Engine:CCMD lua.run: Difference between revisions
Jump to navigation
Jump to search
Line 41: | Line 41: | ||
end | end | ||
` | ` | ||
return bob -- uses the 'lua' context 'lua_edit' default | return bob -- uses the 'lua' context 'lua_edit' default command which prints return values | ||
exit | exit | ||
</kua> | </kua> |
Revision as of 20:29, 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)
`
exit
- 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 prints return values
exit
- Prints 'james'.