Best way to make a script show live health

I am currently making a game that at some point you can fall off a tree the script says that you fall and takes 50% of your health, one problem for me is that it is not stated in the text. it there anyway i can have the text say the current amount of health the player has?


(filler for getting this edited post updated/posted)


in code, as scripting (needs to be within an Element that can contain scripting: Verb/Object's Script Attribute, Function, Command, Turnscript, Timer):

msg ("Player Current Health: " + player.health)

// or using the text processor commands:

msg ("Player Current Health: {player.health}")

in the GUI/Editor:

run as script -> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "Player Current Health: " + player.health

// or:

print [EXPRESSION] "Player Current Health: {player.health}"

// or (this might cause an error... but I think it'll work... but again, might not):

print [MESSAGE] Player Current Health: {player.health}


the '[MESSAGE]' script option allows for ONLY text/string (with the possible exception of the text processor commands: {xxx}, but, again this might not work, might cause an error).

the ['EXPRESSION]' allows for direct scripting, so you can do any of these:

  1. text/string ONLY
  2. VARIABLE ONLY
  3. text/string AND VARIABLE

Thanks! That did the trick, now when you fall it says that you falled followed by Your health is now (Whatever it might be.)


ya, you can re-arrange how you want it to be, for an example (out of infinite, lol):

(example in code, as I'm lazy... hopefully you can figure out how to do it via the GUI/Editor's 'print a message' Script)

// player.health = 75

msg ("Player Current Health: " + player.health)
msg ("Player Current Health: {player.health}")
// output: Player Current Health: 75

msg (player.health + " Player Current Health")
msg ("{player.health} Player Current Health")
// output: 75 Player Current Health

msg ("Your current health is " + player.health + ", make sure you stay healthy!")
msg ("Your current health is {player.health}, make sure you stay healthy!")
// output: Your current health is 75, make sure you stay healthy!

// some more fancy examples (using custom Attributes too: yours that you created-added):

player.alias = "HK" // this is the only built-in Attribute of these here, all the others below are custom Attributes (well maybe 'sex' is a built-in Attribute: I hope not, as I've ben using it as a custom Attribute, lol)
player.sex = "male"
player.age_integer = 18 // I wish I was still 18... lol
player.age_string = "adult"
player.race = "human"
player.class = "warrior"

msg (player.alias + " is a " + player.age_integer + " year old (" + player.age_string + ") " + player.sex + " " + player.race + " " + player.class + ".")
msg ("{player.alias} is a {player.age_integer} year old ({player.age_string}) {player.sex} {player.race} {player.class}.")
// output: HK is a 18 year old (adult) male human warrior. 

if you're interested, you can try looking at this guide of mine on Attribute and the 'if' Script usage:

https://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk

if you're interested in trying to understand it, and need help, let me know, and I'll try to help you better with trying to understand it (I'm not the best at explaining... usually just make people more confused, laughs --- at my own incompetance, not at the person not getting the needed/wanted help from me of course)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums