This commit is contained in:
Gvidas Juknevičius 2024-08-18 05:15:40 +03:00
parent b3b0ab41b3
commit 2eb20cb6c5
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
2 changed files with 19 additions and 25 deletions

View File

@ -94,6 +94,14 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
--- @field unlockDoor function --- @field unlockDoor function
--- @field addToPin function --- @field addToPin function
--- @param ui Ui --- @param ui Ui
local function resetEverything(ui)
sleep(2)
ui.pin = ""
ui.pinLabel:setText("")
redstone.setOutput("front", false)
ui.enterButton:setBackground(colors.blue)
end
--- @param ui Ui
local function unlockDoor(ui) local function unlockDoor(ui)
if drive.isDiskPresent() then if drive.isDiskPresent() then
if drive.getDiskLabel() == config.correctPin then if drive.getDiskLabel() == config.correctPin then
@ -118,18 +126,10 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
ui.enterButton:setBackground(colors.red) ui.enterButton:setBackground(colors.red)
end end
ui.main:addThread():start(function() ui.main:addThread():start(function()
ui.resetEverything(ui) resetEverything(ui)
end) end)
end end
--- @param ui Ui --- @param ui Ui
local function resetEverything(ui)
sleep(2)
ui.pin = ""
ui.pinLabel:setText("")
redstone.setOutput("front", false)
ui.enterButton:setBackground(colors.blue)
end
--- @param ui Ui
local function addToPin(ui, i) local function addToPin(ui, i)
if #ui.pin >= 5 then if #ui.pin >= 5 then
return return
@ -139,9 +139,6 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
end end
function mod.InitUi() function mod.InitUi()
local ui = { local ui = {
resetEverything,
unlockDoor,
addToPin,
pin = "", pin = "",
main = basalt.addMonitor(), main = basalt.addMonitor(),
} }

View File

@ -18,6 +18,15 @@ local mod = {}
--- @field unlockDoor function --- @field unlockDoor function
--- @field addToPin function --- @field addToPin function
--- @param ui Ui
local function resetEverything(ui)
sleep(2)
ui.pin = ""
ui.pinLabel:setText("")
redstone.setOutput("front", false)
ui.enterButton:setBackground(colors.blue)
end
--- @param ui Ui --- @param ui Ui
local function unlockDoor(ui) local function unlockDoor(ui)
if drive.isDiskPresent() then if drive.isDiskPresent() then
@ -45,19 +54,10 @@ local function unlockDoor(ui)
ui.enterButton:setBackground(colors.red) ui.enterButton:setBackground(colors.red)
end end
ui.main:addThread():start(function() ui.main:addThread():start(function()
ui.resetEverything(ui) resetEverything(ui)
end) end)
end end
--- @param ui Ui
local function resetEverything(ui)
sleep(2)
ui.pin = ""
ui.pinLabel:setText("")
redstone.setOutput("front", false)
ui.enterButton:setBackground(colors.blue)
end
--- @param ui Ui --- @param ui Ui
local function addToPin(ui, i) local function addToPin(ui, i)
@ -71,9 +71,6 @@ end
function mod.InitUi() function mod.InitUi()
local ui = { local ui = {
resetEverything,
unlockDoor,
addToPin,
pin = "", pin = "",
main = basalt.addMonitor(), main = basalt.addMonitor(),
} }