Engine:CCMD var: Difference between revisions

From AddOn Studio
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 and sets a variable in the current context.
Creates a new variable in the current context, if doesn't exist. If exists is ignored.
<kua>set bob fred</kua>
<kua>var bob fred</kua>


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


== Examples ==
== Examples ==
=== Default values ===
=== Default values ===
* 'set' called with 'bob' without a value. Variable 'bob' doesn't exist.
* 'var' called with 'bob' without a value. Variable 'bob' doesn't exist.
<kua>
<kua>
> set bob
> var bob
Unknown: bob
Unknown: bob
</kua>
</kua>
* Creates variable 'bob' and sets to 'fred'.  
* Creates variable 'bob' and sets to 'fred'.  
<kua>
<kua>
> set bob fred
> 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 existing 'bob' to 'james', value changes.  
* 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 'james'
'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

Console commands

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.