Engine:Console commands: Difference between revisions

 
(88 intermediate revisions by the same user not shown)
Line 1: Line 1:
<!--{{macroapi}}-->
{{dev|macronav}}
This is a reference for Engine [[console commands]] available for use a [[chat window]] or other console, and as [[macro commands]] in a [[macro]].
This is a reference for Engine [[console commands]] available for use a [[chat window]] or other console, and as [[macro commands]] in a [[macro]].


This list describes all of the 'slash' commands from Engine itself, and not from any additional modules or [[AddOn]]s. These same commands are available in the base Engine scripting language.
This list describes all of the [[slash commands]], [[console commands]] and [[console variables]] from Engine itself, in one list for now. Does include not any from additional components or [[AddOn]]s. These same commands are available in the base Engine scripting language.


By default in the core or empty UI, the console can be entered during runtime by pressing the 'back tick' (`) and exited by pressing escape (Esc). If in a chat type box, commands can be run by starting with a forward slash before the command line, to separate them from actual chat.
== Notes ==
* By default, the console can be opened by pressing the 'back tick' (`) and exited by pressing escape (Esc).
* If in a chat type box, commands can be run by starting with a forward slash (/) before the command line, to separate them from actual chat.


 
=== Key ===
== Key ==
* Global command - Used below, is short-hand for commands placed in the 'global' context.
* 'Global commands' and 'Global variables' - below are short-hand for commands placed in the 'global' context.
* Global variable - Used below, is short-hand for variables placed in the 'global' context.
* 'Default command' - is run by default if its context is addressed by name or is the current context. Examples:
* Default command - Command run by default if no command or alias exists for that name in the current, or inherited, context. Examples:
** Will print 3. Where 'lua' is a child context and 'print' is a real Lua command, not an Engine script one. <pre>lua print(1 + 3)</pre>  
** <kua>var bob fred; bob</kua> Prints 'fred'. The 'var' command is used to create a new variable, then the next statement uses the 'global' default 'varedit' command to print the value of 'bob'. 'bob' is not a command but an existing variable.
** Will also print 3 and return to global. Where context is switched to, then the Lua command is run. <pre>context lua; print(1 + 3); exit</pre>
** <kua>bob james; bob</kua> Prints 'james'. In the first statement, the global default command 'varedit' finds the existing 'bob' variable in the 'global' context, and assigns 'james'. In the next statement, the default command finds and prints the value of variable 'bob'.  
** Will start the client module. <pre lang="lua">client start</pre>  
** <kua>lua print(1 + 3)</kua> Prints '3'. The 'lua' context is addressable from 'global'. The default command 'lua_edit' in the 'lua' context runs the lua statement in the Lua runtime, where the 'print' is a real Lua statement, not an Engine script one.
** Will start the client module and return to global. <pre>context client; start; context global</pre>
** <kua>context lua; print(1 + 3); exit</kua> Also prints '3'. Switches to the 'lua' context. Runs the same 'lua_edit' default command, with the bare statement in the Lua runtime. Switches back to 'global' with the 'exit' command, which is not run in Lua runtime as it exists as a command in the 'lua' context.
** Will print 'fred', using the 'global' default 'varedit' command. 'bob' is not a command but an existing variable. <pre lang="lua">var bob fred; bob</pre>
* Context - A script or command context. Each context may have its own commands and variables and rules. Examples:
** Will print 'james'. Where the default command finds the existing 'bob', and assigns 'james'. <pre lang="lua">bob james; bob</pre>
** <kua>client start</kua> Starts the client service. The 'client' context is addressable from 'global', and the client 'start' command is run.  
* Command - a script command
** <kua>context client; start; context global</kua> Also starts the client service. Switches to 'client'. Then runs the 'start' command from "inside" the 'client' context, then switches back to 'global'.
* Variable - a script variable
* Command - An engine module command, also referred to as a 'CCmd'.
* Alias - an alias or macro created using the global alias command
* Variable - An engine variable, similar to 'CVars' or config vars.
* Binding - key bindings to the keyboard or mouse buttons, or other real or virtual device things
* Alias - An alias or macro which is a string of script.
* Associations - Module or context associations and features
* Binding - key bindings to the keyboard or mouse buttons, or from other real or virtual devices.
* Service - here refers to messaging service. Which may be internal, local or through a network for send or receive.
* Associations - Module or context associations and features.
* Service - An engine messaging service. Which may be internal, local, or network for send or receive.  Some types of services offer commands that only exist while the service is running. 
* Script - May refer to the base Engine script language, which can contain elements here. Or to strings of commands for an alias, or integrated higher-level scripting like blended in-line engine script with lua, JS, or C#.
* Module - An independent static module built into the engine. Modules may create one or more command or script contexts, services or other things. If the module is not available, its commands, variables and contexts won't exist.
* Log - A text buffer that may or may not have an actual file log attached. The default console is composed of a 'log' and a basic text mode edit box.


== Reference ==
== Reference ==
Line 31: Line 37:


