Hi everyone!
I'm new to the forums and I have read the manual but i'm puzzled by something.
In a game I am making I will be awarding points, but I don't know how to have a Points total ( something like 10/100 ), this would be on the GUI when the mouse is not moving over it.
Can someone please help with my problem?
Its in the manual but yeah it kinda hard to find stuff in the manual isn't it? :)
First make a label on the GUI you want your score displayed on. Then rename the label to @SCORETEXT@ and voila!
R4L
EDIT: I didn't know that there are all those @s available, so please ignore my post (unless you want to customize the way the score is displayed by adding a percentage bar or the like)
Add this to the end of your global script:
function on_event(EventType event, int data) {
if (event=eEventGotScore) {
score_label.Text=String.Format("Score: %d/100", game.score);
}
}
You need to change "score_label" to whatever the script name of the label is.
(If there already is an on_event function, just insert the if (..) {...}, don't create another one, of course.)
I think this (http://www.adventuregamestudio.co.uk/manual/Interface%20text.htm) is the manual entry R4L was talking about.
Setting the Label text to @SCORETEXT@ in the editor should display about the same as KhrisMUC's code ("Score : 10 of 100") and will automatically update itself, or you can use @SCORE@ and @TOTALSCORE@ for a different layout.
Ok It's working now :D
Cheers guys.
I have just been reading this thread and I did the score gui bar but there is one problem with my score bar, it wont stay under the main pop up gui bar (where you can select walk look talk etc cursors from), instead the score bar stays on top of the main pop up one. How can this be resolved? I set the score bar is normal and have tried other options, but nothing will stop it from being over the pop up one. Any ideas? Thanks :)
Gypsynail, the Z-order of the score GUI must have a smaller value than the Z-order of the pop-up GUI.
Aha! Thanks :) so thats what the z order was for. I understand. Cheers :)
Hi guys it's me again
I've figured out how to get the total up, but what do i do to make the character go to another room if it has for example 100/100?
thanks again
function on_event(EventType event, int data) {
if (event=eEventGotScore) {
if (game.score==100) player.ChangeRoom(...);
}
}
thanks Khris
Quote from: KhrisMUC on Fri 24/11/2006 22:09:57
function on_event(EventType event, int data) {
Ã, if (event=eEventGotScore) {
Ã, Ã, if (game.score==100) player.ChangeRoom(...);
Ã, }
}
Hi again, I have recently done the 'bulk' of my game, and I have tried to put this code in. However, when I do so the message appears, 'expected ' ( ' ' and if I add the '(' the message appears 'Unexpected ' ( ' '.
I have placed this code at the bottom of the global script, exactly as Khris has put, except I changed the number '100' with '140', and I have also changed the '...' next to the word 'ChangeRoom' to '14'. But it does not seem to work, can anybody help me with this problem?
Thanks.
Apart from the fact it should be event == eEventGotScore ( two '='s) KhrisMUC's code looks sound and should survive those changes. Which line generates the error, and where have you added the '('? It would help to see the code you're actually using, and not Khris' example.
My code is:
function on_event(EventType event, int data) {
Ã, if (event=eEventGotScore) {
Ã, Ã, if (game.score==140) player.ChangeRoom(14);
Ã, }
}
The error message for the '(' is the line where the 'function on_event' is (can't remember line number).
I shall try that code with the extra '=' now Ashen, will edit ASAP.
EDIT: works perfectly now, thanks Ashen, have a merry christmas!