Page 1 of 1

About obtain container context.

Posted: Sat May 16, 2020 11:57 am
by NastyGum
Hi!
I need information about contents of the container.

Code: Select all

for _, entity in pairs(player.surface.find_entities_filtered{area = radius, name = "wooden-chest"}) do
	player.print(entity.get_contents)
end
With I expect some table output with print like
iron-ore - 1000
iron-plate - 100
copper-plate - 100
etc etc
But get this
Pic
What I'm doing wrong?

Re: About obtain container context.

Posted: Sat May 16, 2020 12:06 pm
by boskid
https://lua-api.factorio.com/0.18.24/LuaEntity.html

Code: Select all

for _, entity in pairs(game.player.surface.find_entities_filtered{area = radius, name = "wooden-chest"}) do
    game.player.print(serpent.block(entity.get_inventory(defines.inventory.chest).get_contents()))
end

Re: About obtain container context.

Posted: Sat May 16, 2020 12:12 pm
by NastyGum
boskid, work like a charm!
Big thanks you!))

Re: About obtain container context.

Posted: Sat May 16, 2020 3:26 pm
by steinio
NastyGum wrote: Sat May 16, 2020 12:12 pm boskid, work like a charm!
Big thanks you!))
Hey have you understood what was changed and why it now works?
Boskid is just bit thrifty with words :)