Wintermute Engine Forum
Wintermute Engine => Technical forum => Topic started by: Adventureforall on June 15, 2003, 11:48:27 AM
-
Is It possible too use a point in the game, for example, when i pick up a key i get 5 points, and so on.
I though that to accomplish this i had the make a "variable" called "points" and set it to "0" in the beginnening of the game. when an actions is done "var_points +5" (5 is refering to the pionts i ad to the action"
If this is possible can anyone tell me how to to this ?
-
Hi !
Is It possible too use a point in the game, for example, when i pick up a key i get 5 points, and so on.
Actually it is as you already mentioned - you set a global variable "points" and in the action script you just increase this variable. If you have an object called "key", you probably have somethin like a "key.script". And you could do this point system there by:
// points are global to all scripts. if not set yet, set them to zero.
if(points==null) points=0;
on "Take"
{
// walk to the key
GoToObject();
actor.Talk("Cool. It's a golden key! I get 5 points!");
points = points + 5;
}
Hope that helps ?
-
But that way you should put the line "if(points==null) points=0;" in every script that can change the points! You could just place that line once in the game.script file (if you use the wme_demo as a tutorial).
-
So now i put : if(points==null) points = 0 in the game.script file
and after a correct handling i put : points = points + 5
And i need to put : global points; in the base.inc.
Thanx that will help.
-
Looks likes it's working.
Now i want to make an window in the inventory bar to display the score. My question is can i do that in the inventory.def or do i have to make a new file for it, i already tried several things, but the game crashed every time.
-
Now i want to make an window in the inventory bar to display the score. My question is can i do that in the inventory.def or do i have to make a new file for it, i already tried several things, but the game crashed every time.
Yes, you can add it to the inventory.def. There is a "WINDOW" definition in there, just add something like:
WINDOW
{
...
STATIC
{
NAME = "score"
X = 100
Y = 20
}
}
Now, whenewer you change the score, update the score indicator:
var InvWin = Game.GetInventoryWindow();
var ScoreWin = InvWin.GetWidget("score");
ScoreWin.Text = points; // points is your global variable
Note that I'm improvizing now, I didn't test it. There may be some mistakes, but you get the idea.
-
Thanx it's works