Page 1 of 1

How to create a "score" system

PostPosted: Fri Feb 09, 2007 5:44 am
by Candle
16. How to create a "score" system?

First you need to create a new integer variable that will hold the score. To do so, click the "Variables..." button that is under the VBScript text field in the "Hotspot Properties" window and click "New Integer Variable...". Let's call the new variable MYSCORE.

To increase the value of the score by 1, simply use the following code:
MYSCORE = MYSCORE + 1

If you want to tell the player what his or her score is, use the following code:
msgbox MYSCORE

If you want to use a sentence such as "Your score is:", then use the following code:
msgbox "Your score is: " + cstr(MYSCORE)

The reason why the cstr function is used is that you can only add two variables of the same type. Since "Your score is:" is a string and MYSCORE is an integer, you need to convert it to string (with the cstr function) before you can use the "+" operation.

If you want to say "You have not completed the game" if the score is lower than, say, 1000 points, use the following code:
if MYSCORE < 1000 then msgbox "You have not completed the game."



17. How to make the score appear on all the frames?

This question assumes that you have already created a variable contains the score (see the previous question), and that the variable is called MYSCORE.

The following steps will show you how to display the value of MYSCORE on all the frames.

1. Create a new frame, called for example MyScoreFrame.
2. Double-click to get to the frame editor.
3. Right-click to create text.
4. Type the text: "score". Position it where you want the score to appear on all the frames. Close the frame.
5. Click the link for Runtime Frames Merging.
6. You must select each frame that you want to merge with the hotspot in the frame. Use <shift> or <ctrl> to select multiples. Next use the pull-down menu to the frame called MyScoreFrame.
7. Now each of the frames will share the text box, but they don't know what to do with it. Open the Project Properties, go to the Advanced tab, check the option "Execute some VBScript code every time that a frame is loaded", and type in the following code:

i = Action.GetMergedTextIndex
Text(i).Caption="Score: "+CStr(MYSCORE)


See project files zip how to do one.

PostPosted: Fri Feb 09, 2007 9:26 am
by ShadowHunter
Great tutorial Candle :D

Writing scores to an ini file or to the registery in case more players play the game would complete this tutorial 8)

Kind regards,

ShAdOwHuNtEr

PostPosted: Fri Feb 09, 2007 6:38 pm
by Candle
I'll let you do that part of it. lol

PostPosted: Fri Feb 09, 2007 8:23 pm
by ShadowHunter
Hi Candle,

Hehe... got me there :D

For now I'll gues the Tic-Tac-Death demo script will provide all needed information...

Anyway good job Candle !

Kind regards,

ShAdOwHuNtEr

Re: How to create a "score" system

PostPosted: Thu Jan 03, 2008 2:09 am
by dan
can u do this in the free version? plz answer candle :roll: and if you could do this can you do things like having 100 points then accidentlly hurting your self costing you score?

PostPosted: Thu Jan 03, 2008 2:44 am
by Candle
No you can't.

PostPosted: Fri Jan 04, 2008 12:01 am
by dan
aww that sucks :x

PostPosted: Mon Mar 03, 2008 2:05 pm
by Lyberodoggy
ShadowHunter wrote:Great tutorial Candle :D

Writing scores to an ini file or to the registery in case more players play the game would complete this tutorial 8)

Kind regards,

ShAdOwHuNtEr


LOL! I hadn't seen this tutorial :P
If you go in my naming system tutorial, you will see a way of doing so.

PostPosted: Thu Mar 20, 2008 10:16 pm
by Taretia
hey!!

Is there a way to display a hotspot only if the score is lets say 10?? I mean the hotspot becomes visible when you gain your 10th point and disappears when you gain more...

PostPosted: Thu Mar 20, 2008 11:00 pm
by Candle
Taretia wrote:hey!!

Is there a way to display a hotspot only if the score is lets say 10?? I mean the hotspot becomes visible when you gain your 10th point and disappears when you gain more...

yes, just use the variables to do it .

PostPosted: Thu Mar 20, 2008 11:09 pm
by Taretia
Candle wrote:
Taretia wrote:hey!!

Is there a way to display a hotspot only if the score is lets say 10?? I mean the hotspot becomes visible when you gain your 10th point and disappears when you gain more...

