Scoring System

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Akatz
Posts: 12
Joined: Mon Oct 31, 2011 1:28 pm

Scoring System

Post by Akatz » Mon Dec 05, 2011 1:07 pm

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Scoring System

Post by Mark » Mon Dec 05, 2011 1:28 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Scoring System

Post by Klaus » Mon Dec 05, 2011 1:29 pm

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

Akatz
Posts: 12
Joined: Mon Oct 31, 2011 1:28 pm

Re: Scoring System

Post by Akatz » Mon Dec 05, 2011 1:33 pm

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

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Scoring System

Post by Klaus » Mon Dec 05, 2011 1:38 pm

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

Akatz
Posts: 12
Joined: Mon Oct 31, 2011 1:28 pm

Re: Scoring System

Post by Akatz » Mon Dec 05, 2011 1:42 pm

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?

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Scoring System

Post by Klaus » Mon Dec 05, 2011 1:51 pm

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

Akatz
Posts: 12
Joined: Mon Oct 31, 2011 1:28 pm

Re: Scoring System

Post by Akatz » Mon Dec 12, 2011 1:11 pm

Sorry, been busy lately so only got round to doing it now. It works so thank you very much for the help :)

Akatz
Posts: 12
Joined: Mon Oct 31, 2011 1:28 pm

Re: Scoring System

Post by Akatz » Mon Dec 19, 2011 1:25 pm

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Scoring System

Post by Mark » Mon Dec 19, 2011 1:42 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply