Compare commits
3 Commits
main
...
7ed9f76f15
| Author | SHA1 | Date | |
|---|---|---|---|
|
7ed9f76f15
|
|||
|
2a8932a19f
|
|||
|
28ceac8643
|
15
keypadOS.lua
15
keypadOS.lua
@@ -7,7 +7,7 @@ local require = function(path)
|
|||||||
return __DEFAULT_IMPORT(path)
|
return __DEFAULT_IMPORT(path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local __UPDATE_HASH = "56dffe1d3654b028310d4c9dc976b7c7cc8c9d5a"
|
local __UPDATE_HASH = "18ceba38b88d8a5429e953d23257a26a01c642cf"
|
||||||
rawset(__BUNDLER_FILES, "updater.lua", function ()
|
rawset(__BUNDLER_FILES, "updater.lua", function ()
|
||||||
local utils = require("utils.lua")
|
local utils = require("utils.lua")
|
||||||
local config = require("config.lua")
|
local config = require("config.lua")
|
||||||
@@ -109,6 +109,7 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
|
|||||||
local basalt = require("basalt")
|
local basalt = require("basalt")
|
||||||
local config = require("config.lua")
|
local config = require("config.lua")
|
||||||
local updater = require("updater.lua")
|
local updater = require("updater.lua")
|
||||||
|
local blibs = require("main").blibs;
|
||||||
local monitor = utils.Cast(peripheral.find("monitor"))
|
local monitor = utils.Cast(peripheral.find("monitor"))
|
||||||
local drive = utils.Cast(peripheral.find("drive"))
|
local drive = utils.Cast(peripheral.find("drive"))
|
||||||
local mod = {}
|
local mod = {}
|
||||||
@@ -128,6 +129,7 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
|
|||||||
end
|
end
|
||||||
basalt.debug("test")
|
basalt.debug("test")
|
||||||
if ui.pin == config.correctPin then
|
if ui.pin == config.correctPin then
|
||||||
|
blibs.notifier.notify("5", "Unlocked door :3 love u");
|
||||||
ui.enterButton:setBackground(colors.green)
|
ui.enterButton:setBackground(colors.green)
|
||||||
ui.pinLabel:setText("Welcome")
|
ui.pinLabel:setText("Welcome")
|
||||||
redstone.setOutput("front", true)
|
redstone.setOutput("front", true)
|
||||||
@@ -194,7 +196,7 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
local status, err = pcall(function ()
|
local status, err = pcall(function ()
|
||||||
parallel.waitForAll(basalt.autoUpdate, updater.UpdateChecker)
|
parallel.waitForAll(basalt.autoUpdate)
|
||||||
end)
|
end)
|
||||||
if not status and err ~= "Terminated" then
|
if not status and err ~= "Terminated" then
|
||||||
print("Error detected: " .. err)
|
print("Error detected: " .. err)
|
||||||
@@ -230,15 +232,16 @@ end)
|
|||||||
rawset(__BUNDLER_FILES, "main.lua", function ()
|
rawset(__BUNDLER_FILES, "main.lua", function ()
|
||||||
local utils = require("utils.lua")
|
local utils = require("utils.lua")
|
||||||
local updater = require("updater.lua")
|
local updater = require("updater.lua")
|
||||||
local main = {}
|
local mod = {}
|
||||||
KEYPADOS_VERSION = "4.0"
|
KEYPADOS_VERSION = "4.0"
|
||||||
function main.Main()
|
function mod.main(blibs)
|
||||||
|
mod.blibs = blibs;
|
||||||
utils.MonReset(0.5)
|
utils.MonReset(0.5)
|
||||||
updater.GetBasalt()
|
updater.GetBasalt()
|
||||||
utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION)
|
utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION)
|
||||||
utils.MonReset(1)
|
utils.MonReset(1)
|
||||||
require("ui.lua").InitUi()
|
require("ui.lua").InitUi()
|
||||||
end
|
end
|
||||||
return main
|
return mod;
|
||||||
end)
|
end)
|
||||||
require("main.lua").Main()
|
return require("main.lua").Main
|
||||||
|
|||||||
33
src/main.lua
33
src/main.lua
@@ -1,13 +1,36 @@
|
|||||||
-- keycardOS "bootloader", has no access to basalt
|
|
||||||
-- intended for checking for updates, and automatically updating basalt if it is missing
|
|
||||||
local utils = require("utils.lua")
|
local utils = require("utils.lua")
|
||||||
local updater = require("updater.lua")
|
local updater = require("updater.lua")
|
||||||
local main = {}
|
|
||||||
|
|
||||||
|
local mod = {}
|
||||||
|
|
||||||
KEYPADOS_VERSION = "4.0"
|
KEYPADOS_VERSION = "4.0"
|
||||||
|
|
||||||
function main.Main()
|
--- @class BootloaderLibs
|
||||||
|
--- @field log Logger
|
||||||
|
--- @field updater Updater
|
||||||
|
--- @field notifier Notifier
|
||||||
|
--- @field json JsonParser
|
||||||
|
|
||||||
|
|
||||||
|
--- @class Logger
|
||||||
|
--- @field error fun(...)
|
||||||
|
--- @field warn fun(...)
|
||||||
|
--- @field info fun(...)
|
||||||
|
--- @field debug fun(...)
|
||||||
|
|
||||||
|
--- @class Updater
|
||||||
|
--- @field addEntry fun(path: string, branch: string, url: string)
|
||||||
|
|
||||||
|
--- @class JsonParser
|
||||||
|
--- @field decode fun(s: string): table
|
||||||
|
--- @field encode fun(s: table): string
|
||||||
|
|
||||||
|
--- @class Notifier
|
||||||
|
--- @field notify fun(priority: "1"|"2"|"3"|"4"|"5", body: string)
|
||||||
|
|
||||||
|
---@param blibs BootloaderLibs
|
||||||
|
function mod.main(blibs)
|
||||||
|
mod.blibs = blibs;
|
||||||
utils.MonReset(0.5)
|
utils.MonReset(0.5)
|
||||||
updater.GetBasalt()
|
updater.GetBasalt()
|
||||||
utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION)
|
utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION)
|
||||||
@@ -16,5 +39,5 @@ function main.Main()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return main
|
return mod;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ local utils = require("utils.lua")
|
|||||||
local basalt = require("basalt")
|
local basalt = require("basalt")
|
||||||
local config = require("config.lua")
|
local config = require("config.lua")
|
||||||
local updater = require("updater.lua")
|
local updater = require("updater.lua")
|
||||||
|
local blibs = require("main").blibs;
|
||||||
|
|
||||||
--- @type Monitor
|
--- @type Monitor
|
||||||
local monitor = utils.Cast(peripheral.find("monitor"))
|
local monitor = utils.Cast(peripheral.find("monitor"))
|
||||||
--- @type drive
|
--- @type drive
|
||||||
@@ -38,6 +40,7 @@ local function unlockDoor(ui)
|
|||||||
|
|
||||||
basalt.debug("test")
|
basalt.debug("test")
|
||||||
if ui.pin == config.correctPin then
|
if ui.pin == config.correctPin then
|
||||||
|
blibs.notifier.notify("5", "Unlocked door :3 love u");
|
||||||
ui.enterButton:setBackground(colors.green)
|
ui.enterButton:setBackground(colors.green)
|
||||||
ui.pinLabel:setText("Welcome")
|
ui.pinLabel:setText("Welcome")
|
||||||
redstone.setOutput("front", true)
|
redstone.setOutput("front", true)
|
||||||
@@ -117,7 +120,7 @@ function mod.InitUi()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local status, err = pcall(function ()
|
local status, err = pcall(function ()
|
||||||
parallel.waitForAll(basalt.autoUpdate, updater.UpdateChecker)
|
parallel.waitForAll(basalt.autoUpdate)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if not status and err ~= "Terminated" then
|
if not status and err ~= "Terminated" then
|
||||||
|
|||||||
2
x.py
2
x.py
@@ -56,7 +56,7 @@ def main():
|
|||||||
print(f"=== FILE: {file}");
|
print(f"=== FILE: {file}");
|
||||||
buf += read_file(file);
|
buf += read_file(file);
|
||||||
|
|
||||||
buf += "require(\"main.lua\").Main()\n";
|
buf += "return require(\"main.lua\").Main\n";
|
||||||
|
|
||||||
if MINIMISE:
|
if MINIMISE:
|
||||||
buf = minimise(buf);
|
buf = minimise(buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user