getVariable – Talk
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "<dl class="command_description"> <dd class="notedate">" to "<dl class="command_description"> <dt></dt> <dd class="notedate">") |
Lou Montana (talk | contribs) m (Text replacement - "Killzone Kid" to "Killzone_Kid") |
||
(2 intermediate revisions by the same user not shown) | |||
Line 17: | Line 17: | ||
== misleading comment == | == misleading comment == | ||
<dl class="command_description"> | <dl class="command_description"> | ||
<dt></dt> | <dt></dt> | ||
Line 25: | Line 24: | ||
'''defaultValue''' is processed even if the default isn't used. | '''defaultValue''' is processed even if the default isn't used. | ||
<code>[[player]] '''getVariable''' ["yolo",call {[[hint]] "!"; [[true]]}];</code> | <code style="display: block">[[player]] '''getVariable''' ["yolo",call {[[hint]] "!"; [[true]]}];</code> | ||
The [[hint]] will '''always''' print, even if the "yolo" variable exists. | The [[hint]] will '''always''' print, even if the "yolo" variable exists. | ||
</dd> | </dd> | ||
</dl> | </dl> | ||
The comment is valid but misleading, so I moved it here. It is not true that the default value will be processed even if the variable is defined. It will be processed before when code is compiling, in order to obtain default value. It is simple array, and like with every array, if you put expression into it it will be executed in order to obtain the value. | The comment is valid but misleading, so I moved it here. It is not true that the default value will be processed even if the variable is defined. It will be processed before when code is compiling, in order to obtain default value. It is simple array, and like with every array, if you put expression into it it will be executed in order to obtain the value. | ||
<code>_arr = [1,2,3,4,5,6,7,8,9, call {hint "OMG11!!!! 10th element must be magical!!1!!!"}];</code> [[User: | <code style="display: block">_arr = [1,2,3,4,5,6,7,8,9, call {hint "OMG11!!!! 10th element must be magical!!1!!!"}];</code> [[User:Killzone_Kid|Killzone_Kid]] ([[User talk:Killzone_Kid|talk]]) 23:37, 17 May 2015 (CEST) |
Latest revision as of 13:48, 12 March 2024
Only way I found to see if variable had even been assigned:
if (format ["%1", _obj getVariable "myVar"] == "<NULL>") then { // initialize it };
--Doolittle 06:14, 11 January 2008 (CET)
This also works:
_check = _obj getVariable "myVar"; if (isNil "_check") then { // initialize it };
--raedor 10:47, 12 January 2008 (CET)
misleading comment
- Posted on May 17, 2015 - 20:42 (UTC)
- Waffle SS.
-
defaultValue is processed even if the default isn't used.
player getVariable ["yolo",call {hint "!"; true}];
The hint will always print, even if the "yolo" variable exists.
The comment is valid but misleading, so I moved it here. It is not true that the default value will be processed even if the variable is defined. It will be processed before when code is compiling, in order to obtain default value. It is simple array, and like with every array, if you put expression into it it will be executed in order to obtain the value.
_arr = [1,2,3,4,5,6,7,8,9, call {hint "OMG11!!!! 10th element must be magical!!1!!!"}];
Killzone_Kid (talk) 23:37, 17 May 2015 (CEST)