Code: Select all
if game.tick % 60 == 0 and npc_worker ~= nil then
local inventory = npc_worker.get_main_inventory()
local item_count = inventory.get_item_count( 'iron-ore' )
game.surfaces.nauvis.create_entity( { name = 'flying-text', position = { 4, 4 }, text = item_count .. ' [img=item/iron-ore]', color = { r = 0.98, g = 0.66, b = 0.22 } } )
if item_count > 0 then
game.surfaces.nauvis.spill_item_stack( { 6, 6 }, { name = 'iron-ore', count = item_count }, true )
inventory.clear()
end
end