Engine:CCMD lua.run: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{dev/uiccmd}} Runs a Lua statement in a Lua runtime. <kua>lua run 'print("fred")'</kua> == Arguments == * script - the verbatim text of the Lua statement or statements to be run == Associations == * Is by default placed in the 'lua' context. == Details == Runs the first argument as Lua code in a Lua runtime. == Examples == === Default values === <kua> lua run "print(1 + 2)" </kua> : Prints '3'. == Notes == *") |
|||
| (9 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{dev/uiccmd}} | {{dev/uiccmd}} | ||
Runs a Lua statement in a Lua runtime. | Runs a Lua statement in a Lua runtime. | ||
<kua>lua run | <kua>lua run `print("fred")`</kua> | ||
== Arguments == | == Arguments == | ||
| Line 10: | Line 10: | ||
== Details == | == Details == | ||
Runs the first argument as Lua code in a Lua runtime. | Runs the first argument as a single Lua code block in a Lua runtime. | ||
== Examples == | == Examples == | ||
=== Default values === | === Default values === | ||
<kua> | <kua> | ||
lua run | lua run `print(1 + 2)` | ||
</kua> | </kua> | ||
: Prints '3'. | : Prints '3'. | ||
<kua> | |||
context lua | |||
run `print(1 + 3)` | |||
run `print(1 + 4)` | |||
exit | |||
</kua> | |||
: Prints '4' and '5'. | |||
<kua> | |||
lua run ` | |||
print(1 + 5) | |||
print(1 + 6) | |||
` | |||
</kua> | |||
: Prints '6' and '7'. | |||
<kua> | |||
context lua | |||
run ` | |||
bob = 1 + 7 | |||
if bob > 4 then | |||
bob = "james" | |||
end | |||
` | |||
return bob -- uses the 'lua' context 'lua_edit' default command, which can print return values | |||
exit | |||
</kua> | |||
: Prints 'james'. | |||
== Notes == | == Notes == | ||
* | * | ||
Latest revision as of 20:32, 18 October 2023
Runs a Lua statement in a Lua runtime.
lua run `print("fred")`
Arguments
- script - the verbatim text of the Lua statement or statements to be run
Associations
- Is by default placed in the 'lua' context.
Details
Runs the first argument as a single Lua code block in a Lua runtime.
Examples
Default values
lua run `print(1 + 2)`
- Prints '3'.
context lua
run `print(1 + 3)`
run `print(1 + 4)`
exit
- Prints '4' and '5'.
lua run `
print(1 + 5)
print(1 + 6)
`
- Prints '6' and '7'.
context lua
run `
bob = 1 + 7
if bob > 4 then
bob = "james"
end
`
return bob -- uses the 'lua' context 'lua_edit' default command, which can print return values
exit
- Prints 'james'.