How to update my own in-game leader board

EireStudiosEireStudios Member Posts: 451
edited February 2012 in Working with GS (Mac)
Hi Guys and Gals, I'm having a bit of a problem so I hope ye can help me? I'll try and explain this as best I can, I have my own leaderboards added to my game (not gamecenter) and the way it works is I have five attributes game.timer, game.level1timer, game.level2timer, game.level3timer and game.level4timer I have game.timer on a timer that says every 1 second change game.timer to game.timer+1 and on my leaderboard screen I want it to display game.level1timer in one box and game.level2timer in the next box etc etc..

So what I really need to know is how do I get it to save game.timer to game.level1timer for the first level then reset back to zero then record game.timer to game.level2timer for the second level, then once that is done how would I get it to only save game.level1timer if it is less then game.level1timer i.e if the player replays level one and gets a better time I would only like it to save if its a lesser time than the first time the player completed the level and then show on the leaderboard scene.

I hope I explained myself enough but if ye need to ask me any questions just ask and I'll try and explain myself a bit better. I'm at a total standstill with my next project until I can figure this out so I really hope you guys can help me out, Thanks for reading

Comments

  • MotherHooseMotherHoose Member Posts: 2,456
    just before changeScene … a changeAttribute: game.level#time To: scene.Time

    for ordering a list of those attribute values: you will need attributes to hold listTimePlacements (real) and levelNames (text)… then

    Rules: when (All) … (name this rule: ? level 1 1st place ?)
    Attribute: game.level1Time < game.level2Time
    Attribute: game.level1Time < game.level3Time
    Attribute: game.level1Time < game.level4Time
    --changeAttribute: game.list1st To: game.level1Time
    --changeAttribute: game.list1stName To: Level 1
    Otherwise:
    Rules: when (All)… (name this rule: ? level 1 4th place ?)
    Attribute: game.level1Time > game.level2Time
    Attribute: game.level1Time > game.level3Time
    Attribute: game.level1Time > game.level4Time
    --changeAttribute: game.list4th To: game.level1Time
    --changeAttribute: game.list4thtName To: Level 1

    then create rules for 2nd and 3rd place
    do for each level

    sounds complicated … this is a lot of rules … but mostly option+drag after the 1st set and just select the correct attribute
    you may want a controlActor running this and mayhap have your background spawn that control after the scene loads

    Good Luck!

    @};- MH
  • EireStudiosEireStudios Member Posts: 451
    I don't think I explained myself very well sorry, I'm only looking for one time to be show on my leader board i.e the fastest time level 1 was completed, I have an image with 20 boxes to represent the 20 levels I have in my game for my leaderboard and inside those boxes I want the fastest time to be displayed, so I don't think I need a first second or third attribute, hopefully this will make it easier to accomplish :D

    I got it to display the game.level1timer so I have managed to change my game.timer to game.level1timer and then save it but now it only saves if the player takes longer to complete the level i.e player 1 completes it in 10 seconds but if player 2 completes it in under 10 seconds it doesn't update or save, but if player 3 does it in 12 seconds it updates and saves no problem.

    Oh my head hurts right now and things are getting very messy :O
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    edited February 2012
    Well if you had used one timer alone for all the 20 levels, it would it will be easier.
    Create one game.timer where you run the normal timer count up.
    Then when level ends in success check timer agains best time if you have one. else create one so you have a current timer and a best time.
    However the first score is always 0 since there's no best time yet so have the rule
    If best time = 0 or best time > game.timer
    change attribute best time to game.timer
    save attribute best time to l1best or whatever naming convention you wish.
    Then set the game.timer back to 0 for next level.
    So every time you win that level save attribute for the best time accordingly l1best, l2best whatever you named it.
    Then on your own leader board page use the load attribute rule to display all the individuals best time on each level's boxes.
    That's how it can be done.
  • EireStudiosEireStudios Member Posts: 451
    @GLGames I see what you mean but right now I am very close to accomplishing what I want to do but it only saves when the game.timer > game.level1timer and wont save if it you get a lesser time, which is what I need it to be doing.
    Here is a screenshot maybe you could tell me if you see anything wrong, just don't laugh because I have a feeling I'm doing something very wrong but very simple to fix :-S

    Photobucket
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    Can i know game.t.s1.l1 is what attribute?
    It's a bit confusing when you are using the same naming for game attribute and save keys...
  • EireStudiosEireStudios Member Posts: 451
    @GLGames t.s1.l1 is level one timer I.e. game.level1timer it stands for timer sector1 level1 because I have 5 worlds/sectors with 20 levels in world/sector
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    edited February 2012
    So is the better timing more or less then previous that u like to update? As what you have in your rule it seems like everytime your current level time is smaller than your leaderboard time then you replace current time with leaderboard time. Shouldn't it be the opposite? And your otherwise condition seems not very feasible.

  • EireStudiosEireStudios Member Posts: 451
    @GLGames to be honest I have tried changing the attributes into different positions and tried different ways of doing it and the way I have it right now is the only way it registers a number on my leader board, is there anyway you could plaese recreate what your taking about in the creator and post a screenshot of how you would go about doing it?
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    the way i told you about is the one i said earlier using load attribute for every leaderboard that you need.
    so the saving part is basically,
    when level completes is true
    check if best time = 0 or best time more then current time
    change best time to current time
    save attribute current time
  • EireStudiosEireStudios Member Posts: 451
    edited February 2012
    @GLGames Thanks very much you have been a great help so far. I have done what you told me to do but now when ever my time is greater than game.besttime my leaderboard shows 0.00 time but if I go and get a better time i.e game.timer < game.besttime I shows the best score i.e 3.55, also it loads the same game.besttime for all my levels, I'll post a few screen shots to show you how I have it done right now

    Photobucket
    This is how I am saving everything and when the level is finished a menu pops up and when you click next level it resets game.LBTimer back to 0

    Photobucket
    This is how I am loading the best time attribute for each of the levels but where it says T.S1.L1 for the key for level 1, on level 2 I use T.S1.L2

    Photobucket
    This is my leader board screen just to show you how everything looks

    Thanks again you have been a great help so far :)
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    On your individual leader create individual self.besttime attribute
    Example level1 box should be load attribute T.s1.l1 to self.besttime(level1 box)
    then use your display rule with self.besttime instead. For every other level boxes use the same way. for level2 load attribute t.s1.l2 to self.besttime(level2 box)
    then use the display rule etc....
Sign In or Register to comment.