Possible bug in get_contents() on LuaTransportLine

Place to get help with not working mods / modding interface.
Post Reply
jan_kran
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Jan 02, 2019 10:37 pm
Contact:

Possible bug in get_contents() on LuaTransportLine

Post 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.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3699
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Possible bug in get_contents() on LuaTransportLine

Post 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()))
Last edited by DaveMcW on Thu Jan 03, 2019 10:18 am, edited 1 time in total.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5148
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Possible bug in get_contents() on LuaTransportLine

Post by Klonan »

It works perfectly fine for me:

Image

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Possible bug in get_contents() on LuaTransportLine

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

jan_kran
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Jan 02, 2019 10:37 pm
Contact:

Re: Possible bug in get_contents() on LuaTransportLine

Post 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.

Post Reply

Return to “Modding help”