how to make an actor have lives

Non-platform specific questions.

how to make an actor have lives

Postby mikek » Wed May 16, 2012 12:36 am

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
mikek
 
Posts: 5
Joined: Sun Oct 03, 2010 12:49 pm
Score: 0 Give a positive score

Re: how to make an actor have lives

Postby skydereign » Wed May 16, 2012 1:30 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: how to make an actor have lives

Postby mikek » Wed May 16, 2012 5:00 pm

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
mikek
 
Posts: 5
Joined: Sun Oct 03, 2010 12:49 pm
Score: 0 Give a positive score

Re: how to make an actor have lives

Postby skydereign » Wed May 16, 2012 11:54 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: how to make an actor have lives

Postby mikek » Mon May 21, 2012 4:44 pm

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?
mikek
 
Posts: 5
Joined: Sun Oct 03, 2010 12:49 pm
Score: 0 Give a positive score

Re: how to make an actor have lives

Postby skydereign » Mon May 21, 2012 4:50 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest