godot_luaAPI
godot_luaAPI copied to clipboard
Bug Report: Numbers returned from lua are always cast as floats
Describe the bug When pushing an integer value to lua, it is always pulled back as a float.
To Reproduce Steps to reproduce the behavior:
var lua := LuaAPI.new()
var num: int = 10
lua.push_variant("num", num)
var pulled = lua.pull_variant("num")
print(typeof(pulled)) # float
Expected behavior The value should be of variant type integer.
Lua does not have Integer, it only has number which is similar to float https://www.lua.org/pil/2.3.html
Godot supports integers though. This is what I'm currently doing in my project but it's a bit hacky:
if value is float and fmod(value, 1) == 0:
value = int(value)