setStrProp: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Fixed existing example and added a new one)
m (Added params and see also, explained examples.)
Line 3: Line 3:
|version=1.3b42
|version=1.3b42
|description=
|description=
Returns a [[Macros:string property list|string property list]] with the key set to the value passed in.  
Returns a [[String Property List]] with the key set to the value passed in.  


|usage=
|usage=
Line 9: Line 9:
setStrProp(propList, key, value)
setStrProp(propList, key, value)
</source>
</source>
'''Parameters'''
{{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|value|The value that the specified key will be set to.}}


|examples=
|examples=
Add a new key to an existing [[String Property List]]:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: weapon = "name=longsword; damage=1d8; maxdamage=8"]
[h: weapon = "name=longsword; damage=1d8; maxdamage=8"]
Line 16: Line 21:
[r: weapon]
[r: weapon]
</source>
</source>
Returns "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]]:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: weapon = "name=longsword; damage=1d8; maxdamage=8"]
[h: weapon = "name=longsword; damage=1d8; maxdamage=8"]
Line 23: Line 29:
[r: weapon]
[r: weapon]
</source>
</source>
Returns "name=longsword ; damage=1d6 ; maxdamage=8 ; "
Returns {{code|"name{{=}}longsword ; damage{{=}}1d6 ; maxdamage{{=}}8 ; "}}


|also=
{{func|getStrProp}}
}}
}}
[[Category:String Property List Function]]
[[Category:String Property List Function]]

Revision as of 03:44, 4 April 2009

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)

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.

Examples

Add a new key to an existing String Property List:
[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]
Returns "name=longsword ; damage=1d6 ; maxdamage=8 ; "

See Also