Panakotta00 / FicsIt-Networks

Control, Monitor, Manage and Automate your Satisfactory.
https://ficsit.app/mod/FicsItNetworks
GNU General Public License v3.0
167 stars 53 forks source link

getStack(): inconsistant return structure #29

Closed Sinuswutz closed 4 years ago

Sinuswutz commented 4 years ago

Please forgive me if I am using the wrong words. I don't know Lua.

The data structure returned by the getStack() function isn't consistent which can crash the Lua interpreter.

Assume we have an industrial storage container with the network ID “whatever.” There is a stack of items in the first inventory slot. The stack is NOT full. Think 31 turbo motors instead of 50.

container = component.proxy(“whatever”) inventory = container:getInventories()[1] stack = inventory:getStack(1) itemname = tostring(stack.item.type) print(itemname)

The Lua engine will print: “nil”

The “stack.item.type” property doesn't exist and would cause a runtime error if called directly.

getStack(x) will return a data structure containing “item.type” if and only if the stack is full. For example a stack of 50/50 super computers does have the type property. A stack of 49/50 supercomputers does NOT!

Panakotta00 commented 4 years ago

should be fixed with the next update ^^