Displaying Character Stats in Status window.

Hi,

I know I've been posting on the forum a lot lately but there is just so much I want to know how to do and when I search the forums, I can't find the answer I'm looking for. Or maybe I'm still too new at this to understand.

But anyways, the title really says it all.
I'm pretty sure there is a way to display the stuff from character creation on the status window when you play. I'm basically following the Character Creation Tutorial here:
http://docs.textadventures.co.uk/quest/character_creation.html, with some minor changes. I just don't understand how to display it because most of the tutorials or other forum posts have to do with numbers but I just want certain words.
Well, what I'm going for is something like this:

v Status
Name: player.alias
Class: player.class
Race: player.race
Age: player.age

I have been reading through these:

http://docs.textadventures.co.uk/quest/status_attributes.html
http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#p37375
http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk
https://textadventures.co.uk/forum/quest/topic/3888/displaying-attributes-in-the-status-bar
https://textadventures.co.uk/forum/quest/topic/336/variables-in-status-window

But I'm stumped.


here's a step by step guide creating a demo game via using the GUI/Editor (along with code example along with it) on how to use to use the 'status attributes':

http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375 (scroll past the stuff at the very top, as I was responding to some one's post, start at the 'conceptual' section of my post, just slightly down from the top of it)


(my link above goes into much more detail, this stuff below is just for quick usage)


the big trick is that since the 'status attributes' is merely the DISPLAYMENT of Attributes, you need three main things:

  1. the Attributes themselves (usually Integer Attributes for stats, as stats are usually amounts)
  2. a String Attribute for the 'status attributes' usage, as this enables both the desired TEXT (strings) and VARIABLES: amounts (Integer or Double Attributes) or (the other VARIABLE/Attribute/Value Types: Strings or Booleans, for your displayment via the 'status attributes' or other means
  3. a way of updating your stat displayment (your String Attributes), as the 'status attributes' does NOT do the updating for you: (A) using the special 'changed' Script Attribute, or (B) using the 'Turnscript' Element

for an example (in code):

using the special 'changed' Script Attribute for the stat updating

IMPORTANT: the '!' in the 'Value' for the 'status attributes' will display the current Value held by the Attribute

<object name="room">
  <inherit name="editor_room" />
</object>

<object name="player">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

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

  <attr name="default_maximum_life_integer_attribute" type="int">999</attr>
  <attr name="default_minimum_life_integer_attribute" type="int">0</attr>

  <attr name="age_integer_attribute" type="int">87</attr>

  <attr name="alias" type="string">Aragorn</attr>

  <attr name="race_string_attribute" type="string">human</attr>

  <attr name="class_string_attribute" type="string">ranger</attr>

  <attr name="condition_string_attribute" type="string">normal</attr>

  <attr name="life_string_attribute" type="string">500/500</attr>

  <attr name="current_life_integer_attribute" type="int">500</attr>
  <attr name="maximum_life_integer_attribute" type="int">500</attr>

  <attr name="changedcurrent_life_integer_attribute" type="script">

    <![CDATA[

      if (this.current_life_integer_attribute > this.maximum_life_integer_attribute) {
        this.current_life_integer_attribute = this.maximum_life_integer_attribute
      } else if (this.current_life_integer_attribute < this.default_minimum_life_integer_attribute) {
        this.current_life_integer_attribute = this.default_minimum_life_integer_attribute
      }

      if (this.current_life_integer_attribute = this.default_minimum_life_integer_attribute) {
        this.condition_string_attribute = "dead"
      }

      this.life_string_attribute = this.current_life_integer_attribute + "/" + this.maximum_life_integer_attribute

    ]]>

  </attr>

  <attr name="changedmaximum_life_integer_attribute" type="script">

    <![CDATA[

      if (this.maximum_life_integer_attribute > this.default_maximum_life_integer_attribute) {
        this.maximum_life_integer_attribute = this.default_maximum_life_integer_attribute
      }

      if (this.current_life_integer_attribute > this.maximum_life_integer_attribute) {
        this.current_life_integer_attribute = this.maximum_life_integer_attribute
      }

      this.life_string_attribute = this.current_life_integer_attribute + "/" + this.maximum_life_integer_attribute

    ]]>

  </attr>

  <attr name="changedcondition_string_attribute" type="script">

    switch (this.condition_string_attribute) {
      case ("normal") {
        // WHATEVER SCRIPTING
        msg ("NORMAL")
      }
      case ("dead") {
        // WHATEVER SCRIPTING
        msg ("DEAD")
      }
      case ("poisoned") {
        // WHATEVER SCRIPTING
        msg ("POISONED")
      }
      // etc 'cases' for conditions
    }

  </attr>

  <statusattributes type="stringdictionary">

    <item>

      <key>alias</key>
      <value>Name: !</value>

    </item>

    <item>

      <key>age_integer_attribute</key>
      <value>Age: !</value>

    </item>

    <item>

      <key>race_string_attribute</key>
      <value>Race: !</value>

    </item>

    <item>

      <key>class_string_attribute</key>
      <value>Class: !</value>

    </item>

    <item>

      <key>condition_string_attribute</key>
      <value>Condition: !</value>

    </item>

    <item>

      <key>life_string_attribute</key>
      <value>Life: !</value>

    </item>

  </statusattributes>

</object>

Here's how I display stats. This is in my game - start script.

player.alias = "you"
player.hitpoints = 110
player.max = 110
player.damage = 3
player.attack = 1
player.defence = 0
player.armour = 0
player.exp = 0
player.level = 0
player.attackers = NewObjectList()
player.ammo = 50
player.potion = 2
player.hyper_potion = 0
player.gold = 0
player.statusattributes = NewStringDictionary()
dictionary add (player.statusattributes, "hitpoints", "Hit points: !")
dictionary add (player.statusattributes, "equippedname", "Weapon: !")
dictionary add (player.statusattributes, "ammonote", "Ammo: !")
dictionary add (player.statusattributes, "potion", "Potions: !")
dictionary add (player.statusattributes, "hyper_potion", "Hyper Potions: !")
dictionary add (player.statusattributes, "ammo", "Spare ammo: !")
dictionary add (player.statusattributes, "reallevel", "Level: !")
dictionary add (player.statusattributes, "exp", "EXP: !")
Spade.damage = "2d5"
Spade.attack = 3
Spade.critdesc = "You smash the spade down on #target# (#hits# hits)."
Spade.attackdesc = "You swing the spade at #target# (#hits# hits)."
Spade.missdesc = "You swing wildly and entirely miss #target#."
Pistol.damage = 1
Pistol.attack = 0
Pistol.firearmdamage = "5d7"
Pistol.firearmattack = 3
Pistol.ammo = 7
Pistol.ammomax = 7
Pistol.critdesc = "A well placed shot with the pistol on #target# (#hits# hits)."
Pistol.attackdesc = "You shot the pistol at #target# (#hits# hits)."
Pistol.missdesc = "You shoot wildly and entirely miss #target#."
game.notarealturn = false
dictionary add (player.statusattributes, "gold", "Gold: !")
player.changedhitpoints => {
  if (player.hitpoints > 0) {
    msg ("Hits points now " + player.hitpoints)
  }
  else {
    msg ("You are dead!")
    DisplayHttpLink ("https://www.youtube.com/watch?v=isUFexdtNik", "https://www.youtube.com/watch?v=isUFexdtNik", true)
    MoveObject (player, Game Over1)
    options2 = Split("Undo2 (not recommended);Finish2;", ";")
    ShowMenu ("Please pick one.", options2, true) {
      switch (result) {
        case ("Undo2 (not recommended)") {
          Undo3
        }
        case ("Finish2") {
          Finish3
        }
      }
    }
  }
}
player.reallevel = 1
SMG.damage = 2
SMG.attack = 2
SMG.firearmdamage = "5d9"
SMG.firearmattack = 11
SMG.ammo = 7
SMG.ammomax = 7
SMG.critdesc = "You shoot a fiery, well placed shot with the SMG on #target# (#hits# hits)."
SMG.attackdesc = "You shot the SMG at #target# (#hits# hits)."
SMG.missdesc = "You shoot, but entirely miss #target#."
game.hard = false
game.ultrahard = false
game.spawn = false
game.spawncount = 0
game.count2 = 0
game.changedcount2 => {
  if (game.count2 = 4) {
    game.count2 = 0
  }
}
game.changedcount25 => {
  if (game.count2 = 0) {
    game.spawn = false
  }
}
game.changedcount23 => {
  if (game.count2 = 1) {
    game.spawn = false
  }
}
game.changedcount24 => {
  if (game.count2 = 2) {
    game.spawn = false
  }
}

You need something like this.

player.hitpoints = 50
player.statusattributes = NewStringDictionary()
dictionary add (player.statusattributes, "hitpoints", "Hit points: !")

Status attributes should do exactly what you want.

At the bottom of the "Player" tab of the game element, there is a list of status attributes.
In the first column you want to put the name of the attribute (for example alias). In the second column, you would put how you want that attribute to be displayed; for example Name: !. The exclamation mark will be replaced by the value of player.alias when it is displayed.

So for the 4 attributes mentioned in your first post, it would look something like this:
picture

Screenshot from the web version, but I think it's the same on desktop.


@ hegemonkhan,
@ jmnevil54
@mrangel

Oooh, Thank you, I got it to work!
I will probably need your help again for other things. So I'm sorry that I'm might be a bit annoying in the the future. I appreciate the help!


Another question,

I have 2 attributes:

player.hairstyle
player.haircolour

is there a way for it to show on the status window as something like:

"You have player.hairstyle + player.haircolour hair?"
I assume no. but I thought I ask to be sure.


(see mrangel's post's screenshot and match it up with this stuff below)
(you can rename my Attributes to whatever you want)

Object Name: player (or whatever you renamed it as)

Attribute Name: hair_description_string_attribute
Attribute Type: string
Attribute Value: (see below)

"You have " + player.hairstyle + " " + player.haircolour + " hair"
// "You[SPACE]have[SPACE]" + player.hairstyle + "[SPACE]" + player.haircolour + "[SPACE]hair"

// or:

"You have {player.hairstyle} {player.haircolour} hair"
// "You[SPACE]have[SPACE]{player.hairstyle}[SPACE]{player.haircolour}[SPACE]hair"

Status Attribute:

Key: hair_description_string_attribute
Value: !


umm. What could I be doing wrong or forgetting?

So, I think I set it up right?

Attribute Name: player_hair
Attribute Type: String
Attribute Value:
"You have " + player.hairstyle + " " + player.haircolour + " hair"

I don't know how to put the other code:
// "You[SPACE]have[SPACE]" + player.hairstyle + "[SPACE]" + player.haircolour + "[SPACE]hair"
Do I use "String list" for the type instead?

And the player tab is set up like this:

And when I run the game and put in the info, it looks like this:


Unfortunately, it doesn't work like that.

You need to run the command:

player.player_hair = "You have " + player.hairstyle + " " + player.haircolour + " hair"

after player.hairstyle and player.haircolour have both been set. The most common way to do this would be to put it after the code that sets those attributes.

If the player will have many ways to choose or change their hairstyle during the game, you might want to make it a changescript.

If you make a script attribute named changedhaircolour, it will be run whenever the haircolour attribute is changed. So you can put the line of code in there to change player.player_hair whenever player.haircolour is changed.


Also, the reason it comes up blank instead of just showing the text "You have " + player.hairstyle + " " + player.haircolour + " hair" is because you've created an attribute game.player_hair, and the status attributes function is looking for player.player_hair.


Oh I see.

I thought I have to set it up in the "attribute" tab but I just had to set it as another "set variable or attribute" in the scripting.
Ok I understand now.
Thank you.


(filler for getting my edited post, updated/posted)


my apologizes for not explaining:

I don't know how to put the other code:
// "You[SPACE]have[SPACE]" + player.hairstyle + "[SPACE]" + player.haircolour + "[SPACE]hair"
// or
// "You[SPACE]have[SPACE]{player.hairstyle}[SPACE]{player.haircolour}[SPACE]hair"

I just do these comment lines to show the spaces/white-spaces within it, as it can be hard to see them (for those with bad eyes, like myself)

the actual code line is this:

"You have " + player.hairstyle + " " + player.haircolour + " hair"
// or:
"You have {player.hairstyle} {player.haircolour} hair"


here's what mrangel is saying to do in his post


// set the Attributes themselves (in this case, your String Attributes for your hair style and hair color):

'player' Player Object -> 'Attributes' Tab -> Attributes (the box at the bottom) -> Add -> (see below, repeat as needed)

[Object Name: player]
Attribute Name: hairstyle
Attribute Type: string
Attribute Value: unknown

[Object Name: player]
Attribute Name: haircolour
Attribute Type: string
Attribute Value: unknown


// set a hair description String Attribute (for use by the 'status attributes' displayment or other means of displayment):

'player' Player Object -> 'Attributes' Tab -> Attributes (the box at the bottom) -> Add -> (see below)

[Object Name: player]
Attribute Name: hairdesc // using 'hairdesc' (short for hair description) as the name instead of your 'player_hair'
Attribute Type: string
Attribute Value: unknown


// set the special 'changed' Script Attributes (for updating the hair description String Attribute):

'player' Player Object -> 'Attributes' Tab -> Attributes (the box at the bottom) -> Add -> (see below, repeat as needed)

[Object Name: player]
Attribute Name: changedhairstyle
Attribute Type: script
Attribute Value: (see below)

add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable player.hairdesc = [EXPRESSION] "You have " + player.hairstyle + " " + player.haircolour + " hair"

[Object Name: player]
Attribute Name: changedhaircolour
Attribute Type: script
Attribute Value: (see below)

add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable player.hairdesc = [EXPRESSION] "You have " + player.hairstyle + " " + player.haircolour + " hair"


// set the built-in 'statusattributes' String Dictionary Attributes:

'player' Player Object -> 'Attributes' Tab -> Status Attributes (the box at the top --- I think) -> Add -> (see below)

[Object Name: player]
Attribute Name (Input / Key / Name): hairdesc
Attribute Value (Output / Value / Format-Field): !


you can then have your character creation system for actually inputting/selecting your String choices/Values for your 'player.hairstyle' and 'player.haircolour' String Attributes, which will replace my 'unknown' String Values for your 'player.hairstyle' and 'player.haircolour' String Attributes with the chosen/selected/inputted String Values from your character creation system

this (as we've changed the 'player.hairstyle' and 'player.haircolour' String Attribute's Values) causes the activation/running/execution of the special 'changed' Script Attributes, which will cause the update (re-setting) of the 'player.hairdesc' String Attribute's hair description String Value

and thus, the 'statusattributes' will now display this new/updated description string for your 'player.hairdesc' String Attribute


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

Support

Forums