WeaselGames / godot_luaAPI

Godot LuaAPI
https://luaapi.weaselgames.info
Other
348 stars 27 forks source link

Bug Report: Numbers returned from lua are always cast as floats #209

Open jbromberg opened 2 months ago

jbromberg commented 2 months ago

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.

Supchik22 commented 2 months ago

Lua does not have Integer, it only has number which is similar to float https://www.lua.org/pil/2.3.html

jbromberg commented 2 months ago

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)