Page 1 of 1

how to make an actor have lives

PostPosted: Wed May 16, 2012 12:36 am
by mikek
I have two questions on lives. how do I make it so that when the lives number drops to zero that it load a certain game file.

also, how do I make the number of lives transfer to the next level when you complete the level youre in( I tried using saveVars and loadVars but could not getit to work.

can someone answer these questions for me

Re: how to make an actor have lives

PostPosted: Wed May 16, 2012 1:30 am
by skydereign
Do you know how to use variables? If so this should be pretty straightforward. Namely, you need to set the actor's lives to some non-zero value. You can do this in the actor's create actor event.
actor -> Create Actor -> Script Editor
Code: Select all
lives=3;


Then whenever you decrease the lives (by decreasing the variables) you can use an if to check if lives is less than or equal to 0). In the if statement you call LoadGame to load the other game file.
Code: Select all
lives--; // decrease lives by 1

if(lives<=0)
{
    LoadGame("other_game");
}


As for loadVars and saveVars, have you looked at the tutorials on these forums and/or the script reference? We can't know where you went wrong if you don't tell us, and we don't know what you've tried that didn't work.

Re: how to make an actor have lives

PostPosted: Wed May 16, 2012 5:00 pm
by mikek
I could not get either of these to work and I am not sure how to make it so that the lives actor can be used as a variable.
I'm kind of new to game editor so I'm not sure what went wrong. could someone please post something that might help

Re: how to make an actor have lives

PostPosted: Wed May 16, 2012 11:54 pm
by skydereign
Okay, so you don't know how to use variables. An actor can't be an integer variable. All the variable needs to be in this case is a dedicated number. The value of the number depends on the number of lives the actor has. To create an integer, you can post this in global code, or use gE's gui method.
Global Code
Code: Select all
int lives;

To use gE's variable dialog click [Variables]. From there click [Add]. Type in the name of your variable, and lastly add it. That will create the lives variable just like the above method will. Either way though, the code I posted should then work. One thing to note, you can't have a variable and an actor both named lives.

Re: how to make an actor have lives

PostPosted: Mon May 21, 2012 4:44 pm
by mikek
for some reason when I type it into global code( int lives;) I get a message saying: redeclaration of parameter lives. what should I do to fix this?

Re: how to make an actor have lives

PostPosted: Mon May 21, 2012 4:50 pm
by skydereign
I mentioned this in my post. You cannot have actors and variables named the same thing. So if you have an actor already named lives, you cannot name your variable lives. You can either delete the actor, or just change the name of the variable, for instance player_lives.