[0.17.72] Cleaning the inventory does not work
Posted: Sun Oct 20, 2019 4:38 am
I created a character and ordered him to mine ore. What works so far, the ore accumulation is now great, is still filed only an ore and emptied the inventory. Now the problem, the number in the inventory increases for no apparent reason.
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