Engine:CCMD var: Difference between revisions
Jump to navigation
Jump to search
No edit summary Tag: Reverted |
No edit summary Tag: Manual revert |
||
Line 1: | Line 1: | ||
{{dev/uiccmd}} | {{dev/uiccmd}} | ||
Creates | Creates a new variable in the current context, if doesn't exist. If exists is ignored. | ||
<kua> | <kua>var bob fred</kua> | ||
== Arguments == | == Arguments == | ||
* name - name for variable | * name - name for new variable | ||
* value (optional) - the value to set. If no value, then prints value if exists | * value (optional) - the value to set. If no value, then prints value if exists | ||
== Details == | == Details == | ||
Can be used to set values | Can be used to set defaults for values. | ||
== Examples == | == Examples == | ||
=== Default values === | === Default values === | ||
* ' | * 'var' called with 'bob' without a value. Variable 'bob' doesn't exist. | ||
<kua> | <kua> | ||
> | > var bob | ||
Unknown: bob | Unknown: bob | ||
</kua> | </kua> | ||
* Creates variable 'bob' and sets to 'fred'. | * Creates variable 'bob' and sets to 'fred'. | ||
<kua> | <kua> | ||
> | > var bob fred | ||
</kua> | </kua> | ||
* Same as the first example, but now bob exists. | * Same as the first example, but now bob exists. | ||
Line 26: | Line 26: | ||
'bob' is 'fred' | 'bob' is 'fred' | ||
</kua> | </kua> | ||
* Try to set | * Try to set 'bob' to 'james', but 'bob' is already set. | ||
<kua> | <kua> | ||
> var bob james | > var bob james | ||
> var bob | > var bob | ||
'bob' is ' | 'bob' is 'fred' | ||
</kua> | </kua> | ||
== Notes == | == Notes == | ||
* | * If variable already exists, will not trigger any associated events when attempting to set. |
Revision as of 00:34, 14 October 2023
Creates a new variable in the current context, if doesn't exist. If exists is ignored.
var bob fred
Arguments
- name - name for new variable
- value (optional) - the value to set. If no value, then prints value if exists
Details
Can be used to set defaults for values.
Examples
Default values
- 'var' called with 'bob' without a value. Variable 'bob' doesn't exist.
> var bob Unknown: bob
- Creates variable 'bob' and sets to 'fred'.
> var bob fred
- Same as the first example, but now bob exists.
> var bob
'bob' is 'fred'
- Try to set 'bob' to 'james', but 'bob' is already set.
> var bob james
> var bob
'bob' is 'fred'
Notes
- If variable already exists, will not trigger any associated events when attempting to set.