ID:170666
 
Ok, lets say I have an icon of a little man and some numbers. I want the numbers to appear next to the man to count as lives. Can someone tell me how to program it so that each time the player looses a life, the number goes down to the nmumber below it. So if a mob has 3 lives and the little number next to the man says 3, and the mob looses a life, the number next to the man turns into a 2, then a 1, then a zero, until it hits zero. Then if the mob decides to play again, it resets to three. I also need to know how to make it so that if the mob picks up something like a 1 up, the number increases. Thanks in advance.
Reinhartstar wrote:
Ok, lets say I have an icon of a little man and some numbers. I want the numbers to appear next to the man to count as lives. Can someone tell me how to program it so that each time the player looses a life, the number goes down to the nmumber below it. So if a mob has 3 lives and the little number next to the man says 3, and the mob looses a life, the number next to the man turns into a 2, then a 1, then a zero, until it hits zero. Then if the mob decides to play again, it resets to three. I also need to know how to make it so that if the mob picks up something like a 1 up, the number increases. Thanks in advance.

Im not that great a coder, But maybe this will help.

- To show how many lives a person has, you could use S_Damage by Spuzzum, Just read the instructions and change whatever you need to. (S_Damage does not HAVE to be a Damage Counter, as it states , It can be used for anything else)

- To make a person gain another life when they find a 1UP, you can make the objects OneUp, and put a Bump() proc on it, inside that Bump() proc put something like usr << "You gained a life from the 1UP!" usr.Lives+=1

- To make a person lose a life when they suffer major damage, make a DeathCheck proc like so,
proc
DeathCheck()
if(src.DamageCounter>=100) // Put desired damage needed to lose a life where the 100 is.
src << "You lose a life!"
src.Lives-=1

- To check to see if the player has no lives left at all, make another proc called something like NoLives() and put it under src.Lives-=1 in the above snippet.
proc
NoLives()
if(src.Lives<=0)
world << "[src] has no more lives left!"
del(src)

- Notice the del(src), If a player dies, they are deleted from the game, and if they want to play again, they must rejoin.

I hope what I have told you helps you. :/. May someone like Lummox JR come in and correct me.
Well, if the player will never have more than 9 lives, the easiest method would be to simply use overlays. Make an icon with 10 states - numbers 1 through 9. You need to have a variable for the number of lives they have. When they get a 1UP object, simply add one to thatvariable. The icon_state of the overlay you want to add would be something like num2text(usr.lives) Make sure you remove overlays before adding new ones, too.