hasLightSource: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
 
(11 intermediate revisions by 7 users not shown)
Line 1: Line 1:
==Function hasLightSource==
{{MacroFunction
|name=hasLightSource
|version=1.3b48
|description=
Returns 1 if the [[Current Token]] has any [[Introduction to Lights and Sights|light source]]s 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 [[Introduction to Lights and Sights|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.


Returns 1 if the current [[Token:token|token]] has any [[LightSource:light source|light source]]s 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 [[LightSource:light source|light source]] is on. If only the first argument is passed it will return 1 if any [[LightSource:light source|light source]] of that [[LightSource:light source type|light source type]] is on. If both arguments are passed to the function it will return 1 if the [[LightSource:light source|light source]] with the specified name and specified [[LightSource:light source type|light source type]] is on.
|usage=
<syntaxhighlight lang="mtmacro" line>
hasLightSource()
hasLightSource(type)
hasLightSource(type, name)
hasLightSource(type, name, tokenRef)
hasLightSource(type, name, tokenRef, mapname)
</syntaxhighlight>


===Usage===
'''Parameters'''
<source lang="mtmacro" line>
{{param|type|The light source type, (e.g. "Generic", "D20"). If "*" is entered, all light sources types are checked. Defaults to "*".}}
[h: hasLight = hasLightSource()]
{{param|name|the name of the [[Introduction to Lights and Sights|light source]]. If "*" is entered, all light sources names are checked. Defaults to "*".}}
[h: hasLight = hasLightSource(type)]
{{param|tokenRef|Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of the token which is checked for light sources, defaults to the [[Current Token]]. {{TrustedParameter}} }}
[h: hasLight = hasLightSource(type, name)]
{{param|mapname|The name of the map to find the token.  Defaults to the current map.}}
</source>
{{Note|Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.}}
Where
* type is the [[LightSource:light source type|light source type]], (e.g. "Generic", "D20")
* name is the name of the [[LightSource:light source|light source]].


 
|examples=
 
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.
Check to see if any light source is on.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: l = hasLightSource()]
[h: l = hasLightSource()]
</source>
</syntaxhighlight>


Check to see if a "D20" lamp is on.
Check to see if a "D20" lamp is on.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: l = hasLightSource("D20", "Lamp - 15")]
[h: l = hasLightSource("D20", "Lamp - 15")]
</source>
</syntaxhighlight>


Check to see if any "D20" light source is on.
Check to see if any "D20" light source is on.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: l = hasLightSource("D20")
[h: l = hasLightSource("D20")
</source>
</syntaxhighlight>
 
|changes=
{{change|1.5.4|Added {{code|id}} and {{code|mapname}} parameter options. Changed behavior if {{code|type}} or {{code|name}} are set to "*".}}
 
}}
[[Category:Light Function]]

Latest revision as of 22:14, 16 May 2024

hasLightSource() Function

Introduced in version 1.3b48
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

hasLightSource()
hasLightSource(type)
hasLightSource(type, name)
hasLightSource(type, name, tokenRef)
hasLightSource(type, name, tokenRef, mapname)

Parameters

  • type - The light source type, (e.g. "Generic", "D20"). If "*" is entered, all light sources types are checked. Defaults to "*".
  • name - the name of the light source. If "*" is entered, all light sources names are checked. Defaults to "*".
  • tokenRef - Either the token id or Token Name of the token which is checked for light sources, defaults to the Current Token.

     Note: This parameter can only be used in a Trusted Macro

  • mapname - The name of the map to find the token. Defaults to the current map.
Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.

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")

Version Changes

  • 1.5.4 - Added id and mapname parameter options. Changed behavior if type or name are set to "*".