Help with custom status attributes

WORM1993
28 Apr 2023, 20:50

I just want to display a status attribute that reads HP: currenthp / maxhp (HP: 100 / 100)

  1. I created an object type called playerstats.
  2. I added HP as a string attribute.
  3. I added currenthp and maxhp as integers.
  4. I had the player object inherit player stats.
  5. I have added the inherited HP to player status.
    I just can't figure out the next step. How do I make status window display what I want. Every attempt to edit the string attribute just displays what I've written.
    ""HP " +playerstats.currenthp+ "/" +players tats.maxhp+ ""

I am totally stumped and really am lacking the knowledge to proceed any further. Any help would really be appreciated.


Jennifer Wren
29 Apr 2023, 02:25

Nevermind


Jennifer Wren
29 Apr 2023, 02:27

Did you set a ! in the box at the top?


WORM1993
29 Apr 2023, 06:57

Hi Jennifer. Thanks for replying. Where does the ! Go?


mrangel
29 Apr 2023, 17:37

Status attributes display their value. If it's a string containing some text, that text will be displayed.

What you probably want to do is give your type two script attributes named changedcurrenthp and changedmaxhp. These would both contain a line like:

this.HP = this.currenthp + "/" + this.maxhp

Whenever currenthp is changed, the corresponding changescript runs automatically. In this case, it would set the HP attribute to a string like "95/100", which can be displayed using the statusattributes system.


Jennifer Wren
29 Apr 2023, 21:34

I just used ! as the variable in the status attribute box at the top of the object's attribute page.
This is the page I followed.
https://docs.textadventures.co.uk/quest/status_attributes.html