Engine:CCMD lua.lua edit: Difference between revisions

Line 17: Line 17:
While the 'lua' context has the ability to hold variables and aliases, they cannot be created from script as the 'lua' context has no 'alias', 'set' or 'var' type script commands added to the context.
While the 'lua' context has the ability to hold variables and aliases, they cannot be created from script as the 'lua' context has no 'alias', 'set' or 'var' type script commands added to the context.


Outer return statement:
If the outer scope of the Lua code calls return, the return values will be printed. For example: <kua>
If the outer scope of the Lua code calls return, the return values will be printed. For example: <kua>
context lua
context lua
a = 1
a = 1
return a
return a
</kua> Will write '1' to the engine log/console.
return 100 + 1000
</kua> Will write '1' and '1100' to the engine log/console.
 
This is similar to an interactive Lua console's '=' convenience command: <pre> = 100 </pre> In a Lua will output '100' in the console, after the command is run. Except here anytime return is used on the outer Lua chunk, values will be read and written to the 'log', and there is no special command here.


== Examples ==
== Examples ==