Engine:CCMD var: Difference between revisions

482 bytes added ,  16 October 2023
no edit summary
No edit summary
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 5: Line 5:
== Arguments ==
== Arguments ==
* name - name for new 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 ==
Can be used to set defaults for values.


== Examples ==
== Examples ==
=== Default values ===
* 'var' called with 'bob' without a value. Variable 'bob' doesn't exist.
<kua>
<kua>
:var bob
> var bob
Unknown: bob
Unknown: bob
:var bob fred
</kua>
:var bob
* Creates variable 'bob' and sets to 'fred'.
<kua>
> var bob fred
</kua>
* Same as the first example, but now bob exists. 
<kua>
> var bob
'bob' is 'fred'
</kua>
* Try to set 'bob' to 'james', but 'bob' is already set.
<kua>
> var bob james
> var bob
'bob' is 'fred'
'bob' is 'fred'
</kua>
</kua>


== Notes ==
== Notes ==
*
* If variable already exists, will not trigger any associated events when attempting to set.