LABksh;fiuboslhfbl\
This commit is contained in:
		
							parent
							
								
									dad04f35d6
								
							
						
					
					
						commit
						022c503a9d
					
				
							
								
								
									
										37
									
								
								keypadOS.lua
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								keypadOS.lua
									
									
									
									
									
								
							| 
						 | 
					@ -11,6 +11,7 @@ end
 | 
				
			||||||
rawset(__BUNDLER_FILES, "updater.lua", function ()
 | 
					rawset(__BUNDLER_FILES, "updater.lua", function ()
 | 
				
			||||||
    local utils = require("utils.lua")
 | 
					    local utils = require("utils.lua")
 | 
				
			||||||
    local LAST_USED = os.time()
 | 
					    local LAST_USED = os.time()
 | 
				
			||||||
 | 
					    local mod = {}
 | 
				
			||||||
    local function checkForUpdate()
 | 
					    local function checkForUpdate()
 | 
				
			||||||
        local current_time = os.time()
 | 
					        local current_time = os.time()
 | 
				
			||||||
        local difference = math.abs(current_time - LAST_USED)
 | 
					        local difference = math.abs(current_time - LAST_USED)
 | 
				
			||||||
| 
						 | 
					@ -35,13 +36,13 @@ rawset(__BUNDLER_FILES, "updater.lua", function ()
 | 
				
			||||||
            end
 | 
					            end
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    function UpdateChecker()
 | 
					    function mod.UpdateChecker()
 | 
				
			||||||
        while true do
 | 
					        while true do
 | 
				
			||||||
            checkForUpdate()
 | 
					            checkForUpdate()
 | 
				
			||||||
            sleep(1)
 | 
					            sleep(1)
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    function GetBasalt()
 | 
					    function mod.GetBasalt()
 | 
				
			||||||
        if fs.exists("basalt.lua") then
 | 
					        if fs.exists("basalt.lua") then
 | 
				
			||||||
            utils.MonPrint("Basalt found!")
 | 
					            utils.MonPrint("Basalt found!")
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
| 
						 | 
					@ -60,10 +61,7 @@ rawset(__BUNDLER_FILES, "updater.lua", function ()
 | 
				
			||||||
            os.reboot()
 | 
					            os.reboot()
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    return {
 | 
					    return mod
 | 
				
			||||||
        UpdateChecker,
 | 
					 | 
				
			||||||
        GetBasalt
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
end) -- FILE END: updater.lua --
 | 
					end) -- FILE END: updater.lua --
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -83,6 +81,7 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
 | 
				
			||||||
    local monitor = utils.Cast(peripheral.find("monitor"))
 | 
					    local monitor = utils.Cast(peripheral.find("monitor"))
 | 
				
			||||||
    --- @type drive
 | 
					    --- @type drive
 | 
				
			||||||
    local drive = utils.Cast(peripheral.find("drive"))
 | 
					    local drive = utils.Cast(peripheral.find("drive"))
 | 
				
			||||||
 | 
					    local mod = {}
 | 
				
			||||||
    --- @class Ui
 | 
					    --- @class Ui
 | 
				
			||||||
    --- @field pin string
 | 
					    --- @field pin string
 | 
				
			||||||
    --- @field main any
 | 
					    --- @field main any
 | 
				
			||||||
| 
						 | 
					@ -134,7 +133,7 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
 | 
				
			||||||
        ui.pin = ui.pin .. tostring(i)
 | 
					        ui.pin = ui.pin .. tostring(i)
 | 
				
			||||||
        ui.pinLabel:setText(ui.pin)
 | 
					        ui.pinLabel:setText(ui.pin)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    function InitUi()
 | 
					    function mod.InitUi()
 | 
				
			||||||
        local ui = {
 | 
					        local ui = {
 | 
				
			||||||
            resetEverything,
 | 
					            resetEverything,
 | 
				
			||||||
            unlockDoor,
 | 
					            unlockDoor,
 | 
				
			||||||
| 
						 | 
					@ -180,37 +179,32 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
 | 
				
			||||||
            os.reboot()
 | 
					            os.reboot()
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    return {
 | 
					    return mod
 | 
				
			||||||
        InitUi,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
end) -- FILE END: ui.lua --
 | 
					end) -- FILE END: ui.lua --
 | 
				
			||||||
 | 
					
 | 
				
			||||||
rawset(__BUNDLER_FILES, "utils.lua", function ()
 | 
					rawset(__BUNDLER_FILES, "utils.lua", function ()
 | 
				
			||||||
 | 
					    local utils = {}
 | 
				
			||||||
    -- Type coersion for lsp
 | 
					    -- Type coersion for lsp
 | 
				
			||||||
    ---@generic T
 | 
					    ---@generic T
 | 
				
			||||||
    ---@param object any
 | 
					    ---@param object any
 | 
				
			||||||
    ---@return T
 | 
					    ---@return T
 | 
				
			||||||
    function Cast(object)
 | 
					    function utils.Cast(object)
 | 
				
			||||||
        return object
 | 
					        return object
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    --- @type Monitor
 | 
					    --- @type Monitor
 | 
				
			||||||
    local MONITOR = Cast(peripheral.find("monitor"))
 | 
					    local MONITOR = Cast(peripheral.find("monitor"))
 | 
				
			||||||
    local MONITOR_Y = 1
 | 
					    local MONITOR_Y = 1
 | 
				
			||||||
    function MonPrint(text)
 | 
					    function utils.MonPrint(text)
 | 
				
			||||||
        MONITOR.setCursorPos(1,MONITOR_Y)
 | 
					        MONITOR.setCursorPos(1,MONITOR_Y)
 | 
				
			||||||
        MONITOR.write(text)
 | 
					        MONITOR.write(text)
 | 
				
			||||||
        MONITOR_Y = MONITOR_Y + 1
 | 
					        MONITOR_Y = MONITOR_Y + 1
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    function MonReset(scale)
 | 
					    function utils.MonReset(scale)
 | 
				
			||||||
        MONITOR.clear()
 | 
					        MONITOR.clear()
 | 
				
			||||||
        MONITOR.setTextScale(scale)
 | 
					        MONITOR.setTextScale(scale)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    return {
 | 
					    return utils;
 | 
				
			||||||
        MonPrint,
 | 
					 | 
				
			||||||
        MonReset,
 | 
					 | 
				
			||||||
        Cast,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
end) -- FILE END: utils.lua --
 | 
					end) -- FILE END: utils.lua --
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -220,17 +214,16 @@ 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 ui = require("ui.lua")
 | 
					    local ui = require("ui.lua")
 | 
				
			||||||
 | 
					    local main = {}
 | 
				
			||||||
    KEYPADOS_VERSION = "3.0"
 | 
					    KEYPADOS_VERSION = "3.0"
 | 
				
			||||||
    function Main()
 | 
					    function main.Main()
 | 
				
			||||||
        utils.MonPrint(0.5)
 | 
					        utils.MonPrint(0.5)
 | 
				
			||||||
        updater.getBasalt()
 | 
					        updater.getBasalt()
 | 
				
			||||||
        utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION)
 | 
					        utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION)
 | 
				
			||||||
        utils.MonPrint(1)
 | 
					        utils.MonPrint(1)
 | 
				
			||||||
        ui.InitUi()
 | 
					        ui.InitUi()
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    return {
 | 
					    return main
 | 
				
			||||||
        Main
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
end) -- FILE END: main.lua --
 | 
					end) -- FILE END: main.lua --
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,11 +4,12 @@ local utils = require("utils.lua")
 | 
				
			||||||
local updater = require("updater.lua")
 | 
					local updater = require("updater.lua")
 | 
				
			||||||
local ui = require("ui.lua")
 | 
					local ui = require("ui.lua")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local main = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
KEYPADOS_VERSION = "3.0"
 | 
					KEYPADOS_VERSION = "3.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function Main()
 | 
					function main.Main()
 | 
				
			||||||
    utils.MonPrint(0.5)
 | 
					    utils.MonPrint(0.5)
 | 
				
			||||||
    updater.getBasalt()
 | 
					    updater.getBasalt()
 | 
				
			||||||
    utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION)
 | 
					    utils.MonPrint("keypadOS v" .. KEYPADOS_VERSION)
 | 
				
			||||||
| 
						 | 
					@ -17,7 +18,5 @@ function Main()
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return {
 | 
					return main
 | 
				
			||||||
    Main
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,8 @@ local monitor = utils.Cast(peripheral.find("monitor"))
 | 
				
			||||||
--- @type drive
 | 
					--- @type drive
 | 
				
			||||||
local drive = utils.Cast(peripheral.find("drive"))
 | 
					local drive = utils.Cast(peripheral.find("drive"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local mod = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
--- @class Ui
 | 
					--- @class Ui
 | 
				
			||||||
--- @field pin string
 | 
					--- @field pin string
 | 
				
			||||||
--- @field main any
 | 
					--- @field main any
 | 
				
			||||||
| 
						 | 
					@ -66,7 +68,7 @@ local function addToPin(ui, i)
 | 
				
			||||||
    ui.pinLabel:setText(ui.pin)
 | 
					    ui.pinLabel:setText(ui.pin)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function InitUi()
 | 
					function mod.InitUi()
 | 
				
			||||||
    local ui = {
 | 
					    local ui = {
 | 
				
			||||||
        resetEverything,
 | 
					        resetEverything,
 | 
				
			||||||
        unlockDoor,
 | 
					        unlockDoor,
 | 
				
			||||||
| 
						 | 
					@ -120,6 +122,4 @@ function InitUi()
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return {
 | 
					return mod
 | 
				
			||||||
    InitUi,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,6 +2,8 @@ local utils = require("utils.lua")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local LAST_USED = os.time()
 | 
					local LAST_USED = os.time()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local mod = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function checkForUpdate()
 | 
					local function checkForUpdate()
 | 
				
			||||||
    local current_time = os.time()
 | 
					    local current_time = os.time()
 | 
				
			||||||
    local difference = math.abs(current_time - LAST_USED)
 | 
					    local difference = math.abs(current_time - LAST_USED)
 | 
				
			||||||
| 
						 | 
					@ -28,14 +30,14 @@ local function checkForUpdate()
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function UpdateChecker()
 | 
					function mod.UpdateChecker()
 | 
				
			||||||
    while true do
 | 
					    while true do
 | 
				
			||||||
        checkForUpdate()
 | 
					        checkForUpdate()
 | 
				
			||||||
        sleep(1)
 | 
					        sleep(1)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function GetBasalt()
 | 
					function mod.GetBasalt()
 | 
				
			||||||
    if fs.exists("basalt.lua") then
 | 
					    if fs.exists("basalt.lua") then
 | 
				
			||||||
        utils.MonPrint("Basalt found!")
 | 
					        utils.MonPrint("Basalt found!")
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
| 
						 | 
					@ -58,7 +60,4 @@ function GetBasalt()
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return {
 | 
					return mod
 | 
				
			||||||
    UpdateChecker,
 | 
					 | 
				
			||||||
    GetBasalt
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,10 @@
 | 
				
			||||||
 | 
					local utils = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Type coersion for lsp
 | 
					-- Type coersion for lsp
 | 
				
			||||||
---@generic T
 | 
					---@generic T
 | 
				
			||||||
---@param object any
 | 
					---@param object any
 | 
				
			||||||
---@return T
 | 
					---@return T
 | 
				
			||||||
function Cast(object)
 | 
					function utils.Cast(object)
 | 
				
			||||||
    return object
 | 
					    return object
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,19 +12,15 @@ end
 | 
				
			||||||
--- @type Monitor
 | 
					--- @type Monitor
 | 
				
			||||||
local MONITOR = Cast(peripheral.find("monitor"))
 | 
					local MONITOR = Cast(peripheral.find("monitor"))
 | 
				
			||||||
local MONITOR_Y = 1
 | 
					local MONITOR_Y = 1
 | 
				
			||||||
function MonPrint(text)
 | 
					function utils.MonPrint(text)
 | 
				
			||||||
    MONITOR.setCursorPos(1,MONITOR_Y)
 | 
					    MONITOR.setCursorPos(1,MONITOR_Y)
 | 
				
			||||||
    MONITOR.write(text)
 | 
					    MONITOR.write(text)
 | 
				
			||||||
    MONITOR_Y = MONITOR_Y + 1
 | 
					    MONITOR_Y = MONITOR_Y + 1
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function MonReset(scale)
 | 
					function utils.MonReset(scale)
 | 
				
			||||||
    MONITOR.clear()
 | 
					    MONITOR.clear()
 | 
				
			||||||
    MONITOR.setTextScale(scale)
 | 
					    MONITOR.setTextScale(scale)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return {
 | 
					return utils;
 | 
				
			||||||
    MonPrint,
 | 
					 | 
				
			||||||
    MonReset,
 | 
					 | 
				
			||||||
    Cast,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user