Page 1 of 1

Scoring System

Posted: Mon Dec 05, 2011 1:07 pm
by Akatz
For my game, the user has to click on a image to gain a score. Currently I have the code :

global highscore
on mouseUp
add 1 to highscore
go to card "
end mouseUp

on each of them and for my start button, I have set it to input 0 into the variable highscore and globalized it.
For my output, I have :

global highscore
put highscore into line 1 of field "output"

but this does not display any number so I'm not sure what I have done wrong. Can someone please direct me in the right direction? :D

Re: Scoring System

Posted: Mon Dec 05, 2011 1:28 pm
by Mark
Hi Akatz,

Many things are not clear. E.g. you write go to card " but you need to specify a name between double quotes. You provide the script

Code: Select all

global highscore
put highscore into line 1 of field "output" 
but it is not clear when this runs. You can put this in a preOpenCard or openCard handler, but you can also put it inside a mouseUp handler.

What do your actual scripts look like?

Kind regards,

Mark

Re: Scoring System

Posted: Mon Dec 05, 2011 1:29 pm
by Klaus
Hi Akatz,

syntax is definitively correct!
I think this is a typo or just "skippng" of the card name:
...
go to cd "
...
right?

But maybe you should be more "precise" here:
...
global highscore
put highscore into line 1 of field "output" OF CARD "where that field really resides"
## Just to be sure that there is or "no such object" error!
...
Just guessing...


Best

Klaus

Re: Scoring System

Posted: Mon Dec 05, 2011 1:33 pm
by Akatz
Sorry, I actually do have the code as go to card "Picture 2" but differently for each picture and I thought I'd just delete the end but deleted too much :p

Once again sorry for not specifying the details, in a bit of a rush. I want the display highscore to show once I go onto the 'End Menu' card which displays the overall score the user has gained. So once they have finished the game, it will go onto that end card that will display such score

Re: Scoring System

Posted: Mon Dec 05, 2011 1:38 pm
by Klaus
Hi Akatz,
Akatz wrote:Sorry, I actually do have the code as go to card "Picture 2" but differently for each picture and I thought I'd just delete the end but deleted too much :p
OK, I guessed, in these cases just use a placeholder like: go card XXX
Akatz wrote:Once again sorry for not specifying the details, in a bit of a rush. I want the display highscore to show once I go onto the 'End Menu' card which displays the overall score the user has gained. So once they have finished the game, it will go onto that end card that will display such score
Well, we also guessed that 8)

Question is, where do you have this script:
...
global highscore
put highscore into line 1 of field "output"
...
Guessing is fine, but won't help here much :D


Best

Klaus

Re: Scoring System

Posted: Mon Dec 05, 2011 1:42 pm
by Akatz
I have it in the actual output box so I think this is where the problem lies? It should actually be within the card itself and it'll activate when it goes onto the card via the openCard handler?

Re: Scoring System

Posted: Mon Dec 05, 2011 1:51 pm
by Klaus
Hi Akatz,
Akatz wrote:I have it in the actual output box so I think this is where the problem lies?
LiveCode is an EVENT DRIVEN application, so if nothing DRIVES that output box, we assume that his is your highscore field?, that script will never get executed!
What is the complete script you have there?
Akatz wrote:It should actually be within the card itself and it'll activate when it goes onto the card via the openCard handler?
Mark already answered this question!
Yes, put it into a "pre/opencard" handler of that card and all should be fine!


Best

Klaus

Re: Scoring System

Posted: Mon Dec 12, 2011 1:11 pm
by Akatz
Sorry, been busy lately so only got round to doing it now. It works so thank you very much for the help :)

Re: Scoring System

Posted: Mon Dec 19, 2011 1:25 pm
by Akatz
Sorry but I need help once again. For my project, I need to be able to read and write from a file that has been created that includes the username and highscores of previous players and this has to be put into a table. I seriously don't know how to tackle this and I've checked the forums to no avail. Thanks

Re: Scoring System

Posted: Mon Dec 19, 2011 1:42 pm
by Mark
Hi,

Use the read and write commands to read from and write to a file. You can also use the put and get URL commands. I think there are plenty of examples in this forum, which show how to read and write.

I'd assume you have your data in a variable or in a field. You can simply write this data to the file and read the data from the file when the next session starts.

I would keep such a file in the preferences folder on Mac or in the Application Data folder on Windows.

Kind regards,

Mark