Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Possible bug: lua_tonumber not working after update to runtime?

edited March 2014 in Bugs Posts: 2,820

Hello,
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)))

Thank you!

Tagged:

Comments

  • SimeonSimeon Admin Mod
    Posts: 4,886

    @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.

  • edited March 2014 Posts: 2,820

    @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?
    Thanks!
    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.

  • Posts: 2,042

    @Zoyt I was seeing the same issue before. It fixed itself for me, but I worry about it returning and causing problems.

  • Posts: 2,820

    @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. :/

Sign In or Register to comment.