yes, just use the variables to do it .


Hey! Great!
OK, so I do a variable when my score is 10 and the use it in the show hotspot only if variable = 1? Or I can write a script to show hotspot is score = 10 or 15 etc?? Sorry, I'm not that good in these... :oops:

PostPosted: Fri Mar 21, 2008 1:58 pm
by Lyberodoggy
I didn't really get the last one, but if I understood it correctly, the tutorial above should help you.


Anyway, as ShAdOwHuNtEr says, when coding, the sky is the limit, so you can make the hotspot appear in many different ways.
First way (using a boolean variable):
Create two integer variables. One named score and one named scoreequaltoten. Then use the score variable to save the user's score.
Go to your hotspot, make it visible only if scoreequaltoten=1. Then use this line of code to make scoreequaltoten=1:
Code: Select all
If score=10 Then
scoreequaltoten=1
else
scoreequaltoten=0
End If

Second way (using only the score variable):
Create just an integer variable named score.
Go to the frame's properties, under advanced type:
Code: Select all
If score =10 then
Hotspot(the number of your hotspot goes here).enabled=False
else
Hotspot(the number of your hotspot goes here).enabled=True
End If


etc...



Hope it helped...

PostPosted: Fri Mar 21, 2008 2:22 pm
by Taretia
Lyberodoggy wrote:I didn't really get the last one, but if I understood it correctly, the tutorial above should help you.


Anyway, as ShAdOwHuNtEr says, when coding, the sky is the limit, so you can make the hotspot appear in many different ways.
First way (using a boolean variable):
Create two integer variables. One named score and one named scoreequaltoten. Then use the score variable to save the user's score.
Go to your hotspot, make it visible only if scoreequaltoten=1. Then use this line of code to make scoreequaltoten=1:
Code: Select all
If score=10 Then
scoreequaltoten=1
else
scoreequaltoten=0
End If

Second way (using only the score variable):
Create just an integer variable named score.
Go to the frame's properties, under advanced type:
Code: Select all
If score =10 then
Hotspot(the number of your hotspot goes here).enabled=False
else
Hotspot(the number of your hotspot goes here).enabled=True
End If


etc...



Hope it helped...



Hey!

Sorry for not making myself clear in my post. But anyway, the first method what you described, that's what I meant! And I was looking for the second method that you described! :) So thank you!! :) You're a great help

PostPosted: Fri Mar 21, 2008 2:34 pm
by Lyberodoggy
:oops: hehe, thanks for the compliment :lol:


You are welcome. It's always nice to be of help...

PostPosted: Sun Mar 30, 2008 3:05 pm
by chickens1127
Excuse me, and laugh at me, but is this for full edition only?

PostPosted: Sun Mar 30, 2008 3:16 pm
by Lyberodoggy
Yes, it's only for full edition, because it requires vbs...

PostPosted: Tue Apr 08, 2008 11:25 pm
by chickens1127
Can I do this with the free version???

PostPosted: Wed Apr 09, 2008 12:16 am
by Candle
chickens1127 wrote:Can I do this with the free version???

I don't know ? what do you think?

PostPosted: Wed Apr 09, 2008 12:22 am
by binhotinto
Nice, I think i'm gonna use this to create a simple life/energy system, I can set the score to 100 points and instead of increase more points, I can decrease it (MYSCORE = MYSCORE - 1) till it reachs 0 (If score=0 Then msgbox "game over" ) :)

PostPosted: Wed Apr 09, 2008 11:06 am
by Lyberodoggy
binhotinto I suggest you see the stress bar tutorial :P
you can display HP bars with it.

PostPosted: Sun Apr 13, 2008 10:33 pm
by chickens1127
I'M CONFUSED!


Can I make a simple scoring system with the free version or not?

If you can, here is where I am:

PostPosted: Sun Apr 13, 2008 11:16 pm
by Lyberodoggy
As far as I am concerned, no there's no way to create a scoring system without AM Full... I 've already answered that before...

PostPosted: Mon Apr 14, 2008 2:07 pm
by Chromegloss55
Yep. Pretty difficult.
_________________
Gnosticism Forum