trying new update system mayb
This commit is contained in:
parent
2e33e98e5e
commit
68a7d4eaa5
20
keypadOS.lua
20
keypadOS.lua
|
@ -7,7 +7,7 @@ local require = function(path)
|
||||||
return __DEFAULT_IMPORT(path)
|
return __DEFAULT_IMPORT(path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local KEYPADOS_UPDATE_HASH = "PJIEvsAncSvhKOqsLGVlxvzJ"
|
||||||
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()
|
||||||
|
@ -26,10 +26,9 @@ rawset(__BUNDLER_FILES, "updater.lua", function ()
|
||||||
if string.find(update_code_text, "^local __BUNDLER_FILES = {}") then
|
if string.find(update_code_text, "^local __BUNDLER_FILES = {}") then
|
||||||
-- Make backup
|
-- Make backup
|
||||||
fs.copy("startup.lua", "backup.lua")
|
fs.copy("startup.lua", "backup.lua")
|
||||||
local startup_file = fs.open("startup.lua", "r")
|
local pattern = 'local KEYPADOS_UPDATE_HASH%s*=%s*"(.-)"'
|
||||||
local startup_contents = startup_file.readAll()
|
local foundUpdateHash = inputString:match(pattern)
|
||||||
startup_file.close()
|
if KEYPADOS_UPDATE_HASH ~= foundUpdateHash then
|
||||||
if update_code_text ~= startup_contents then
|
|
||||||
local file = fs.open("startup.lua", "w")
|
local file = fs.open("startup.lua", "w")
|
||||||
file.write(update_code_text)
|
file.write(update_code_text)
|
||||||
file.close()
|
file.close()
|
||||||
|
@ -160,13 +159,20 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
|
||||||
ui.enterButton = ui.main:addButton()
|
ui.enterButton = ui.main:addButton()
|
||||||
:setText(">>>>")
|
:setText(">>>>")
|
||||||
:setBackground(colors.blue)
|
:setBackground(colors.blue)
|
||||||
:setPosition(6,3)
|
:setPosition(6,2)
|
||||||
:setSize(1.5,3.2)
|
:setSize(1.5,3.2)
|
||||||
:onClick(function()
|
:onClick(function()
|
||||||
unlockDoor(ui)
|
unlockDoor(ui)
|
||||||
end)
|
end)
|
||||||
local btnX = 1
|
local btnX = 1
|
||||||
local btnY = 3
|
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
|
for i = 1, 9 do
|
||||||
ui.main:addButton()
|
ui.main:addButton()
|
||||||
:setPosition(btnX, btnY)
|
:setPosition(btnX, btnY)
|
||||||
|
|
12
src/ui.lua
12
src/ui.lua
|
@ -83,14 +83,22 @@ function mod.InitUi()
|
||||||
ui.enterButton = ui.main:addButton()
|
ui.enterButton = ui.main:addButton()
|
||||||
:setText(">>>>")
|
:setText(">>>>")
|
||||||
:setBackground(colors.blue)
|
:setBackground(colors.blue)
|
||||||
:setPosition(6,3)
|
:setPosition(6,2)
|
||||||
:setSize(1.5,3.2)
|
:setSize(1.5,3.2)
|
||||||
:onClick(function()
|
:onClick(function()
|
||||||
unlockDoor(ui)
|
unlockDoor(ui)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local btnX = 1
|
local btnX = 1
|
||||||
local btnY = 3
|
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
|
for i = 1, 9 do
|
||||||
ui.main:addButton()
|
ui.main:addButton()
|
||||||
|
|
|
@ -19,11 +19,10 @@ local function checkForUpdate()
|
||||||
-- Make backup
|
-- Make backup
|
||||||
fs.copy("startup.lua", "backup.lua")
|
fs.copy("startup.lua", "backup.lua")
|
||||||
|
|
||||||
local startup_file = fs.open("startup.lua", "r")
|
local pattern = 'local KEYPADOS_UPDATE_HASH%s*=%s*"(.-)"'
|
||||||
local startup_contents = startup_file.readAll()
|
local foundUpdateHash = inputString:match(pattern)
|
||||||
startup_file.close()
|
|
||||||
|
|
||||||
if update_code_text ~= startup_contents then
|
if KEYPADOS_UPDATE_HASH ~= foundUpdateHash then
|
||||||
local file = fs.open("startup.lua", "w")
|
local file = fs.open("startup.lua", "w")
|
||||||
file.write(update_code_text)
|
file.write(update_code_text)
|
||||||
file.close()
|
file.close()
|
||||||
|
|
5
x.py
5
x.py
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
import string
|
||||||
|
import random
|
||||||
|
UPDATE_ID= ''.join(random.choices(string.ascii_letters, k=24))
|
||||||
OUTPUT="keypadOS.lua";
|
OUTPUT="keypadOS.lua";
|
||||||
FILES= [
|
FILES= [
|
||||||
"updater.lua",
|
"updater.lua",
|
||||||
|
@ -31,6 +33,7 @@ def main():
|
||||||
buf += " return __DEFAULT_IMPORT(path)\n";
|
buf += " return __DEFAULT_IMPORT(path)\n";
|
||||||
buf += " end\n";
|
buf += " end\n";
|
||||||
buf += "end\n";
|
buf += "end\n";
|
||||||
|
buf += f'local KEYPADOS_UPDATE_HASH = "{UPDATE_ID}"';
|
||||||
|
|
||||||
for file in FILES:
|
for file in FILES:
|
||||||
print(f"=== FILE: {file}");
|
print(f"=== FILE: {file}");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user