Added hazard gate prompt

This commit is contained in:
2026-01-02 17:05:55 -05:00
parent 53db2eadf9
commit f5657a1799
3 changed files with 73 additions and 13 deletions

View File

@ -19,8 +19,7 @@ addresses.MainGates = {
{ "Unitas", { 2, 27, 8, 34, 24, 15, 0 } }, { "Unitas", { 2, 27, 8, 34, 24, 15, 0 } },
{ "Lantea", { 18, 20, 1, 15, 14, 7, 19, 0 } }, { "Lantea", { 18, 20, 1, 15, 14, 7, 19, 0 } },
{ "Rima", { 33, 20, 10, 22, 3, 17, 0 } }, { "Rima", { 33, 20, 10, 22, 3, 17, 0 } },
{ "Athos", { 18, 21, 14, 24, 1, 26, 28, 0 } }, { "Athos", { 18, 21, 14, 24, 1, 26, 28, 0 } }
{ "Moon", { 33, 11, 17, 27, 12, 13, 3, 24, 0 } }
} }
--------------------------------------------- ---------------------------------------------
@ -42,7 +41,8 @@ addresses.playerGates = {
-- Dangerous destinations -- Dangerous destinations
addresses.hazardGates = { addresses.hazardGates = {
{ "Cavum Tenebrae", { 18, 7, 3, 36, 25, 15, 0 }, "Weird Gravity" } { "Cavum Tenebrae", { 18, 7, 3, 36, 25, 15, 0 }, "Weird Gravity" },
{ "Moon", { 33, 11, 17, 27, 12, 13, 3, 24, 0 }, "No Oxygen" }
} }
return addresses return addresses

View File

@ -16,6 +16,7 @@ local localGateAddress
local buttonXY = {} local buttonXY = {}
local computerAddresses = {} local computerAddresses = {}
local computerNames = {} local computerNames = {}
local hazardReasons = {}
local x, y = 0, 0 local x, y = 0, 0
function display.init(monitor, cfg, addr, utilsModule, localAddr) function display.init(monitor, cfg, addr, utilsModule, localAddr)
@ -27,13 +28,14 @@ function display.init(monitor, cfg, addr, utilsModule, localAddr)
end end
function display.getButtonData() function display.getButtonData()
return buttonXY, computerAddresses, computerNames return buttonXY, computerAddresses, computerNames, hazardReasons
end end
function display.clearButtonData() function display.clearButtonData()
buttonXY = {} buttonXY = {}
computerAddresses = {} computerAddresses = {}
computerNames = {} computerNames = {}
hazardReasons = {}
end end
--------------------------------------------- ---------------------------------------------
@ -116,6 +118,12 @@ function display.screenWrite(list, fcount, fy)
table.insert(buttonXY, { x1, x2, fy }) table.insert(buttonXY, { x1, x2, fy })
table.insert(computerNames, list[i][1]) table.insert(computerNames, list[i][1])
table.insert(computerAddresses, list[i][2]) table.insert(computerAddresses, list[i][2])
-- Store hazard reason if present (third element in hazard gates)
if list[i][3] then
table.insert(hazardReasons, list[i][3])
else
table.insert(hazardReasons, nil)
end
end end
end end

View File

@ -538,19 +538,71 @@ local function dialGate(address)
end end
end end
local function selectGateFromList() local function selectGateFromList(isHazardGate)
local state = getState() local state = getState()
local selecting = true local selecting = true
while dialing == false and selecting == true do while dialing == false and selecting == true do
selx, sely = GetClick() selx, sely = GetClick()
local buttonXY, computerAddresses, computerNames = display.getButtonData() local buttonXY, computerAddresses, computerNames, hazardReasons = display.getButtonData()
for i = 1, #buttonXY do for i = 1, #buttonXY do
if (sely == buttonXY[i][3]) and ((selx >= buttonXY[i][1]) and (selx <= buttonXY[i][2])) then if (sely == buttonXY[i][3]) and ((selx >= buttonXY[i][1]) and (selx <= buttonXY[i][2])) then
dialGate(computerAddresses[i]) local shouldDial = true
state.destAddressname = computerNames[i]
state.destAddress = computerAddresses[i] -- If this is a hazard gate, show confirmation prompt
dialing = true 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 (use direct os.pullEvent to bypass handlers)
local confirmed = false
while true do
local event, side, cx, cy = os.pullEvent("monitor_touch")
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 sely = 0
selx = 0 selx = 0
break break
@ -586,7 +638,7 @@ local function selectCategory()
mon.setBackgroundColor(colors.purple) mon.setBackgroundColor(colors.purple)
count, y = display.screenWrite(addresses.MainGates, count, y) count, y = display.screenWrite(addresses.MainGates, count, y)
local returnstate = selectGateFromList() local returnstate = selectGateFromList(false)
if returnstate == true then if returnstate == true then
state = false state = false
end end
@ -604,7 +656,7 @@ local function selectCategory()
mon.setBackgroundColor(colors.green) mon.setBackgroundColor(colors.green)
count, y = display.screenWrite(addresses.playerGates, count, y) count, y = display.screenWrite(addresses.playerGates, count, y)
local returnstate = selectGateFromList() local returnstate = selectGateFromList(false)
if returnstate == true then if returnstate == true then
state = false state = false
end end
@ -622,7 +674,7 @@ local function selectCategory()
mon.setBackgroundColor(colors.red) mon.setBackgroundColor(colors.red)
count, y = display.screenWrite(addresses.hazardGates, count, y) count, y = display.screenWrite(addresses.hazardGates, count, y)
local returnstate = selectGateFromList() local returnstate = selectGateFromList(true)
if returnstate == true then if returnstate == true then
state = false state = false
end end