Engine:CCMD run: Difference between revisions

590 bytes added ,  16 October 2023
Line 39: Line 39:
</kua>
</kua>
: In this case: echos 'fred' to console, runs a Lua statement that adds '1 + 3' and prints the result, creates an alias 'bob', creates 'fred' variable that the alias 'bob' will show the value of, runs the 'bob' alias that effectively prints the value of 'fred' that is 'james'.
: In this case: echos 'fred' to console, runs a Lua statement that adds '1 + 3' and prints the result, creates an alias 'bob', creates 'fred' variable that the alias 'bob' will show the value of, runs the 'bob' alias that effectively prints the value of 'fred' that is 'james'.
=== Multiline strings ===
Strings in the base scripting language are intrinsically multiline.
For a script file named 'startup.cfg' and looks like:
<kua>
echo 'fred
bob'
alias bob "
    lua run '
        local a = 5
        print(a + 1 + 3)
    '
"
bob
</kua>
* Run the example script file.
<kua>
> run startup.cfg
fred
bob
9
</kua>
: Here the echo prints across two lines. An alias is created with an embedded block of lua that runs via the 'lua' context 'run' command, which uses single quotes to not conflict with the outer double quotes. Then bob is run and the whole thing prints 9.


== Script syntax ==
== Script syntax ==