mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -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
|
while #history > 10 do
|
||||||
table.remove(history, 1)
|
table.remove(history, 1)
|
||||||
end
|
end
|
||||||
local statement, result = load(command, "=stdin", "t", env)
|
local code, reason
|
||||||
local expression = load("return " .. command, "=stdin", "t", env)
|
if string.sub(command, 1, 1) == "=" then
|
||||||
local code = expression or statement
|
code, reason = load("return " .. string.sub(command, 2), "=stdin", "t", env)
|
||||||
|
else
|
||||||
|
code, reason = load(command, "=stdin", "t", env)
|
||||||
|
end
|
||||||
if code then
|
if code then
|
||||||
local result = table.pack(pcall(code))
|
local result = table.pack(pcall(code))
|
||||||
if not result[1] then
|
if not result[1] then
|
||||||
@ -35,6 +38,6 @@ while term.isAvailable() do
|
|||||||
print(table.unpack(result, 2, result.n))
|
print(table.unpack(result, 2, result.n))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print(result)
|
print(reason)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user