findToken: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function encode== {{ProposedChange}} Encodes a string that was can be decoded with the decode() function. The decode() and encod...)
 
No edit summary
Line 1: Line 1:
==Function encode==
==Function encode==
{{ProposedChange}}
{{ProposedChange}}
{{TrustedOnlyFunction}}


 
Finds a token on the current map by the token name or GM name and returns its id. If the token is not found then an empty string "" is returned.
Encodes a string that was can be decoded with the [[Macros:Function:decode|decode()]] function. The [[Macros:Function:decode | decode()]] and encode() functions can be used to encode a property list so that it can be embedded within another property list.




===Usage===
===Usage===
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: str = encode(string)]
[h: id = findToken(name)]
</source>
</source>


===Examples===
===Examples===
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: innerPropList = encode("val1=blah;val2=blahblah")]
[h: id = findToken("Hero")]
[h: props = setStrProp(props, key, innerPropList)]
[if (id == "", "Token not found!", "Token found")]
</source>
</source>

Revision as of 06:28, 1 December 2008

Function encode

 Note: This refers to a proposed change that has not been implemented in the main code base yet.

This function can only be called from a trusted macro

Finds a token on the current map by the token name or GM name and returns its id. If the token is not found then an empty string "" is returned.


Usage

[h: id = findToken(name)]

Examples

[h: id = findToken("Hero")]
[if (id == "", "Token not found!", "Token found")]