mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-12 00:35:56 -04:00
lua program can now be quit using 'exit()' function
This commit is contained in:
parent
b52cc44598
commit
60118f19cc
@ -1,13 +1,15 @@
|
||||
while term.isAvailable() do
|
||||
print("Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio")
|
||||
local running = true
|
||||
local env = setmetatable({exit=function() running = false end}, {__index=_ENV})
|
||||
while running and term.isAvailable() do
|
||||
io.write("lua> ")
|
||||
local command = io.read()
|
||||
if not command then
|
||||
return -- eof
|
||||
end
|
||||
|
||||
local code, result = load("return " .. command, "=stdin")
|
||||
local code, result = load("return " .. command, "=stdin", env)
|
||||
if not code then
|
||||
code, result = load(command, "=stdin") -- maybe it's a statement
|
||||
code, result = load(command, "=stdin", env) -- maybe it's a statement
|
||||
end
|
||||
if code then
|
||||
local result = table.pack(pcall(code))
|
||||
|
Loading…
x
Reference in New Issue
Block a user