setStrProp: Difference between revisions
Jump to navigation
Jump to search
m (Conversion script moved page setStrProp to SetStrProp without leaving a redirect: Converting page title to first-letter uppercase) |
Full Bleed (talk | contribs) m (Added missing delimiter usage/parameter.) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 6: | Line 6: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
setStrProp(propList, key, value) | setStrProp(propList, key, value) | ||
</ | setStrProp(propList, key, value, delim) | ||
</syntaxhighlight> | |||
'''Parameters''' | '''Parameters''' | ||
{{param|propList|The [[String Property List]] affected by this function.}} | {{param|propList|The [[String Property List]] affected by this function.}} | ||
{{param|key|The key in the specified [[String Property List]] that will have its value set.}} | {{param|key|The key in the specified [[String Property List]] that will have its value set.}} | ||
{{param|value|The value that the specified key will be set to.}} | {{param|value|The value that the specified key will be set to.}} | ||
{{param|delim|Delimiter between fields (default is ";").}} | |||
|examples= | |examples= | ||
Add a new key to an existing [[String Property List]]: | Add a new key to an existing [[String Property List]]: | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: weapon = "name=longsword; damage=1d8; maxdamage=8"] | [h: weapon = "name=longsword; damage=1d8; maxdamage=8"] | ||
[h: weapon = setStrProp(weapon, "value", 10)] | [h: weapon = setStrProp(weapon, "value", 10)] | ||
[r: weapon] | [r: weapon] | ||
</ | </syntaxhighlight> | ||
Returns {{code|"name{{=}}longsword ; damage{{=}}1d8 ; maxdamage{{=}}8 ; value{{=}}10 ; "}} | Returns {{code|"name{{=}}longsword ; damage{{=}}1d8 ; maxdamage{{=}}8 ; value{{=}}10 ; "}} | ||
Change the value of a key in an existing [[String Property List]]: | Change the value of a key in an existing [[String Property List]]: | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: weapon = "name=longsword; damage=1d8; maxdamage=8"] | [h: weapon = "name=longsword; damage=1d8; maxdamage=8"] | ||
[h: weapon = setStrProp(weapon, "damage", "1d6")] | [h: weapon = setStrProp(weapon, "damage", "1d6")] | ||
[r: weapon] | [r: weapon] | ||
</ | </syntaxhighlight> | ||
Returns {{code|"name{{=}}longsword ; damage{{=}}1d6 ; maxdamage{{=}}8 ; "}} | Returns {{code|"name{{=}}longsword ; damage{{=}}1d6 ; maxdamage{{=}}8 ; "}} | ||
Latest revision as of 23:59, 14 November 2024
setStrProp() Function
• Introduced in version 1.3b42
Returns a String Property List with the key set to the value passed in.
Usage
setStrProp(propList, key, value)
setStrProp(propList, key, value, delim)
Parameters
propList
- The String Property List affected by this function.key
- The key in the specified String Property List that will have its value set.value
- The value that the specified key will be set to.delim
- Delimiter between fields (default is ";").
Examples
Add a new key to an existing String Property List:
Returns
[h: weapon = "name=longsword; damage=1d8; maxdamage=8"]
[h: weapon = setStrProp(weapon, "value", 10)]
[r: weapon]
Returns "name=longsword ; damage=1d8 ; maxdamage=8 ; value=10 ; "
Change the value of a key in an existing String Property List:
[h: weapon = "name=longsword; damage=1d8; maxdamage=8"]
[h: weapon = setStrProp(weapon, "damage", "1d6")]
[r: weapon]
"name=longsword ; damage=1d6 ; maxdamage=8 ; "