Coolcrab Posted September 29, 2018 Share Posted September 29, 2018 I just noticed that my Highscore saving script does not work, mostly because it looks at the 3 score groups separately. if _sc1 > _a then __New_High_Score if _sc2 > _b then __New_High_Score if _sc3 > _c then __New_High_Score goto __Skip_High_Score __New_High_Score rem store high score _a = _sc1 : _b = _sc2 : _c = _sc3 __Skip_High_Score WIth this script 000085 will be seen as a high score compared to 002040 because 85 > 40. Is there a simple way around this that used 16 bytes or less? Quote Link to comment https://forums.atariage.com/topic/283464-saving-highscore/ Share on other sites More sharing options...
+Random Terrain Posted September 29, 2018 Share Posted September 29, 2018 All I know is that supercat and Nukey Shay went over and over and over this code until it was about as perfect as you can get: Saving a High Score (by supercat and Nukey Shay) Quote Link to comment https://forums.atariage.com/topic/283464-saving-highscore/#findComment-4123808 Share on other sites More sharing options...
+Karl G Posted September 29, 2018 Share Posted September 29, 2018 If in your source, _sc1 is set to score, _sc2 is set to score+1 and _sc3 is set to score+3, then it would first checks the variable holding the 100 thousands and ten thousands digits, then the variable holding the thousands and hundreds digits, then the variable holding the tens and ones digits. In your example, 002040 would register as a new high score over 000085 because _sc2 would be compared before _sc3, and 20 > 0. So, the code above in theory should work. My guess would be there is somewhere else you are setting or resetting the values in _a _b and _c causing it to not work as you expect. Quote Link to comment https://forums.atariage.com/topic/283464-saving-highscore/#findComment-4123821 Share on other sites More sharing options...
Coolcrab Posted September 30, 2018 Author Share Posted September 30, 2018 All I know is that supercat and Nukey Shay went over and over and over this code until it was about as perfect as you can get: Saving a High Score (by supercat and Nukey Shay) Thanks! It didn't fit but I change it up into this. if _sc1 > _a then __New_High_Score if _sc1 < _a then __Skip_High_Score if _sc2 > _b then __New_High_Score if _sc2 < _b then __Skip_High_Score if _sc3 > _c then __New_High_Score else goto __Skip_High_Score If in your source, _sc1 is set to score, _sc2 is set to score+1 and _sc3 is set to score+3, then it would first checks the variable holding the 100 thousands and ten thousands digits, then the variable holding the thousands and hundreds digits, then the variable holding the tens and ones digits. In your example, 002040 would register as a new high score over 000085 because _sc2 would be compared before _sc3, and 20 > 0. So, the code above in theory should work. My guess would be there is somewhere else you are setting or resetting the values in _a _b and _c causing it to not work as you expect. if score is xxyyzz then sc1=xx, sc2=yy, sc3=zz right? Or is it the other way around? Because it can skip the first two if's in the original code if they are not larger and the get triggered on the third. The new code seems to work better, but I'm still testing. Quote Link to comment https://forums.atariage.com/topic/283464-saving-highscore/#findComment-4124127 Share on other sites More sharing options...
bogax Posted September 30, 2018 Share Posted September 30, 2018 I think this should work, but I don't think you can do it in less than 16 bytes dim scr0 = score dim scr1 = score + 1 dim scr2 = score + 2 dim hi0 = a dim hi1 = b dim hi2 = c if scr0 <= hi0 && scr1 <= hi1 && scr2 <= hi2 then skip_new_high_score hi0 = scr0 : hi1 = scr1 : hi2 = scr2 skip_new_high_score Quote Link to comment https://forums.atariage.com/topic/283464-saving-highscore/#findComment-4124311 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.