:3
This commit is contained in:
parent
b3b0ab41b3
commit
2eb20cb6c5
21
keypadOS.lua
21
keypadOS.lua
|
@ -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(),
|
||||||
}
|
}
|
||||||
|
|
23
src/ui.lua
23
src/ui.lua
|
@ -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(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user