From 816ea366abc21ab1d65a57137fb25902a615034d Mon Sep 17 00:00:00 2001 From: Kan18 <24967425+Kan18@users.noreply.github.com> Date: Fri, 24 Jul 2020 20:41:21 -0400 Subject: [PATCH] TLCO fix & boot file extension change (#37) This commit fixes the TLCO boot option (which hasn't been working for a while now), and also changes boot file extensions from .boot to .lua. --- startup.lua | 21 ++++++++++++++++++--- sys/boot/{kiosk.boot => kiosk.lua} | 0 sys/boot/{opus.boot => opus.lua} | 0 sys/boot/tlco.boot | 15 --------------- sys/boot/tlco.lua | 30 ++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 18 deletions(-) rename sys/boot/{kiosk.boot => kiosk.lua} (100%) rename sys/boot/{opus.boot => opus.lua} (100%) delete mode 100644 sys/boot/tlco.boot create mode 100644 sys/boot/tlco.lua diff --git a/startup.lua b/startup.lua index f72fb21..c81a2c1 100644 --- a/startup.lua +++ b/startup.lua @@ -29,9 +29,10 @@ local function loadBootOptions() preload = { }, menu = { { prompt = os.version() }, - { prompt = 'Opus' , args = { '/sys/boot/opus.boot' } }, - { prompt = 'Opus Shell' , args = { '/sys/boot/opus.boot', 'sys/apps/shell.lua' } }, - { prompt = 'Opus Kiosk' , args = { '/sys/boot/kiosk.boot' } }, + { prompt = 'Opus' , args = { '/sys/boot/opus.lua' } }, + { prompt = 'Opus Shell' , args = { '/sys/boot/opus.lua', '/sys/apps/shell.lua' } }, + { prompt = 'Opus Kiosk' , args = { '/sys/boot/kiosk.lua' } }, + { prompt = 'Opus TLCO' , args = { '/sys/boot/tlco.lua' } }, }, })) f.close() @@ -41,6 +42,20 @@ local function loadBootOptions() local options = textutils.unserialize(f.readAll()) f.close() + -- Backwards compatibility for .startup.boot files created before sys/boot files' extensions were changed + local changed = false + for _, item in pairs(options.menu) do + if item.args and item.args[1]:match("/?sys/boot/%l+%.boot") then + item.args[1] = item.args[1]:gsub("%.boot", "%.lua") + changed = true + end + end + if changed then + local f = fs.open(".startup.boot", "w") + f.write(textutils.serialize(options)) + f.close() + end + return options end diff --git a/sys/boot/kiosk.boot b/sys/boot/kiosk.lua similarity index 100% rename from sys/boot/kiosk.boot rename to sys/boot/kiosk.lua diff --git a/sys/boot/opus.boot b/sys/boot/opus.lua similarity index 100% rename from sys/boot/opus.boot rename to sys/boot/opus.lua diff --git a/sys/boot/tlco.boot b/sys/boot/tlco.boot deleted file mode 100644 index 350e68f..0000000 --- a/sys/boot/tlco.boot +++ /dev/null @@ -1,15 +0,0 @@ -local pullEvent = os.pullEventRaw -local shutdown = os.shutdown - -os.pullEventRaw = function() - error('') -end - -os.shutdown = function() - os.pullEventRaw = pullEvent - os.shutdown = shutdown - - os.run(getfenv(1), 'sys/boot/opus.boot') -end - -os.queueEvent('modem_message') diff --git a/sys/boot/tlco.lua b/sys/boot/tlco.lua new file mode 100644 index 0000000..cbbba0c --- /dev/null +++ b/sys/boot/tlco.lua @@ -0,0 +1,30 @@ +local run = os.run +local shutdown = os.shutdown + +local args = {...} -- keep the args so that they can be passed to opus.lua + +os.run = function() + os.run = run +end + +os.shutdown = function() + os.shutdown = shutdown + + _ENV.multishell = nil -- prevent sys/apps/shell.lua erroring for odd reasons + + local success, err = pcall(function() + run(_ENV, 'sys/boot/opus.lua', table.unpack(args)) + end) + term.redirect(term.native()) + if success then + print("Opus OS abruptly stopped.") + else + printError("Opus OS errored.") + printError(err) + end + print("Press any key to continue.") + os.pullEvent("key") + shutdown() +end + +shell.exit() \ No newline at end of file