Multiple values on 1 status line
duggold
10 Jun 2012, 15:48I am trying to display multiple status numbers on 1 line in the status panel. Example:
Health: 100%
Score: 100
Stats: Damage 1-4 + 2, Defense: 2, Offense: 5
I can't see a way to use a string or an expression when setting the statusattributes. It looks like each member of the dictionary can only use a single ! to represent 1 value. Anyway to use a string or an expression to display the info formatted as I want instead of making each status its own line in the pane?
I figured this out. Here is the code I used:
I coded it so if a description starts with an asterisks, it doesn't add a new line prior to adding it to the pane. In the example above, I show the basedamage and randdamage on the same line. Looks much nicer that way.
Health: 100%
Score: 100
Stats: Damage 1-4 + 2, Defense: 2, Offense: 5
I can't see a way to use a string or an expression when setting the statusattributes. It looks like each member of the dictionary can only use a single ! to represent 1 value. Anyway to use a string or an expression to display the info formatted as I want instead of making each status its own line in the pane?
I figured this out. Here is the code I used:
<game name="Hack and Slash">
<gameid>9bbe53c0-da1d-49f6-bed2-42f64d08cf3c</gameid>
<version>1.0</version>
<showscore type="boolean">false</showscore>
<showhealth type="boolean">false</showhealth>
<autodescription_youcansee type="int">3</autodescription_youcansee>
<autodescription_youcango type="int">4</autodescription_youcango>
<autodescription_description type="int">2</autodescription_description>
<hitpoints type="int">100</hitpoints>
<expneeded type="int">1000</expneeded>
<gold type="int">100</gold>
<level type="int">1</level>
<tohit type="int">0</tohit>
<basedamage type="int">1</basedamage>
<randomdamage type="int">3</randomdamage>
<defense type="int">0</defense>
<statusattributes type="stringdictionary">hitpoints = Hit Points: !;level = Current Level: !;expneeded = Experience needed for next level: !;gold = Gold: !;randomdamage = Damage: 1-!;basedamage = * +!</statusattributes>
<function name="AddStatusAttributesForElement" parameters="status, element" type="string">
<![CDATA[
if (element.statusattributes <> null) {
foreach (attr, element.statusattributes) {
z = FormatStatusAttribute(attr, GetAttribute(element, attr), StringDictionaryItem(element.statusattributes, attr))
if (LengthOf(status) > 0) {
if (Left(z,1) <> "*") {
status = status + "\n"
}
}
if (Left(z,1) = "*") {
z = Right(z,LengthOf(z) - 1)
}
status = status + z
}
}
return (status)
]]>
</function>
</game>
I coded it so if a description starts with an asterisks, it doesn't add a new line prior to adding it to the pane. In the example above, I show the basedamage and randdamage on the same line. Looks much nicer that way.