Engine:CCMD lua.lua edit: Difference between revisions

 
(3 intermediate revisions by the same user not shown)
Line 37: Line 37:
run `print(1+2);print(1+2)`;exit
run `print(1+2);print(1+2)`;exit
</kua>
</kua>
Thus, when run directly in the context the first one works and the second one doesn't, third does:
And this fails because 'if', 'print', and 'end' are in separate script statements:
<kua>
<kua>
contexct lua
context lua
function bob(s) print(s) end
if bob then -- Lua errer!
bob("fred")
   print(1 + 2)
> fred
</kua>
<kua>
function bob(s)  -- Lua syntax error!!!
   print(s)
end
end
bob("james")
</kua>
</kua>
These work:
<kua>
<kua>
run `function bob(s)  -- Lua syntax error!!!
context lua
   print(s)
run `if bob then
   print(1 + 3)
end`
end`
bob("alan")
if bob then print(1 + 4) end
> alan
</kua>
</kua>