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

#1 2012-01-27 23:38:15

tibstar
New Scratcher
Registered: 2012-01-27
Posts: 5

Need help with script

I want to add a feature to a script i have, basicaly need to add a scoring system to a game. record the number of attempts made, if the score for say level 1 is better than before, replaces the score.

I have been able to get it to do this, but it always adds another number to the score list. so if the score for level 1 is entered, it adds a number into level 2 and i don't see why it does that.

if someone can help, i can send you the game to look at

Offline

 

#2 2012-01-27 23:45:05

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Need help with script

tibstar wrote:

I want to add a feature to a script i have, basicaly need to add a scoring system to a game. record the number of attempts made, if the score for say level 1 is better than before, replaces the score.

I have been able to get it to do this, but it always adds another number to the score list. so if the score for level 1 is entered, it adds a number into level 2 and i don't see why it does that.

if someone can help, i can send you the game to look at

Do you have it add or replace the score? Could you show us your script?

Offline

 

#3 2012-01-28 05:29:54

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Need help with script

Ok, so I imagine you have a 'level' variable and a 'score' variable. You'll also want a highscores list to save your per-level highest score. Once you finish your level, you should broadcast something like 'level finished'. You could then do something like

when I receive [level finished! v]
repeat until < ((length of [highscores v]) + (1)) > (level) >
  add [0] to [highscores v] //list should be long enough
end
if <(score) > (item (level) of [highscores v])>
  replace item (level) of [highscores v] with (score)
  say [You've beaten your previous record!] for (2) secs
end


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#4 2012-01-28 09:51:36

treebark1313
Scratcher
Registered: 2011-05-23
Posts: 90

Re: Need help with script

You need to be more specific... i can't really help without enough info on your problem.


When life gives you 100 reasons to frown,
show life you have 1000 reasons to smile. - Unknown

Offline

 

#5 2012-01-28 16:02:02

tibstar
New Scratcher
Registered: 2012-01-27
Posts: 5

Re: Need help with script

JSO that looks like what i need.

I'm not sure how to show you the code on here, could i send someone the scartch file, and they look at it? i will explain in the the email what i need to do.

it's a very cool program, just so frustrating when you get stuck.

kind regards

Offline

 

#6 2012-01-28 16:27:40

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Need help with script

tibstar wrote:

JSO that looks like what i need.

I'm not sure how to show you the code on here, could i send someone the scartch file, and they look at it? i will explain in the the email what i need to do.

it's a very cool program, just so frustrating when you get stuck.

kind regards

Try implementing the code example above, and see how it goes  smile  If you can't get it to work, just upload the project to your account and I'll look into it if you want.


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

Board footer