How to make 'look at self' change with health

I want to make it so the command 'look at self' prints something different depending on your current health
I can do it by using
if (Player.health = 100) {
msg ("You are in perfect health
best to keep it that way")
}
but that means I have to make 100 if statements for every tick of health, is there a way to do this more efficiently ?


Perhaps you add the reassurance, “You’ll do better next time,” or vow to use your experience to improve in the future. drift boss


How about something like:

if (game.pov.health >= 100) {
  msg ("You are in perfect health
best to keep it that way")
}
else if (game.pov.health > 80) {
  msg ("You got a few scratches, but nothing too serious.")
}
else if (game.pov.health > 50) {
  msg ("Everything hurts.")
}
else if (game.pov.health > 20) {
  msg ("You're battered and broken. Finding a doctor would be a really good idea.")
}
else {
  msg ("You're seriously injured. You should try to find an undertaker.")
}

(note: I used game.pov as the player because it's a good habit to get into, and means that anyone else who finds this post can use the code even if they renamed the player object. For this script, you could just as easily use this)


Log in to post a reply.

Support

Forums