Engine:CCMD varedit: Difference between revisions
Jump to navigation
Jump to search
Line 12: | Line 12: | ||
== Details == | == Details == | ||
Can be used to set or report a value for an existing variable. Will fail if variable does not already exist. | Can be used to set or report a value for an existing variable. Will fail if variable does not already exist. | ||
Line 19: | Line 18: | ||
* var - creates and sets only if not exist | * var - creates and sets only if not exist | ||
* set - creates and sets any time | * set - creates and sets any time | ||
While 'varedit' is intended make console variable checking and editing easy, in combination with the other variable commands, can allow scripts and other types of macros to avoid lots of situations where complex logic would otherwise be required. | |||
For example, this default command 'varedit' would allow writing a script that was intended to only set certain variables if another service or module had already created them. | |||
== Examples == | == Examples == |
Revision as of 03:27, 14 October 2023
Sets an existing variable in the current context, reports variable value.
bob fred
Associations
- Is the default command for the 'global' context.
- Does not have its own command name in 'global' for console or script.
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 or report a value for an existing variable. Will fail if variable does not already exist.
This command behaves like a combination of 'var' and 'set', but will never create a variable:
- varedit - never creates, sets anytime value exists
- var - creates and sets only if not exist
- set - creates and sets any time
While 'varedit' is intended make console variable checking and editing easy, in combination with the other variable commands, can allow scripts and other types of macros to avoid lots of situations where complex logic would otherwise be required.
For example, this default command 'varedit' would allow writing a script that was intended to only set certain variables if another service or module had already created them.
Examples
Default values
- 'bob' without a value. Variable 'bob' doesn't exist, and 'bob' is not the name of anything else.
> bob Unknown: bob
- Tries to set variable 'bob' to 'fred'. Fails as 'bob' does not exist.
> bob fred Unknown: bob
- Using the 'set' command to create the variable 'bob' and set to 'fred'.
> set bob fred
- Same as the first example, but now 'bob' exists.
> bob
'bob' is 'fred'
- Try to set existing 'bob' to 'james', value changes.
> bob james
> bob
'bob' is 'james'