[solved]works but ITS BUGGED only few lines

Place to get help with not working mods / modding interface.
Post Reply
heloo22
Burner Inserter
Burner Inserter
Posts: 18
Joined: Wed Aug 22, 2018 11:20 am
Contact:

[solved]works but ITS BUGGED only few lines

Post by heloo22 »

anybody understands this?? i cant figure it out but almost got it!

This one when building anything it makes sure that the item don't get used.
PROBLEM?
it works but when placing blueprints, it will for some reason give to the main inventory 12 empty blueprints. everytime...

Code: Select all

script.on_event(defines.events.on_built_entity, function(event)
	local player = game.players[event.player_index]
	
		if event.stack then
			player.insert({name = event.stack.name, count = 1})
		end
end)
and this one will make sure that player doesn't have more than 1 of any item (important)
PROBLEM?
you can't get any resources from trees or stones

Code: Select all

script.on_event(defines.events.on_player_mined_entity, function(event)
	local entity = event.entity
	local player = event.player_index and game.players[event.player_index] or nil
	if player then
		for i = 1,#event.buffer do
			local item = event.buffer[i]
			if player.get_item_count(item.name) > 0 or not(item.prototype.place_result or item.prototype.place_as_tile_result) then
				event.buffer.remove({name = item.name, count = item.count})
			end
		end
	end
end)
Last edited by heloo22 on Thu Aug 23, 2018 3:39 am, edited 3 times in total.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: works but ITS BUGGED only few lines

Post by DaveMcW »

For problem 1, don't do anything if event.created_entity.name == "entity-ghost".

For problem 2, don't do anything if event.entity.force.name == "neutral".

heloo22
Burner Inserter
Burner Inserter
Posts: 18
Joined: Wed Aug 22, 2018 11:20 am
Contact:

Re: works but ITS BUGGED only few lines

Post by heloo22 »

amazing, works now thank you

Post Reply

Return to “Modding help”