hasLightSource: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function hasLightSource== {{ProposedChange}} Returns 1 if the current Token:token has any LightSource:light sources that match the criteria passed in or 0 if there are no match...)
 
No edit summary
Line 18: Line 18:


===Examples===
===Examples===
You can use the following code to print out the ids of all of the [[Token:token|token]]s on the current [[Map:map|map]] with the "Dead" [[Token:state| token state]] set.
Check to see if any light source is on.
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: names = getWithState()]
[h: l = hasLightSource()]
[foreach(name, names, "<br>"): name]
</source>
 
Check to see if a "D20" lamp is on.
<source lang="mtmacro" line>
[h: l = hasLightSource("D20", "Lamp - 15")]
</source>
 
Check to see if any "D20" light source is on.
<source lang="mtmacro" line>
[h: l = hasLightSource("D20")
</source>
</source>

Revision as of 00:11, 2 December 2008

Function hasLightSource

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

Returns 1 if the current token has any light sources that match the criteria passed in or 0 if there are no matches. If no arguments are passed to the function then it will return 1 if any light source is on. If only the first argument is passed it will return 1 if any light source of that light source type is on. If both arguments are passed to the function it will return 1 if the light source with the specified name and specified light source type is on.

Usage

[h: hasLight = hasLightSource()]
[h: hasLight = hasLightSource(type)]
[h: hasLight = hasLightSource(type, name)]

Where


If delim is specified then it is used to separate the values in the list, if it is not specified then it defaults to ','.

Examples

Check to see if any light source is on.

[h: l = hasLightSource()]

Check to see if a "D20" lamp is on.

[h: l = hasLightSource("D20", "Lamp - 15")]

Check to see if any "D20" light source is on.

[h: l = hasLightSource("D20")