I’m running into an odd issue after the update to the runtime where anywhere I put lua_tonumber, it returns 0 or occasionally some bogus number. I’m wondering if any of you are having the same issue, or if this is just an issue with my code in some hidden pocket.
Right now, I’m using this code to make it work, but it’s not very smooth:
#define LUA_TONUM(s,x) ((float)atof(lua_tostring(s,x)))
@Zoyt you probably don’t want the (float) cast in there.
#define LUA_TONUM(s,x) (atof(lua_tostring(s,x)))
Codea is 64 bit now, so you’d be losing precision by casting to a 32 bit float. I can’t see why
lua_tonumber wouldn’t work. You’ll have to explain more about your situation.
@Simeon - Odd, I fixed it. I didn’t have much time to fool around with things to try and debug this when I posted it, but brand new projects do not seem to have the issue. So, I went ahead and used FileMerge to compare the two, and I found that the Codea libraries were different. So I reinstalled it, and it works just fine now. Did you update the runtime since you sent out the first runtime during beta?
Edit: IDK what happened, but it seems that that didn’t fix it. Now I’m really lost. I’ve compared all the files, and they’re identical. That being said, it’s probably an issue somewhere in my code, but I can’t find it. (crap…)
Edit #2: I forgot to mention that other things like lua_tostring and lua_tointeger work just fine. I’m only having issues with lua_tonumber. My code even says that it’s a number (using lua_type), but it still returns 0. It returns a valid value when using lua_tointeger and lua_tostring.
@Zoyt I was seeing the same issue before. It fixed itself for me, but I worry about it returning and causing problems.
@JakAttak - I think I’ve had this issue before too, but I think it was fixed by cleaning the project. It isn’t doing the trick.