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)
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)