From 5c35a8383e06719f7b3559df962bce5b699c8cac Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Fri, 1 Nov 2019 22:37:08 -0600 Subject: [PATCH] lock computer --- startup.lua | 31 +++++++++++++++++-------------- sys/init/2.vfs.lua | 10 +++++----- sys/lzwfs.lua | 9 ++++++--- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/startup.lua b/startup.lua index 0cfcd7f..b6381d1 100644 --- a/startup.lua +++ b/startup.lua @@ -13,10 +13,13 @@ description: array of menu entries (see .startup.boot for examples) ]] -local colors = _G.colors -local os = _G.os -local settings = _G.settings -local term = _G.term +local colors = _G.colors +local fs = _G.fs +local keys = _G.keys +local os = _G.os +local settings = _G.settings +local term = _G.term +local textutils = _G.textutils local function loadBootOptions() if not fs.exists('.startup.boot') then @@ -87,19 +90,19 @@ local function startupMenu() if key == keys.enter or key == keys.right then return selected - elseif key == keys.down then - if selected == #bootOptions.menu then - selected = 0 + elseif key == keys.down then + if selected == #bootOptions.menu then + selected = 0 end selected = selected + 1 - elseif key == keys.up then - if selected == 1 then - selected = #bootOptions.menu + 1 + elseif key == keys.up then + if selected == 1 then + selected = #bootOptions.menu + 1 end selected = selected - 1 elseif event == 'char' then key = tonumber(key) or 0 - if bootOptions.menu[key] then + if bootOptions.menu[key] then return key end end @@ -145,13 +148,13 @@ local function splash() term.write(str) end -term.clear() -splash() - for _, v in pairs(bootOptions.preload) do os.run(_ENV, v) end +term.clear() +splash() + local timerId = os.startTimer(bootOptions.delay) while true do local e, id = os.pullEvent() diff --git a/sys/init/2.vfs.lua b/sys/init/2.vfs.lua index 0ddc672..62f5b4d 100644 --- a/sys/init/2.vfs.lua +++ b/sys/init/2.vfs.lua @@ -1,3 +1,5 @@ +local fs = _G.fs + if fs.native then return end @@ -7,8 +9,6 @@ local Util = require('opus.util') -- TODO: support getDrive for virtual nodes -local fs = _G.fs - fs.native = Util.shallowCopy(fs) local fstypes = { } @@ -16,7 +16,7 @@ local nativefs = { } for k,fn in pairs(fs) do if type(fn) == 'function' then - nativefs[k] = function(node, ...) + nativefs[k] = function(_, ...) return fn(...) end end @@ -340,8 +340,8 @@ function fs.unmount(path) end end -function fs.registerType(name, fs) - fstypes[name] = fs +function fs.registerType(name, vfs) + fstypes[name] = vfs end function fs.getTypes() diff --git a/sys/lzwfs.lua b/sys/lzwfs.lua index ac2ddb8..c1e9088 100644 --- a/sys/lzwfs.lua +++ b/sys/lzwfs.lua @@ -11,7 +11,7 @@ -- 1 is reserved for compression exclusion -- fs.addException('startup.lua', 1) --- To renable compression for a file +-- To renable compression for a file -- fs.removeException('startup.lua', 1) -- Restores file system @@ -23,6 +23,9 @@ local sub = string.sub local tconcat = table.concat local tinsert = table.insert +local bit = _G.bit +local fs = _G.fs + local SIGC = 'LZWC' local IGNORE_COMPRESSION = 1 -- support other bits as well @@ -157,7 +160,7 @@ local function decompress(input) return tconcat(result) end -function split(str, pattern) +local function split(str, pattern) pattern = pattern or "(.-)\n" local t = {} local function helper(line) tinsert(t, line) return "" end @@ -219,7 +222,7 @@ function fs.open(fname, flags) end, flush = function() -- this isn't gonna work... - // f.write(compress(tconcat(c))) + -- f.write(compress(tconcat(c))) f.flush(); end, close = function()