[0.12.5] Lua TransportLine get_contents()

Bugs that are actually features.
Post Reply
Kikkers
Fast Inserter
Fast Inserter
Posts: 109
Joined: Sun Jun 22, 2014 8:45 pm
Contact:

[0.12.5] Lua TransportLine get_contents()

Post by Kikkers »

This scripting function doesn't seem to populate the table it returns.

Reproducable by filling a belt, calling get_contents() on one of the belt's lines, and printing the # of the returned table.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13219
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.12.5] Lua TransportLine get_contents()

Post by Rseding91 »

#table doesn't work that way for named indexes:
Image

You have to check for the key and then if it isn't nil check the count it returns.

See: http://www.lua.org/manual/5.2/manual.html#3.4.6
If you want to get ahold of me I'm almost always on Discord.

Kikkers
Fast Inserter
Fast Inserter
Posts: 109
Joined: Sun Jun 22, 2014 8:45 pm
Contact:

Re: [0.12.5] Lua TransportLine get_contents()

Post by Kikkers »

What a language, what a wonderful language.

You're completely right, but still, I was sure i did check whether looping worked. Apparently not.

Post Reply

Return to “Not a bug”