Added hazard gate prompt

This commit is contained in:
2026-01-02 17:05:55 -05:00
parent 53db2eadf9
commit ab238e7c0b
2 changed files with 70 additions and 10 deletions

View File

@ -538,19 +538,71 @@ local function dialGate(address)
end
end
local function selectGateFromList()
local function selectGateFromList(isHazardGate)
local state = getState()
local selecting = true
while dialing == false and selecting == true do
selx, sely = GetClick()
local buttonXY, computerAddresses, computerNames = display.getButtonData()
local buttonXY, computerAddresses, computerNames, hazardReasons = display.getButtonData()
for i = 1, #buttonXY do
if (sely == buttonXY[i][3]) and ((selx >= buttonXY[i][1]) and (selx <= buttonXY[i][2])) then
dialGate(computerAddresses[i])
state.destAddressname = computerNames[i]
state.destAddress = computerAddresses[i]
dialing = true
local shouldDial = true
-- If this is a hazard gate, show confirmation prompt
if isHazardGate and hazardReasons and hazardReasons[i] then
mon.setBackgroundColor(colors.black)
mon.clear()
mon.setBackgroundColor(colors.red)
mon.setTextScale(1)
mon.setCursorPos(5, 5)
mon.write("WARNING: HAZARD GATE")
mon.setBackgroundColor(colors.black)
mon.setCursorPos(2, 8)
mon.write("Destination:")
mon.setCursorPos(2, 9)
mon.write(computerNames[i])
mon.setCursorPos(2, 11)
mon.write("Hazard:")
mon.setCursorPos(2, 12)
mon.write(hazardReasons[i])
mon.setCursorPos(2, 15)
mon.write("Proceed with dialing?")
-- Draw YES and NO buttons
mon.setBackgroundColor(colors.green)
mon.setCursorPos(5, 17)
mon.write(" YES ")
mon.setBackgroundColor(colors.red)
mon.setCursorPos(18, 17)
mon.write(" NO ")
-- Wait for confirmation
local confirmed = false
while true do
local cx, cy = GetClick()
if cy == 17 then
if cx >= 5 and cx <= 10 then
-- YES clicked
confirmed = true
break
elseif cx >= 18 and cx <= 22 then
-- NO clicked
break
end
end
end
shouldDial = confirmed
end
if shouldDial then
dialGate(computerAddresses[i])
state.destAddressname = computerNames[i]
state.destAddress = computerAddresses[i]
dialing = true
end
sely = 0
selx = 0
break
@ -586,7 +638,7 @@ local function selectCategory()
mon.setBackgroundColor(colors.purple)
count, y = display.screenWrite(addresses.MainGates, count, y)
local returnstate = selectGateFromList()
local returnstate = selectGateFromList(false)
if returnstate == true then
state = false
end
@ -604,7 +656,7 @@ local function selectCategory()
mon.setBackgroundColor(colors.green)
count, y = display.screenWrite(addresses.playerGates, count, y)
local returnstate = selectGateFromList()
local returnstate = selectGateFromList(false)
if returnstate == true then
state = false
end
@ -622,7 +674,7 @@ local function selectCategory()
mon.setBackgroundColor(colors.red)
count, y = display.screenWrite(addresses.hazardGates, count, y)
local returnstate = selectGateFromList()
local returnstate = selectGateFromList(true)
if returnstate == true then
state = false
end