mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
lua.lua now behaves closer to vanilla Lua's interpreter, meaning entering an expression like 1+1
now gives an error, you'd have to write =1+1
to have the result of the expression returned and printed.
This commit is contained in:
parent
6a860927c6
commit
fa6dae03eb
@ -21,9 +21,12 @@ while term.isAvailable() do
|
||||
while #history > 10 do
|
||||
table.remove(history, 1)
|
||||
end
|
||||
local statement, result = load(command, "=stdin", "t", env)
|
||||
local expression = load("return " .. command, "=stdin", "t", env)
|
||||
local code = expression or statement
|
||||
local code, reason
|
||||
if string.sub(command, 1, 1) == "=" then
|
||||
code, reason = load("return " .. string.sub(command, 2), "=stdin", "t", env)
|
||||
else
|
||||
code, reason = load(command, "=stdin", "t", env)
|
||||
end
|
||||
if code then
|
||||
local result = table.pack(pcall(code))
|
||||
if not result[1] then
|
||||
@ -35,6 +38,6 @@ while term.isAvailable() do
|
||||
print(table.unpack(result, 2, result.n))
|
||||
end
|
||||
else
|
||||
print(result)
|
||||
print(reason)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user