Engine:CCMD var: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
Tag: Reverted
Line 1: Line 1:
{{dev/uiccmd}}
{{dev/uiccmd}}
Creates a new variable in the current context, if doesn't exist. If exists is ignored.
Creates and sets a variable in the current context.
<kua>var bob fred</kua>
<kua>set bob fred</kua>


== Arguments ==
== Arguments ==
* name - name for new variable
* name - name for variable to set
* 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 defaults for values.
Can be used to set values for variables. Will create a new variable is not exists.


== Examples ==
== Examples ==
=== Default values ===
=== Default values ===
* 'var' called with 'bob' without a value. Variable 'bob' doesn't exist.
* 'set' called with 'bob' without a value. Variable 'bob' doesn't exist.
<kua>
<kua>
> var bob
> set 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
> set 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 'bob' to 'james', but 'bob' is already set.  
* Try to set existing 'bob' to 'james', value changes.  
<kua>
<kua>
> var bob james
> var bob james
> var bob
> var bob
'bob' is 'fred'
'bob' is 'james'
</kua>
</kua>


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

Revision as of 00:32, 14 October 2023

Console commands

Creates and sets a variable in the current context.

set bob fred

Arguments

  • name - name for variable to set
  • value (optional) - the value to set. If no value, then prints value if exists.

Details

Can be used to set values for variables. Will create a new variable is not exists.

Examples

Default values

  • 'set' called with 'bob' without a value. Variable 'bob' doesn't exist.
> set bob
Unknown: bob
  • Creates variable 'bob' and sets to 'fred'.
> set bob fred
  • Same as the first example, but now bob exists.
> var bob
'bob' is 'fred'
  • Try to set existing 'bob' to 'james', value changes.
> var bob james
> var bob
'bob' is 'james'

Notes