gilzoide / godot-lua-pluginscript

Godot PluginScript for the Lua language, currently based on LuaJIT's FFI
https://gilzoide.github.io/godot-lua-pluginscript/topics/README.md.html
MIT License
308 stars 21 forks source link

Array __newindex Setter Broken #10

Closed bojjenclon closed 2 years ago

bojjenclon commented 2 years ago
E 0:00:04.667   __newindex: attempt to perform arithmetic on global 'index' (a nil value)
stack traceback:
    [string "res://scenes/actors/actor.lua"]:250: in function <[string "res://scenes/actors/actor.lua"]:240>
    in call add_item @ res://scenes/actors/actor.lua
    in call _exit_tree @ res://scenes/objects/pickup_on_free/pickup_on_free.lua
    in call _on_tween_completed @ res://scenes/objects/shrink_away/shrink_away.lua
  <C++ Source>  lps_init_script:1766 @ __newindex()

I was testing the Array indexing changes and it works great for the getter, but it seems the setter is broken. I even tried a very basic repro like below and it errors as well:

inventory[1] = Item:new()

gilzoide commented 2 years ago

Found the issue. I probably just copied and pasted the previous function and forgot to change the parameters. Oops =X https://github.com/gilzoide/godot-lua-pluginscript/blob/main/src/godot_array_commons.lua#L71-L73

bojjenclon commented 2 years ago

All good, happens to all of us. That fixed it though! :D