Global commands:
Global commands:
: [[MACRO varedit|varedit]] - (none), / - Prints or sets variable, if variable exists and name is not another command.
: [[CCMD varedit|varedit]] - (none), / - Sets an existing variable. If does not exist then fails.
: [[MACRO var|var]] - var, /var - Creates a variable. If already exists, then does not change value.
: [[CCMD var|var]] - var, /var - Creates a new variable only. If already exists, then does not change value.
: [[MACRO set|set]] - set, /set - Set an existing var. Updates a value on an existing variable if exists.
: [[CCMD set|set]] - set, /set - Creates or sets a variable. Works whether already exists or not.
: [[MACRO alias|alias]] - alias, /alias - New named script. Will change existing alias if already created.
: [[CCMD alias|alias]] - alias, /alias - New named script. Will change existing alias if already created.
: [[MACRO bind|bind]] - bind, /bind - Key to script.  Map a key to a script block.
: [[CCMD bind|bind]] - bind, /bind - Key to script.  Map a key to a script block.
: [[MACRO echo|echo]] - echo, /echo - Write text to log only. Print text to current console but not the file.
: [[CCMD echo|echo]] - echo, /echo - Write text to log only. Print text to current console but not the file.
: [[MACRO bind|print]] - print, /print - Write text to log and file. Print text to current console and to file.
: [[CCMD print|print]] - print, /print - Write text to log and file. Print text to current console and to file.
: [[MACRO bind|context]] - context, /context - Change context. Change current console context to another known context.
: [[CCMD context|context]] - context, /context - Change context. Change current console context to another known context.
: [[MACRO bind|run]] - run, /run - Load and run script file. Run a named script file. Name must include extension.
: [[CCMD run|run]] - run, /run - Load and run script file. Run a named script file. Name must include extension.


Global vars:
Global vars:
: [[CVAR lib_path|lib_path]] - './lib/' - Path for native 'world' modules.
: [[CVAR lib_path|lib_path]] - './lib/' - Path for native 'world' libraries.
: [[CVAR lib_path|base_path]] - './data/' - Path for content and assets.
: [[CVAR base_path|base_path]] - './data/' - Path for content and assets.
: [[CVAR lib_path|module]] - 'game' - Base name for 'world' module, without platform postfix.
: [[CVAR module|module]] - 'game' - Base name for 'world' module, without platform postfix.
: [[CVAR lib_path|GameDll]] - (none) - Full path for 'world' module, './lib/gamex86.dll'.
: [[CVAR GameDll|GameDll]] - (none) - Full path for 'world' module, './lib/gamex86.dll'.
: [[CVAR lib_path|s_use_ai]] - '1.0' - If world 'AI' processing is enabled.
: [[CVAR s_use_ai|s_use_ai]] - '1.0' - If world 'AI' processing is enabled.
: [[CVAR lib_path|map]] - 'maps/base1.bsp' - Full path for default content module.
: [[CVAR map|map]] - 'maps/base1.bsp' - Full path for default content module.
: [[CVAR lib_path|startup]] - (none) - Full path of initial startup script.
: [[CVAR startup|startup]] - (none) - Full path of initial startup script.


Assignments:
Assignments:
Line 72: Line 78:
Assignments:
Assignments:
: Explicit context name is 'lua' reachable through 'global'
: Explicit context name is 'lua' reachable through 'global'
: Inherits 'global' context
: Default reachable contexts: none. See 'exit' command
: Optional reachable contexts: none
: Default self-reference context: 'lua'
: Does not inherit 'global' context


Lua context commands:
Lua context commands:
: [[MACRO lua.lua_edit|lua_edit]] - (none), / - Runs a Lua command in the main Lua runtime as though were in a Lua console
: [[CCMD lua.lua_edit|lua_edit]] - (none), / - Runs a Lua command in the main Lua runtime as though were in a Lua console
: [[MACRO lua.run|run]] - lua run - Runs a Lua command in the Lua runtime.
: [[CCMD lua.run|run]] - lua run - Runs a Lua command in the Lua runtime.
: [[MACRO lua.block|block]] - lua run - Runs a Lua command block in the Lua runtime
: [[CCMD lua.block|block]] - lua run - Runs a Lua command block in the Lua runtime
: [[MACRO lua.exit|exit]] - lua exit - Immediately switches current context to 'global'
: [[CCMD lua.exit|exit]] - lua exit - Immediately switches current context to 'global'
 
Lua context variables:
: none


Lua context aliases:
Lua context aliases:
: none
: none
Lua functions placed in a Lua runtime by the lua context:
: [[CLUA script|script]] - Runs an engine script from the Lua runtime.
: [[CLUA require|require]] - Loads and runs lua text file asset from engine data.


=== Msg module ===
=== Msg module ===
Line 116: Line 132:


Global commands:
Global commands:
: [[MACRO quit|quit]] - quit, /quit - Exits engine immediately with graceful shutdown.
: [[CCMD quit|quit]] - quit, /quit - Exits engine immediately with graceful shutdown.


Global vars:
Global vars:
Line 131: Line 147:


Global commands:
Global commands:
: [[MACRO console|console]] - console, /console - Opens command console
: [[CCMD console|console]] - console, /console - Opens command console


Global vars:
Global vars:
Line 187: Line 203:


Client context commands:
Client context commands:
: [[MACRO client.start|start]] - client start - Starts the 'client' module.
: [[CCMD client.start|start]] - client start - Starts the 'client' module.
: [[MACRO client.stop|stop]] - client stop - Stops the 'client' module.
: [[CCMD client.stop|stop]] - client stop - Stops the 'client' module.


Client context aliases:
Client context aliases:
: [[MACRO client.lol|lol]] - client lol - 'print "client lol"' - Demo alias. Prints "client lol".
: [[CCMD client.lol|lol]] - client lol - 'print "client lol"' - Demo alias. Prints "client lol".