Page 1 of 1

Possible bug in get_contents() on LuaTransportLine

Posted: Thu Jan 03, 2019 9:59 am
by jan_kran
I'm trying to get content and quantity of items on belt with following command:

Code: Select all

game.player.selected.get_transport_line(1).get_contents()
while hovering the cursor over belt with content. According to docs, return value should be in form of dictionary string → uint
but I'm getting following error:

Code: Select all

1: Unknown key: "4"
"4" seems to be quantity of items, but I was expecting something like

Code: Select all

"item-name": 4
Is there a bug in this command, or am I just using it wrong?
I'm running Factorio 0.16.51 (build 36654, linux64, alpha) with Bob's mods and some QoL mods, but it keeps happening on every item on belt. If you think it might be bug, not misusing, I'm happy to provide log file with modlist.

Re: Possible bug in get_contents() on LuaTransportLine

Posted: Thu Jan 03, 2019 10:17 am
by DaveMcW
Please post your full code. The line you included works fine.

Code: Select all

/c game.print(serpent.block(game.player.selected.get_transport_line(1).get_contents()))

Re: Possible bug in get_contents() on LuaTransportLine

Posted: Thu Jan 03, 2019 10:17 am
by Klonan
It works perfectly fine for me:

Image

Re: Possible bug in get_contents() on LuaTransportLine

Posted: Thu Jan 03, 2019 10:20 am
by Bilka
If you are printing the raw
value in the console, the game will parse it like a localised string which gives that error. You need to use something to format the table, like serpent.block in the code posted by DaveMcW.

Re: Possible bug in get_contents() on LuaTransportLine

Posted: Thu Jan 03, 2019 11:42 am
by jan_kran
Bilka wrote: Thu Jan 03, 2019 10:20 am If you are printing the raw
value in the console, the game will parse it like a localised string which gives that error. You need to use something to format the table, like serpent.block in the code posted by DaveMcW.
Yes, the problem was with formatting the output. Now it works as expected.

Thank you for the support.
Jan.