LABksh;fiuboslhfbl\

This commit is contained in:
Gvidas Juknevičius 2024-08-18 04:34:08 +03:00
parent dad04f35d6
commit 022c503a9d
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
5 changed files with 33 additions and 44 deletions

View File

@ -11,6 +11,7 @@ end
rawset(__BUNDLER_FILES, "updater.lua", function ()
local utils = require("utils.lua")
local LAST_USED = os.time()
local mod = {}
local function checkForUpdate()
local current_time = os.time()
local difference = math.abs(current_time - LAST_USED)
@ -35,13 +36,13 @@ rawset(__BUNDLER_FILES, "updater.lua", function ()
end
end
end
function UpdateChecker()
function mod.UpdateChecker()
while true do
checkForUpdate()
sleep(1)
end
end
function GetBasalt()
function mod.GetBasalt()
if fs.exists("basalt.lua") then
utils.MonPrint("Basalt found!")
else
@ -60,10 +61,7 @@ rawset(__BUNDLER_FILES, "updater.lua", function ()
os.reboot()
end
end
return {
UpdateChecker,
GetBasalt
}
return mod
end) -- FILE END: updater.lua --
@ -83,6 +81,7 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
local monitor = utils.Cast(peripheral.find("monitor"))
--- @type drive
local drive = utils.Cast(peripheral.find("drive"))
local mod = {}
--- @class Ui
--- @field pin string
--- @field main any
@ -134,7 +133,7 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
ui.pin = ui.pin .. tostring(i)
ui.pinLabel:setText(ui.pin)
end
function InitUi()
function mod.InitUi()
local ui = {
resetEverything,
unlockDoor,
@ -180,37 +179,32 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
os.reboot()
end
end
return {
InitUi,
}
return mod
end) -- FILE END: ui.lua --
rawset(__BUNDLER_FILES, "utils.lua", function ()
local utils = {}
-- Type coersion for lsp
---@generic T
---@param object any
---@return T
function Cast(object)
function utils.Cast(object)
return object
end
--- @type Monitor
local MONITOR = Cast(peripheral.find("monitor"))
local MONITOR_Y = 1
function MonPrint(text)
function utils.MonPrint(text)
MONITOR.setCursorPos(1,MONITOR_Y)
MONITOR.write(text)
MONITOR_Y = MONITOR_Y + 1
end
function MonReset(scale)
function utils.MonReset(scale)
MONITOR.clear()
MONITOR.setTextScale(scale)
end
return {
MonPrint,
MonReset,
Cast,
}
return utils;
end) -- FILE END: utils.lua --
@ -220,17 +214,16 @@ rawset(__BUNDLER_FILES, "main.lua", function ()
local utils = require("utils.lua")
local updater = require("updater.lua")
local ui = require("ui.lua")
local main = {}
KEYPADOS_VERSION = "3.0"
function Main()
function main.Main()
utils.MonPrint(0.5)
updater.getBasalt()
utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION)
utils.MonPrint(1)
ui.InitUi()
end
return {
Main
}
return main
end) -- FILE END: main.lua --

View File

@ -4,11 +4,12 @@ local utils = require("utils.lua")
local updater = require("updater.lua")
local ui = require("ui.lua")
local main = {}
KEYPADOS_VERSION = "3.0"
function Main()
function main.Main()
utils.MonPrint(0.5)
updater.getBasalt()
utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION)
@ -17,7 +18,5 @@ function Main()
end
return {
Main
}
return main

View File

@ -7,6 +7,8 @@ local monitor = utils.Cast(peripheral.find("monitor"))
--- @type drive
local drive = utils.Cast(peripheral.find("drive"))
local mod = {}
--- @class Ui
--- @field pin string
--- @field main any
@ -66,7 +68,7 @@ local function addToPin(ui, i)
ui.pinLabel:setText(ui.pin)
end
function InitUi()
function mod.InitUi()
local ui = {
resetEverything,
unlockDoor,
@ -120,6 +122,4 @@ function InitUi()
end
end
return {
InitUi,
}
return mod

View File

@ -2,6 +2,8 @@ local utils = require("utils.lua")
local LAST_USED = os.time()
local mod = {}
local function checkForUpdate()
local current_time = os.time()
local difference = math.abs(current_time - LAST_USED)
@ -28,14 +30,14 @@ local function checkForUpdate()
end
end
function UpdateChecker()
function mod.UpdateChecker()
while true do
checkForUpdate()
sleep(1)
end
end
function GetBasalt()
function mod.GetBasalt()
if fs.exists("basalt.lua") then
utils.MonPrint("Basalt found!")
else
@ -58,7 +60,4 @@ function GetBasalt()
end
end
return {
UpdateChecker,
GetBasalt
}
return mod

View File

@ -1,8 +1,10 @@
local utils = {}
-- Type coersion for lsp
---@generic T
---@param object any
---@return T
function Cast(object)
function utils.Cast(object)
return object
end
@ -10,19 +12,15 @@ end
--- @type Monitor
local MONITOR = Cast(peripheral.find("monitor"))
local MONITOR_Y = 1
function MonPrint(text)
function utils.MonPrint(text)
MONITOR.setCursorPos(1,MONITOR_Y)
MONITOR.write(text)
MONITOR_Y = MONITOR_Y + 1
end
function MonReset(scale)
function utils.MonReset(scale)
MONITOR.clear()
MONITOR.setTextScale(scale)
end
return {
MonPrint,
MonReset,
Cast,
}
return utils;