Page 1 of 1

[solved]works but ITS BUGGED only few lines

Posted: Wed Aug 22, 2018 12:23 pm
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)

Re: works but ITS BUGGED only few lines

Posted: Wed Aug 22, 2018 6:33 pm
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".

Re: works but ITS BUGGED only few lines

Posted: Thu Aug 23, 2018 3:29 am
by heloo22
amazing, works now thank you