Two Variable in a Status Attribute?

Okay, so, I have an idea I want to execute on, but I can't wrap my head around how. For my game, I'm looking to have both a player's current health and their maximum health fluctuate throughout the game. Changing these values is fairly simple. What is complex, however, is getting them to appear in the same status attribute. For example, I want a status attribute that looks something like this:

Health: 100/100

Where both numbers are editable. So far, I can only seem to figure out how to get one editable attribute per line in the status menu. Does anyone know how to get two attributes within a single status attribute?

if you haven't (and you can do so), download the desktop/offline version of quest

as here's a step by step walkthrough guide, creating your own "testable/playable game" on the basics of Attribute usage (including status attributes, including on exactly what you're asking about in your topic/post/thread here):

if you need help with anything, let me know!

the trick (see my link above) is to create a string attribute for your 'min/max' displayment for your statusattribute, and then you got to adjust/update that string attribute as your min/max values change, which you can do via the special 'changed' Script Attributes or the 'Turnscript/Timer' Elements

The trick is to use a third attribute that is a string and has both.

player.healthstring = player.currenthealth + "/" + player.maxhealth

Then you only need to display that.

Of course, you then need to update player.healthstring when either of the other two change, and the slick way to do that is with a change script:

I had a hunch that it revolved around proper use of Strings, but I hadn't quite worked out on my own just how to go about it. I'll look over your suggestions, and thank you for the prompt response and advice.

for the statusattribute item, I think you can probably leave it's Value blank, but I like putting in the special '!' character/symbol, as it gets the Attribute's Value, just to be on the same side, and it can be used with concatenation too.

for example:

<object name="room">

<object name="player">

  <attr name="parent" type="object">room</attr>

  <attr name="life_string_attribute" type="string">999/999</attr> // the putting in of a Value ("999/999") is for having an initial displayment of your life, as the design, doesn't update the statusattribute item until a min/max life integer attribute Value changes, and thus the statusattribute item would have a blank for its Value initially otherwise. Since this is an example, I can have it initially set to a Value that matches the Value I'm also able to give/set to the min/max life integer attributes. Dynamic (such as through a character creation determining starting/initial life and other stats), would require different/more coding to handle it, compared to this static example.

  <attr name="current_life_integer_attribute" type="int">999</attr>

  <attr name="changedcurrent_life_integer_attribute" type="script">
      if (player.current_life_integer_attribute < 1) {
        msg ("You are dead or were killed.")
        msg ("GAME OVER")
      } else if (player.current_life_integer_attribute > player.maximum_life_integer_attribute) {
        player.current_life_integer_attribute = player.maximum_life_integer_attribute
      player.life_string_attribute = player.current_life_integer_attribute + "/" + player.maximum_life_integer_attribute

  <attr name="maximum_life_integer_attribute" type="int">999</attr>

  <attr name="changedmaximum_life_integer_attribute" type="script">
      if (player.current_life_integer_attribute > player.maximum_life_integer_attribute) {
        player.current_life_integer_attribute = player.maximum_life_integer_attribute
      player.life_string_attribute = player.current_life_integer_attribute + "/" + player.maximum_life_integer_attribute

  <attr name="statusattributes" type="simplestringdictionary">life_string_attribute = Life: !; current_life_integer_attribute = Current Life Integer Attribute: !; maximum_life_integer_attribute = Maximum Life Integer Attribute: !</attr> // I just added the min/max life integer attributes, so you can see them too, for this example. You do NOT want to have them as statusattribute items for your game obviously.

  // or, if you prefer this (999/999 Life) look/design better:
  <attr name="statusattributes" type="simplestringdictionary">life_string_attribute = ! Life</attr>


Thank you very much hegemonkhan, just tested it out and it works exactly as I needed it to.

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