diff --git a/sys/apis/opus.lua b/sys/apis/opus.lua new file mode 100644 index 0000000..11d0baa --- /dev/null +++ b/sys/apis/opus.lua @@ -0,0 +1,38 @@ +local Opus = { } + +local function runDir(directory, desc, open) + if not fs.exists(directory) then + return true + end + + local success = true + local files = fs.list(directory) + table.sort(files) + + for _,file in ipairs(files) do + print(desc .. file) + os.sleep(0) + local result, err = open(directory .. '/' .. file) + if not result then + printError(err) + success = false + end + end + + return success +end + +function Opus.loadExtensions() + return runDir('sys/extensions', '[ ext ] ', shell.run) +end + +function Opus.loadServices() + return runDir('sys/services', '[ svc ] ', shell.openHiddenTab) +end + +function Opus.autorun() + local s = runDir('sys/autorun', '[ aut ] ', shell.run) + return runDir('usr/autorun', '[ aut ] ', shell.run) and s +end + +return Opus diff --git a/sys/apps/Lua.lua b/sys/apps/Lua.lua index 3f189e2..5078afe 100644 --- a/sys/apps/Lua.lua +++ b/sys/apps/Lua.lua @@ -1,4 +1,4 @@ -local injector = requireInjector or load(http.get('http://pastebin.com/raw/c0TWsScv').readAll())() +local injector = requireInjector or load(http.get('https://raw.githubusercontent.com/kepler155c/opus/master/sys/apis/injector.lua').readAll())() injector(getfenv(1)) local Event = require('event') diff --git a/sys/apps/builder.lua b/sys/apps/builder.lua index 078650c..c43cbff 100644 --- a/sys/apps/builder.lua +++ b/sys/apps/builder.lua @@ -20,6 +20,11 @@ if Util.getVersion() == 1.8 then ChestProvider = require('chestProvider18') end +if not turtle.point then + local Opus = require('opus') + Opus.loadExtensions() +end + local BUILDER_DIR = 'usr/builder' local schematic = Schematic() @@ -2034,6 +2039,7 @@ function startPage:eventHandler(event) Builder:build() elseif event.type == 'quit' then + UI.term:reset() Event.exitPullEvents() end diff --git a/sys/apps/multishell b/sys/apps/multishell index 4f80573..43f5d99 100644 --- a/sys/apps/multishell +++ b/sys/apps/multishell @@ -22,6 +22,7 @@ end requireInjector(getfenv(1)) local Config = require('config') +local Opus = require('opus') local Util = require('util') -- Begin multishell @@ -462,27 +463,10 @@ end) local function startup() local hasError - local function runDir(directory, desc, open) - if not fs.exists(directory) then - return - end - - local files = fs.list(directory) - table.sort(files) - - for _,file in ipairs(files) do - print(desc .. file) - os.sleep(0) - local result, err = open(directory .. '/' .. file) - if not result then - printError(err) - hasError = true - end - end + if not Opus.loadExtensions() then + hasError = true end - runDir('sys/extensions', '[ ext ] ', shell.run) - local overviewId = multishell.openTab({ path = 'sys/apps/Overview.lua', focused = true, @@ -491,9 +475,13 @@ local function startup() }) overviewTab = tabs[overviewId] - runDir('sys/services', '[ svc ] ', shell.openHiddenTab) - runDir('sys/autorun', '[ aut ] ', shell.run) - runDir('usr/autorun', '[ aut ] ', shell.run) + if not Opus.loadServices() then + hasError = true + end + + if not Opus.autorun() then + hasError = true + end if hasError then error('An autorun program has errored') diff --git a/sys/extensions/clipboard.lua b/sys/extensions/clipboard.lua index 6720276..c63c509 100644 --- a/sys/extensions/clipboard.lua +++ b/sys/extensions/clipboard.lua @@ -1,3 +1,7 @@ +if _G.clipboard then + return +end + requireInjector(getfenv(1)) local Util = require('util') @@ -32,6 +36,8 @@ function clipboard.useInternal(mode) end end -multishell.addHotkey(20, function() - clipboard.useInternal(not clipboard.isInternal()) -end) +if multishell and multishell.addHotkey then + multishell.addHotkey(20, function() + clipboard.useInternal(not clipboard.isInternal()) + end) +end diff --git a/sys/extensions/device.lua b/sys/extensions/device.lua index 06e8e75..0b1eee3 100644 --- a/sys/extensions/device.lua +++ b/sys/extensions/device.lua @@ -1,3 +1,7 @@ +if _G.device then + return +end + requireInjector(getfenv(1)) local Peripheral = require('peripheral') diff --git a/sys/extensions/pathfind.lua b/sys/extensions/pathfind.lua index ef96342..bb0f3e4 100644 --- a/sys/extensions/pathfind.lua +++ b/sys/extensions/pathfind.lua @@ -1,4 +1,4 @@ -if not turtle then +if not turtle or turtle.pathfind then return end diff --git a/sys/extensions/scheduler.lua b/sys/extensions/scheduler.lua index 6a0a4a7..6669228 100644 --- a/sys/extensions/scheduler.lua +++ b/sys/extensions/scheduler.lua @@ -1,4 +1,4 @@ -if not turtle then +if not turtle or turtle.abortAction then return end diff --git a/sys/extensions/tgps.lua b/sys/extensions/tgps.lua index fec95e9..f257236 100644 --- a/sys/extensions/tgps.lua +++ b/sys/extensions/tgps.lua @@ -1,4 +1,4 @@ -if not turtle then +if not turtle or turtle.enableGPS then return end diff --git a/sys/extensions/tl3.lua b/sys/extensions/tl3.lua index 09ff41f..9166384 100644 --- a/sys/extensions/tl3.lua +++ b/sys/extensions/tl3.lua @@ -1,4 +1,4 @@ -if not turtle then +if not turtle or turtle.getPoint then return end