This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-11-03 10:04:11

maurootjr
New Scratcher
Registered: 2012-11-02
Posts: 6

highscore list

how to make highscore list

Offline

 

#2 2012-11-03 12:42:28

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: highscore list

First, you'll need to create a variable called i and a list called highscores. Once you've done this, use this script for a highscore list:

set [i v] to (1)
repeat until <(i) = [h]>//*
 if <not <(item (i) of [highscores v]) > (score)>>
  insert (score) at (i) of [highscores v]
  set [i v] to [h]
 else
  change [i v] by (1)
  if<(i) > (length of [h v])>
   insert (score) at [last v] of [highscores v]
   set [i v] to [h]
  end
 end
end
* - This repeat loop and the scripts in it check to see where to put the score.

Run this whenever you finish the game.

Anyway, I hope that this helps!

Last edited by ErnieParke (2012-11-03 12:44:19)


http://i46.tinypic.com/35ismmc.png

Offline

 

#3 2012-11-03 16:26:18

cognig
New Scratcher
Registered: 2012-11-03
Posts: 5

Re: highscore list

new to scratch , I'm assuming a list is a one dimensional array with h  pointing to last cell

if i = h - 1 and new score < highscores[h-1] then first if is false goto second if
now i = h so we don't do second if but get out of the loop because i = h; this means we never put the lowest score in cell h!!!!

also say new score = highscores[i] then 1st if is true so we over write old score, but both scores are the same, inefficient code.

looks like the problem is the "not" of first if, a true on the first if is both of these cases, when highscores[i] < score, but also when highscores[i] is = score

would it be better to just say for first if: if highscores[i] < score?

do this then it looks like highest score will be in the last cell

Paul USA

Offline

 

#4 2012-11-03 16:26:40

stevetheipad
Scratcher
Registered: 2011-08-06
Posts: 1000+

Re: highscore list

ErnieParke is right, but that's for a personal high score list. Unfortunately, in this version of scratch, you can't save data for all players.


http://i.imgur.com/0x8ia.jpg
gone

Offline

 

#5 2012-11-03 16:30:00

gxl
Scratcher
Registered: 2010-04-15
Posts: 100+

Re: highscore list

Ah thankyou! I will add this to my next game ^^


http://i185.photobucket.com/albums/x87/tyagust/cloudosigcopy-1.jpg

Offline

 

#6 2012-11-03 18:01:17

maurootjr
New Scratcher
Registered: 2012-11-02
Posts: 6

Re: highscore list

Thanks everyone

Offline

 

#7 2012-11-04 01:55:49

maurootjr
New Scratcher
Registered: 2012-11-02
Posts: 6

Re: highscore list

where i must put that script

Offline

 

Board footer