getStrProp: Difference between revisions
Jump to navigation
Jump to search
m (Can't use "=" inside {{code}} blocks?) |
True Hitoare (talk | contribs) mNo edit summary |
||
Line 12: | Line 12: | ||
</source> | </source> | ||
'''Parameters''' | '''Parameters''' | ||
{{param|proplist|String list to extract data from.}} | {{param|proplist|String property list to extract data from.}} | ||
{{param|key|Key within string to extract.}} | {{param|key|Key within string to extract.}} | ||
{{param|default|Value returned if the key is not found.}} | {{param|default|Value returned if the key is not found.}} |
Revision as of 11:25, 27 November 2011
getStrProp() Function
• Introduced in version 1.3b42
Returns the value associated with a key from the specified string property list.
Usage
getStrProp(propList, key)
getStrProp(propList, key, default)
getStrProp(propList, key, default, delim)
Parameters
proplist
- String property list to extract data from.key
- Key within string to extract.default
- Value returned if the key is not found.delim
- Delimiter between fields (default is ";").
Example
To get the name from a weapon string property list
Returns
[h: weapon = "name=longsword; damage=1d8; maxdamage=8"]
Name of Weapon: [r: getStrProp(weapon, "name")]
Returns Name of Weapon: longsword
.
To get the minimum damage from a weapon string property list with a default value should the key not exist
[h: weapon = "name=longsword; damage=1d8; maxdamage=8"]
Minimum damage of Weapon: [r: getStrProp(weapon, "mindamage", 1)]
Returns Minimum damage of Weapon: 1
.
To get the damage from a weapon string property list where the field delimiter is a colon. The default is 1d3 (note that a default value must be provided in order to specify the delimiter).
[h: weapon = "name=longsword: damage=1d8: maxdamage=8"]
Damage of Weapon: [r: getStrProp(weapon, "damage", "1d3", ":")]
Damage of Weapon: 1d8
.
Version Changes
- 1.3b43 - Added the optional
error
parameter.