About obtain container context.

Place to get help with not working mods / modding interface.
NastyGum
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat May 16, 2020 11:36 am
Contact:

About obtain container context.

Post 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?
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4059
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: About obtain container context.

Post 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
NastyGum
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat May 16, 2020 11:36 am
Contact:

Re: About obtain container context.

Post by NastyGum »

boskid, work like a charm!
Big thanks you!))
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: About obtain container context.

Post 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 :)
Image

Transport Belt Repair Man

View unread Posts
Post Reply

Return to “Modding help”