Navigation menu

Engine:CCMD lua.lua edit: Difference between revisions

Jump to navigation Jump to search
 
(11 intermediate revisions by the same user not shown)
Line 18: Line 18:


; Line by line processing:
; Line by line processing:
In the 'lua' context all of the script syntax rules still apply. The 'lua_edit' default command will only be run when a statement is not another context, or a command, variable, or alias. Script in the 'lua' context is still run statement by statement as script in the engine.  
The 'lua_edit' default command will only be run when a statement is not another context, or a command, variable, or alias. Script in the 'lua' context is still run statement by statement, as script in the engine.  


This means that for example:
For example:
<kua>
<kua>
context lua
context lua
print(1+2); exit
print(1+2); exit
</kua>
</kua>
Would be run as:
Is actually:
<kua>
<kua>
context lua
context lua
Line 32: Line 32:
exit      // script
exit      // script
</kua>
</kua>
 
This however would run ';' delimited statements in one Lua chunk, using the 'lua' context 'run' command. And then still run the script 'exit' command:
 
<kua>
 
context lua
run `print(1+2);print(1+2)`;exit
</kua>
And this fails because 'if', 'print', and 'end' are in separate script statements:
<kua>
context lua
if bob then -- Lua errer!
  print(1 + 2)
end
</kua>
These work:
<kua>
context lua
run `if bob then
  print(1 + 3)
end`
if bob then print(1 + 4) end
</kua>


; Outer return statement:
; Outer return statement:
Line 108: Line 125:
var bob fred
var bob fred
bob
bob
lua `
lua run `
   local s = script
   local s = script
   print(1 + 4)
   print(1 + 4)