1
0
mirror of https://github.com/kepler155c/opus synced 2025-01-24 06:06:54 +00:00

web run applications

This commit is contained in:
kepler155c@gmail.com 2017-09-05 21:21:43 -04:00
parent f7a03b2eea
commit 9f5c58cc4c
10 changed files with 72 additions and 30 deletions

38
sys/apis/opus.lua Normal file
View File

@ -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

View File

@ -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)) injector(getfenv(1))
local Event = require('event') local Event = require('event')

View File

@ -20,6 +20,11 @@ if Util.getVersion() == 1.8 then
ChestProvider = require('chestProvider18') ChestProvider = require('chestProvider18')
end end
if not turtle.point then
local Opus = require('opus')
Opus.loadExtensions()
end
local BUILDER_DIR = 'usr/builder' local BUILDER_DIR = 'usr/builder'
local schematic = Schematic() local schematic = Schematic()
@ -2034,6 +2039,7 @@ function startPage:eventHandler(event)
Builder:build() Builder:build()
elseif event.type == 'quit' then elseif event.type == 'quit' then
UI.term:reset()
Event.exitPullEvents() Event.exitPullEvents()
end end

View File

@ -22,6 +22,7 @@ end
requireInjector(getfenv(1)) requireInjector(getfenv(1))
local Config = require('config') local Config = require('config')
local Opus = require('opus')
local Util = require('util') local Util = require('util')
-- Begin multishell -- Begin multishell
@ -462,27 +463,10 @@ end)
local function startup() local function startup()
local hasError local hasError
local function runDir(directory, desc, open) if not Opus.loadExtensions() then
if not fs.exists(directory) then hasError = true
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
end end
runDir('sys/extensions', '[ ext ] ', shell.run)
local overviewId = multishell.openTab({ local overviewId = multishell.openTab({
path = 'sys/apps/Overview.lua', path = 'sys/apps/Overview.lua',
focused = true, focused = true,
@ -491,9 +475,13 @@ local function startup()
}) })
overviewTab = tabs[overviewId] overviewTab = tabs[overviewId]
runDir('sys/services', '[ svc ] ', shell.openHiddenTab) if not Opus.loadServices() then
runDir('sys/autorun', '[ aut ] ', shell.run) hasError = true
runDir('usr/autorun', '[ aut ] ', shell.run) end
if not Opus.autorun() then
hasError = true
end
if hasError then if hasError then
error('An autorun program has errored') error('An autorun program has errored')

View File

@ -1,3 +1,7 @@
if _G.clipboard then
return
end
requireInjector(getfenv(1)) requireInjector(getfenv(1))
local Util = require('util') local Util = require('util')
@ -32,6 +36,8 @@ function clipboard.useInternal(mode)
end end
end end
multishell.addHotkey(20, function() if multishell and multishell.addHotkey then
clipboard.useInternal(not clipboard.isInternal()) multishell.addHotkey(20, function()
end) clipboard.useInternal(not clipboard.isInternal())
end)
end

View File

@ -1,3 +1,7 @@
if _G.device then
return
end
requireInjector(getfenv(1)) requireInjector(getfenv(1))
local Peripheral = require('peripheral') local Peripheral = require('peripheral')

View File

@ -1,4 +1,4 @@
if not turtle then if not turtle or turtle.pathfind then
return return
end end

View File

@ -1,4 +1,4 @@
if not turtle then if not turtle or turtle.abortAction then
return return
end end

View File

@ -1,4 +1,4 @@
if not turtle then if not turtle or turtle.enableGPS then
return return
end end

View File

@ -1,4 +1,4 @@
if not turtle then if not turtle or turtle.getPoint then
return return
end end