local __BUNDLER_FILES = {} local __DEFAULT_IMPORT = require local require = function(path) if __BUNDLER_FILES[path] then return __BUNDLER_FILES[path]() elseif __BUNDLER_FILES[path .. ".lua"] then return __BUNDLER_FILES[path .. ".lua"]() else return __DEFAULT_IMPORT(path) end end local __UPDATE_HASH = "5e1c10aba96c3f9ded6aecb030f2774577c005af" rawset(__BUNDLER_FILES, "updater.lua", function () local utils = require("utils.lua") local config = require("config.lua") local mod = {} function mod.GetBasalt() if fs.exists("basalt.lua") then utils.MonPrint("Basalt found!") else utils.MonPrint("Downloading basalt...") local basalt_code = http.get(config.basalt_url).readAll() utils.MonPrint("Installing basalt...") local file = fs.open("basalt.lua", "w") if not file then utils.MonPrint("failed to get basalt") sleep(60) os.reboot() end file.write(utils.Cast(basalt_code)) file.close() utils.MonPrint("Rebooting...") os.reboot() end end return mod end) rawset(__BUNDLER_FILES, "config.lua", function () local config = { correctPin = "42069", release_url = "https://git.mcorangehq.xyz/xomf/keypadOS/raw/branch/main/keypadOS.lua", basalt_url = "https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/versions/latest.lua", ntfy_url = "https://ntfy.sh/keypadOS_alerts", config_path = "keypadOS.config.lua" } local DEFAULT_CONFIG = "return {\n" .. " group=\"default\",\n" .. "}\n" function config.ReadConfig() if not fs.exists(config.config_path) then local f = fs.open(config.config_path, "w") f.write(DEFAULT_CONFIG) f.close(); end local cfg = require(config.config_path) return cfg end return config end) rawset(__BUNDLER_FILES, "ui.lua", function () local utils = require("utils.lua") local basalt = require("basalt") local config = require("config.lua") local updater = require("updater.lua") local monitor = utils.Cast(peripheral.find("monitor")) local drive = utils.Cast(peripheral.find("drive")) local mod = {} local function resetEverything(ui) sleep(2) ui.pin = "" ui.pinLabel:setText("") redstone.setOutput("front", false) ui.enterButton:setBackground(colors.blue) end local function unlockDoor(ui) if drive.isDiskPresent() then if drive.getDiskLabel() == config.correctPin then ui.pin = config.correctPin drive:ejectDisk() end end if ui.pin == config.correctPin then blibs.notifier.notify("5", "Unlocked door :3 love u"); ui.enterButton:setBackground(colors.green) ui.pinLabel:setText("Welcome") redstone.setOutput("front", true) if drive.isDiskPresent() then if drive.getDiskLabel() == nil then drive.setDiskLabel(config.correctPin) ui.pinLabel:setText("Crd set") drive:ejectDisk() end end else ui.pinLabel:setText("Wrong") ui.enterButton:setBackground(colors.red) end ui.main:addThread():start(function() resetEverything(ui) end) end local function addToPin(ui, i) if #ui.pin >= 5 then return end ui.pin = ui.pin .. tostring(i) ui.pinLabel:setText(ui.pin) end function mod.InitUi() local ui = { pin = "", main = basalt.addMonitor(), } ui.main:setMonitor(monitor) ui.pinLabel = ui.main:addLabel() :setText("") :setFontSize(1) ui.enterButton = ui.main:addButton() :setText(">>>>") :setBackground(colors.blue) :setPosition(6,2) :setSize(1.5,3.2) :onClick(function() unlockDoor(ui) end) local btnX = 1 local btnY = 2 ui.main:addButton() :setPosition(1, 5) :setText("0") :setSize(6,1) :onClick(function() addToPin(ui, 0) end) for i = 1, 9 do ui.main:addButton() :setPosition(btnX, btnY) :setText(tostring(i)) :setSize(2,1) :onClick(function() addToPin(ui, i) end) btnX = btnX + 2 if btnX >= 6 then btnY = btnY + 1 btnX = 1 end end local status, err = pcall(function () parallel.waitForAll(basalt.autoUpdate) end) if not status and err ~= "Terminated" then log.error("Error detected: " .. err) blibs.notifier.notify("5", err); --exposed ntfy url no spam me pls sleep(5) utils.MonReset(0.5) fs.delete("basalt.lua") fs.delete("startup.lua") fs.copy("backup.lua", "startup.lua") os.reboot() end end return mod end) rawset(__BUNDLER_FILES, "utils.lua", function () local utils = {} function utils.Cast(object) return object end local MONITOR = utils.Cast(peripheral.find("monitor")) local MONITOR_Y = 1 function utils.MonPrint(text) MONITOR.setCursorPos(1,MONITOR_Y) MONITOR.write(text) MONITOR_Y = MONITOR_Y + 1 end function utils.MonReset(scale) MONITOR.clear() MONITOR.setTextScale(scale) end return utils; end) rawset(__BUNDLER_FILES, "main.lua", function () local utils = require("utils.lua") local updater = require("updater.lua") local mod = {} KEYPADOS_VERSION = "4.0" function mod.main(blibs) _G.log = blibs.log; _G.blibs = blibs; utils.MonReset(0.5) updater.GetBasalt() utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION) utils.MonReset(1) require("ui.lua").InitUi() end return mod; end) return require("main.lua")