Closed bojjenclon closed 2 years ago
Hmm, that's a good question.
I think most of the time people won't be calling the same functions with both tables and Arrays/Pool*Arrays, but now that I'm thinking better about it, I guess making both work with 1-based indexing will do more good than harm.
Anyone wanting 0-based indexing with Arrays can still call get
/set
or safe_get
/safe_set
if they know they have an Array/Pool*Array in hand.
In this case, I think we should also change Array.__ipairs
to return indices starting from 1.
An example where you may use both Lua tables and Godot Arrays is using a LuaRocks library to perform some data manipulations then converting it into a specific Godot Array indexing scheme.
I agree about ipairs though.
Good point, thanks for the insight! Ok then, I'll make it happen =]
Currently, an object constructed from the
Array
wrapper in Lua requires zero-indexing to access its elements. This looks wrong next to Lua's one-indexing, and can lead to some odd logic that requires checking types and adding/subtracting one to avoid OBO errors. ShouldArray
be changed to one based indexing?