Howdy, Stranger!

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

Codea 2.0 and saveScore() ?

edited April 2014 in Bugs Posts: 88

Has anything changed in Codea 2 that would make my Game Center addon submit 0 scores?

Is the saveScore() function maybe undocumented but taking over the addon's function?

Something weird is going on, it used to work ... Hmmm ...

Comments

  • Posts: 4

    Wow, same problem here. Tried to change the GameCenterAddOn using GKGameCenterViewController, but I'm too bad at this :(

  • Posts: 88

    To get rid of deprecated issues?

    I don't think they're causing this as the same addon worked fine in Codea 1.5x

  • Posts: 88

    I've now confirmed it, Codea 2 saveScore saves a 0 with an app that used to work

    In Codea 1.5 and where the Game Center code and addon remained unchanged ...

  • edited April 2014 Posts: 88

    Anyone try publishing an app and their saveScore doesn't work?

    I put an NSlog and it shows the score being submitted, and the score is in the sandbox,

    but when the app gets published the score being reported is 0

    Same code used to work and it was submitting in Codea 1.5 - i'm lost ...


    All 3 of my apps lost the game center functionality. Some scores are there from 1.5

  • Jmv38Jmv38 Mod
    Posts: 3,297

    @Zoyt maybe you can help here?

  • Posts: 2,048

    @escape75, when the runtime function receives the number, is it always zero? Because there is an error with lua_tonumber that seems to pop up sometimes where it always returns 0

  • Posts: 2,048

    @escape75, when the runtime function receives the number, is it always zero? Because there is an error with lua_tonumber that seems to pop up sometimes where it always returns 0

  • Posts: 2,820

    Looks like your having the same bug as I did. Try this and see what is logs: NSLog(@"%f",lua_tonumber(L,1);. (This was not tested, let me know if it raises an error.)
    See this thread for a temporary solution: http://codea.io/talk/discussion/4841/possible-bug-lua_tonumber-not-working-after-update-to-runtime#Item_5
    @Simeon - Any idea whythis is happening to 3-4 people?

  • Posts: 2,820

    @escape75 - Use my GameCenter library here, which is more up to date: http://codea.io/talk/discussion/4221/objective-c-libraries-testflight-gamecenter-location-twitterfacebookcamera-roll-sharing-more#Item_9
    For those having issues with lua_tonumber and have a iOS 7 build dependency, I'll post the new code eventually.

  • edited April 2014 Posts: 88

    Thank You! I'll test this asap, but not sure if I'll get to it tonight

    I'm pretty sure I'm using lua_tonumber and in the simulator it seemed to work

    but when the app got submitted it always seems to be 0 - but maybe not always?

    I will try to work on the lua_tonumber, thanks for the hint.


    It didn't make sense to me because nothing was changed in the code,

    and after going from 1.5x to 2.0 that part just stopped working altogether.


    Oh and like I said I put an NSLog right when the Game Center submit happens

    and in the simulator it was fine, but then I submitted the app and now it submits 0's ...

  • Posts: 88

    @Zoyt I'll have a look at your library, I just re-wrote mine to fix the

    deprecated issues after targeting IOS7 and 7.1 but didn't resubmit my apps.

  • Posts: 2,820

    @escape75 - It seemed unpredictable for me. Try my temporary fix for lua_tonumber if you haven't already. Thanks!

  • edited April 2014 Posts: 88

    @Zoyt Ok you were right, it was lua_tonumber ...


    Take the following example, commented out part always produces 0

    but only when running on a real device, and not in a simulator,- plus a fix

    This of course assumes the score is always an integer, etc.

    
    from LUA call "saveScore(12345)"
    
    static int saveScore(struct lua_State *state)
    {
        // [gameCenterAddOnInstance saveNewScore: lua_tonumber(state, 1)];
        [gameCenterAddOnInstance saveNewScore: atoi(lua_tostring(state, 1))];
        return 0;
    }
    
    - (void) saveNewScore: (NSInteger) score
    {
        NSLog(@"score: %d", score);
        // we don't need to submit to Game Center, just a test.
    }
    
  • Posts: 88

    Update: submitted new version with the fix above and scores work again !

  • edited April 2014 Posts: 88

    Have you guys figured out why lua_tonumber(state,1) produces 0, but

    atoi(lua_tostring(state,1)) works everytime, and will Codea 2.01 fix it?


    Note that the 0 is only produced on a real device, and in simulator it's ok ...

  • Posts: 13

    I have the same problem. Thanks for the workaround! It works.

  • Posts: 13

    The same problem in Codea 2.1 but only in the 64 bit simulator.

Sign In or Register to comment.