:3333333 extra config stuff

This commit is contained in:
2024-08-18 14:37:59 +03:00
parent 2eb20cb6c5
commit 348e764adf
6 changed files with 80 additions and 3092 deletions

View File

@@ -1,3 +1,27 @@
return {
correctPin = "42169"
local config = {
correctPin = "42169",
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",
config_path = "keypadOS.config.lua"
}
local DEFAULT_CONFIG = "return {\n" ..
" group=\"default\",\n" ..
"}\n"
--- @class Config
--- @field group string
--- Read current configs, create if doesnt exist
---@return Config
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

View File

@@ -2,8 +2,6 @@
-- intended for checking for updates, and automatically updating basalt if it is missing
local utils = require("utils.lua")
local updater = require("updater.lua")
local main = {}

View File

@@ -1,5 +1,5 @@
local utils = require("utils.lua")
local config = require("config.lua")
local LAST_USED = os.time()
local mod = {}
@@ -7,11 +7,12 @@ local mod = {}
local function checkForUpdate()
local current_time = os.time()
local difference = math.abs(current_time - LAST_USED)
print("Checking for update... difference: " .. tostring(difference))
-- print("INFO: Checking for update... difference: " .. tostring(difference))
--its been considerable time since the keypad was interacted with
--therefore it's time to force an update down the users throat (microsoft moment)
if difference > .5 then
local update_code_request = http.get("https://git.mcorangehq.xyz/xomf/keypadOS/raw/branch/main/keypadOS.lua")
print("INFO: Updating! (diff: " .. tostring(difference) .. ")")
local update_code_request = http.get(config.release_url)
if update_code_request then
local update_code_text = update_code_request.readAll()
if update_code_text then
@@ -45,7 +46,7 @@ function mod.GetBasalt()
utils.MonPrint("Basalt found!")
else
utils.MonPrint("Downloading basalt...")
local basalt_code = http.get("https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/versions/latest.lua").readAll()
local basalt_code = http.get(config.release_url).readAll()
utils.MonPrint("Installing basalt...")
local file = fs.open("basalt.lua", "w")