Page 1 of 1

[1.1.109] LuaSurface.create_entity uses 0 based indexing for the "bar"

Posted: Thu Jul 04, 2024 1:15 pm
by Atria
When I create entity (specifically a chest) with LuaSurface.create_entity I can provide "bar" parameter which will be used to set bar of a chest.

But this "bar" is treated as zero-based index, instead of 1-based index as all other method which work with inventory bar

Code: Select all

-- setting "bar" to 10, so only first row should be allowed
-- but "get_bar" function returns 11
surface.create_entity({name = 'iron-chest', bar = 10}).get_inventory(defines.inventory.chest).get_bar()

Re: [1.1.109] LuaSurface.create_entity uses 0 based indexing for the "bar"

Posted: Fri Jul 05, 2024 1:16 pm
by Rseding91
Well, that's annoying. It turns out all blueprint strings share this same Lua API. So if I "fix" it for create_entity every single blueprint string will be broken. It's going to need some more thinking.

Re: [1.1.109] LuaSurface.create_entity uses 0 based indexing for the "bar"

Posted: Fri Jul 05, 2024 5:44 pm
by Atria
Plus breaking use of LuaSurface.create_entity in all existing mods which use bar. But to be fair it's probably not that common