Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local S_DOOR_CLOSE_VALUE = "Close"
- local S_DOOR_OPEN_VALUE = "Open"
- local S_TP_WALL_UP_VALUE = "up"
- local S_TP_WALL_DOWN_VALUE = "down"
- local S_NETHER_OPEN_VALUE = "Open"
- local S_NETHER_CLOSED_VALUE = "Close"
- local S_ALARM_ON_VALUE = "on"
- local S_ALARM_OFF_VALUE = "off"
- local S_MONITOR_ON_VALUE = "on"
- local S_MONITOR_OFF_VALUE = "off"
- local versionNumber = "1.0"
- local loadingChars = {"/","|","\\","-"}
- local loadingPos = {x = 0, y = 0,active = false}
- local inputChar = "q"
- local consoleWidth, consoleHeight = term.getSize()
- consoleWidth, consoleHeight = consoleWidth - 1, consoleHeight - 1
- local consoleWidthCentre = math.floor(consoleWidth * 0.5) + 2
- local consoleHeightCentre = math.floor(consoleHeight * 0.5)
- local sSaveFile = "roomProperties.txt"
- local sDoorStatus = ""
- local sTeleportStatus = ""
- local sPortalStatus = ""
- local sAlarmStatus = ""
- local sMonitorStatus = ""
- local refreshTimer = nil
- local fastRender = false
- local tDoorControls = {}
- tDoorControls.iMoveOut = colors.lightBlue
- tDoorControls.iMoveIn = colors.white
- tDoorControls.iOpen = colors.green
- tDoorControls.iClose = colors.lime
- tDoorControls.iInput = colors.red
- tDoorControls.iAlarm = colors.orange
- tDoorControls.timer = nil
- local tTeleportControls = {}
- tTeleportControls.iWallUp = colors.black
- tTeleportControls.iWallDown = colors.brown
- tTeleportControls.iTeleport = colors.blue
- tTeleportControls.iAlarm = colors.gray
- local tPortalControls = {}
- tPortalControls.iUp = colors.pink
- tPortalControls.iDown = colors.cyan
- tPortalControls.iIgnite = colors.yellow
- local tPeripherals = sensors.getPeripherals()
- local pMonitor = nil
- local nMonWidth = nil
- local nMonHeight = nil
- local nMonHalfW = nil
- local nMonHalfH = nil
- if tPeripherals.monitor then
- pMonitor = peripheral.wrap(tPeripherals.monitor)
- pMonitor.setTextScale(4)
- nMonWidth, nMonHeight = pMonitor.getSize()
- nMonHalfW = nMonWidth * 0.5
- nMonHalfH = nMonHeight * 0.5
- end
- local mode = 0
- local debugMode = false
- --Utility functions-\/-----------------------------------------------------------------------------
- function slowWriteAt(x,y,str)
- term.setCursorPos(x ,y)
- textutils.slowWrite(str,60)
- end
- function drawAllBoxes(boxes)
- for i, v in ipairs(boxes) do
- v:draw()
- end
- end
- function writeAllText(texts, slow)
- for i, v in ipairs(texts) do
- if not slow then
- v:write()
- else
- v:slowWrite()
- end
- end
- end
- function pulseOutput(sColour, n)
- for i = 1, n do
- rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), sColour))
- sleep(0.45)
- rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), sColour))
- sleep(0.45)
- end
- end
- function showLoading()
- local i = 1
- if loadingPos.active then
- error("Something is already loading")
- end
- loadingPos.active = true
- if loadingPos.x < 1 or loadingPos.y < 1 then
- error("loadingPos not set")
- end
- repeat
- term.setCursorPos(loadingPos.x, loadingPos.y)
- print(loadingChars[i])
- i = (i < #loadingChars) and i + 1 or 1
- sleep(0.2)
- until not loadingPos.active
- term.setCursorPos(loadingPos.x, loadingPos.y)
- print(" ")
- loadingPos.x, loadingPos.y = 0, 0
- end
- function stopLoading()
- loadingPos.active = false
- end
- function debug(val)
- if debugMode then
- oldx, oldy = term.getCursorPos()
- term.setCursorPos(6, consoleHeight)
- print(val)
- sleep(3)
- term.setCursorPos(oldx, oldy)
- end
- end
- --Utility functions-/\-----------------------------------------------------------------------------
- --Class constructors-\/----------------------------------------------------------------------------
- function newBox(x, y, width, height)
- --creates a box with drawing and erasing methods
- local function drawBox(box)
- --renders a box onscreen at correct location and size, accepts box "class" as argument
- local hChar = "|"
- local vChar = "-"
- local cornerChar = "O"
- local currentChar = ""
- if not box.x or not box.y or not box.width or not box.height then
- --exit without attempting to render the box
- return 0
- end
- --print("y is "..y)
- for i = box.x, x + box.width do
- if i == x or i == x + width then
- currentChar = cornerChar
- else
- currentChar = vChar
- end
- sensorsUI.writeAt(i, y, currentChar)
- sensorsUI.writeAt(i, y + height, currentChar)
- end
- for i = y + 1, y + box.height - 1 do
- currentChar = hChar
- sensorsUI.writeAt(x, i, currentChar)
- sensorsUI.writeAt(x + width, i, currentChar)
- end
- end
- local function eraseBox(box)
- --clears the area that box sits in. Can be used to create a box in negative space
- if not box.x or not box.y or not box.width or not box.height then
- --exit without attempting to render the box
- return 0
- end
- for i = box.x, x + box.width do
- sensorsUI.writeAt(i, y, "")
- sensorsUI.writeAt(i, y + height, "")
- end
- for i = y + 1, y + box.hight - 1 do
- sensorsUI.writeAt(x, i, "")
- sensorsUI.writeAt(x + width, i, "")
- end
- end
- local box = {x = x, y = y, width = width, height = height, draw = drawBox, erase = eraseBox}
- return box
- end
- function newText(string, x, y, alignment, renderImmediate)
- local function renderText(text)
- --renders text onscreen at correct alignment, accepts text "class" as argument
- text.alignment = text.alignment or "left"
- if text.alignment == "left" then
- sensorsUI.writeAt(text.x,text.y,text.string)
- elseif alignment == "centre" then
- sensorsUI.writeAt(text.x - #text.string * 0.5, text.y, text.string)
- elseif alignment == "right" then
- sensorsUI.writeAt(text.x - #text.string, text.y, text.string)
- else
- error(text.alignment..' alignment for string "'..text.string..'" is not a valid alignment')
- end
- end
- local function slowRenderText(text)
- --slow renders text onscreen at correct alignment, accepts text "class" as argument
- text.alignment = text.alignment or "left"
- if text.alignment == "left" then
- slowWriteAt(text.x,text.y,text.string)
- elseif alignment == "centre" then
- slowWriteAt(text.x - #text.string * 0.5, text.y, text.string)
- elseif alignment == "right" then
- slowWriteAt(text.x - #text.string, text.y, text.string)
- else
- error(text.alignment..' alignment for string "'..text.string..'" is not a valid alignment')
- end
- end
- local function deleteText(text)
- text.alignment = text.alignment or "left"
- text.string = string.rep(" ", #text.string)
- if text.alignment == "left" then
- sensorsUI.writeAt(text.x,text.y,text.string)
- elseif alignment == "centre" then
- sensorsUI.writeAt(text.x - #text.string * 0.5, text.y, text.string)
- elseif alignment == "right" then
- sensorsUI.writeAt(text.x - #text.string, text.y, text.string)
- else
- error(text.alignment..' alignment for string "'..text.string..'" is not a valid alignment')
- end
- end
- local function slowDeleteText(text)
- text.alignment = text.alignment or "left"
- text.string = string.rep(" ", #text.string)
- if text.alignment == "left" then
- slowWriteAt(text.x,text.y,text.string)
- elseif alignment == "centre" then
- slowWriteAt(text.x - #text.string * 0.5, text.y, text.string)
- elseif alignment == "right" then
- slowWriteAt(text.x - #text.string, text.y, text.string)
- else
- error(text.alignment..' alignment for string "'..text.string..'" is not a valid alignment')
- end
- end
- local function getLength(text)
- return #text.string
- end
- renderImmediate = renderImmediate or "false"
- local text = {}
- text.alignment = alignment or "left"
- text.string = string or "blank"
- text.x = x or 1
- text.y = y or 1
- text.write = renderText
- text.slowWrite = slowRenderText
- text.delete = deleteText
- text.slowDelete = slowDeleteText
- text.length = getLength
- if renderImmediate == "now" then
- text:write()
- elseif renderImmediate == "slow" then
- text:slowWrite()
- end
- return text
- end
- --Class constructors-/\----------------------------------------------------------------------------
- local tConsStringsStatic = {}
- tConsStringsStatic[1] = newText("Teleportation Controls Room", consoleWidthCentre, 2, "centre")
- tConsStringsStatic[2] = newText("version "..versionNumber, consoleWidthCentre, tConsStringsStatic[1].y + 1, "centre")
- --boxes that need to be rendered evert tick
- local tConsoleBoxes = {}
- tConsoleBoxes[1] = newBox(1, 1, consoleWidth, consoleHeight)
- tConsoleBoxes[2] = newBox(1, 4, consoleWidth, consoleHeight - 5)
- tConsoleBoxes[3] = newBox((consoleWidthCentre - #tConsStringsStatic[1].string * 0.5) - 2, 1, #tConsStringsStatic[1].string + 3, 3)
- local sSensorSide = nil
- local sSensorName = nil
- local sProbe = nil
- local sTarget = nil
- if sensors then
- sSensorSide = sensors.getController()
- sSensorName = sensors.getSensors(sSensorSide)[1]
- sProbe = sensors.getProbes(sSensorSide, sSensorName)[3]
- sTarget = sensors.getAvailableTargetsforProbe(sSensorSide,sSensorName,sProbe)[1]
- end
- local inputText = newText("Input Choice> ",2,consoleHeight, "left")
- function main()
- repeat
- renderOptions()
- local inputType, input = getInput()
- local exitLoop = false
- --assert(false)
- fastRender = false
- term.clear()
- drawAllBoxes(tConsoleBoxes)
- writeAllText(tConsStringsStatic)
- if inputType == "redstone" then
- if colors.test(rs.getBundledInput("bottom"), tDoorControls.iInput) then
- toggleDoor()
- end
- elseif inputType == "timer" then
- if input == tDoorControls.timer then
- toggleDoor()
- elseif input == refreshTimer then
- fastRender = true
- end
- else
- if mode == 0 then
- if input == "1" then
- toggleDoor()
- --pcall(toggleDoor)
- elseif input == "2" then
- teleportSequence()
- --pcall(teleportSequence)
- elseif input == "3" then
- togglePortal()
- elseif input == "4" then
- end
- else
- if input == "1" then
- elseif input == "2" then
- elseif input == "3" then
- elseif input == "4" then
- end
- end
- end
- until exitLoop
- end
- function renderOptions()
- term.clear()
- local doorOption = (sDoorStatus == S_DOOR_OPEN_VALUE) and S_DOOR_CLOSE_VALUE or S_DOOR_OPEN_VALUE
- local portalOption = (sPortalStatus == S_NETHER_OPEN_VALUE and S_NETHER_CLOSED_VALUE) or S_NETHER_OPEN_VALUE
- writeAllText(tConsStringsStatic)
- drawAllBoxes(tConsoleBoxes)
- --writeAllText(tConsStringsStatic)
- if mode == 0 then
- local rightMargin = 5
- local longestStr = 0
- local optionsText = {}
- optionsText.doorText = doorOption.." Security Doors:"
- optionsText.teleportText = "Begin Teleport Sequence:"
- optionsText.portalText = portalOption.." Nether Portal:"
- optionsText.manualText = "Manual System Controls:"
- optionsText.shutDownText = "Reset System"
- for k, v in pairs(optionsText) do
- longestStr = (longestStr < #v) and #v or longestStr
- end
- longestStr = longestStr + 5
- local options = {}
- local textX = math.floor(consoleWidthCentre - longestStr * 0.5) - rightMargin
- options[1] = newText("Options", consoleWidthCentre - rightMargin, 6, "centre")
- options[2] = newText(optionsText.doorText, textX, 8, "left")
- options[3] = newText("1", textX + longestStr, 8, "left")
- options[4] = newText(optionsText.teleportText, textX, 9, "left")
- options[5] = newText("2", textX + longestStr, 9, "left")
- options[6] = newText(optionsText.portalText, textX, 10, "left")
- options[7] = newText("3", textX + longestStr, 10, "left")
- --options[8] = newText(optionsText.manualText, textX, 11, "left")
- --options[9] = newText("4", textX + longestStr, 11, "left")
- options[8] = newText(optionsText.shutDownText, textX, 13, "left")
- options[9] = newText("4", textX + longestStr, 13, "left")
- local optionsBox = newBox(textX - 2, 5, longestStr + 4, 2)
- if sensorsUI then
- --We're interested in maxStorage and energy
- local tReadings = sensors.getSensorReadingAsDict(sSensorSide,sSensorName,sTarget,sProbe)
- sensorsUI.vBar(textX + longestStr + 6,consoleHeight - 2,consoleHeight - 9,"Power",tReadings.energy,tReadings.maxStorage)
- drawAllBoxes(tConsoleBoxes)
- local barBox = newBox(consoleWidth - 9, 4, 10, consoleHeight - 5)
- barBox:draw()
- end
- optionsBox:draw()
- writeAllText(options, not (debugMode or fastRender))
- else
- --Support for a different mode goes here.
- end
- end
- function renderCountdown(n)
- if sMonitorStatus == S_MONITOR_ON_VALUE and pMonitor then
- term.redirect(pMonitor)
- sensorsUI.writeAt(1,1,tostring(n))
- term.restore()
- end
- end
- function getInput()
- --ask for input
- if not fastRender then
- inputText:slowWrite()
- end
- inputText:write()
- local e, key = nil, nil
- refreshTimer = os.startTimer(1)
- repeat
- e, key = os.pullEvent()
- until e == "redstone" or e == "char" or key == tDoorControls.timer or key == refreshTimer
- if e == "char" then
- term.write(" "..key)
- sleep(0.7)
- end
- return e, key
- end
- function writeStatus()
- --save statuses
- local hWrite = fs.open(sSaveFile, "w")
- hWrite.write(sDoorStatus.."\n")
- hWrite.write(sTeleportStatus.."\n")
- hWrite.write(sPortalStatus.."\n")
- hWrite.write(sAlarmStatus.."\n")
- hWrite.write(sMonitorStatus.."\n")
- hWrite.close()
- end
- function resetSystem()
- newText("Resetting system ", 6, y, "left", "slow")
- end
- function resetEverything()
- if sPortalStatus == S_NETHER_OPEN_VALUE then
- setOutput(tTeleportControls.iAlarm, true)
- setOutput(tPortalControls.iIgnite, false)
- closePortal()
- setOutput(tTeleportControls.iAlarm, false)
- sPortalStatus = S_NETHER_CLOSED_VALUE
- end
- if sDoorStatus == S_DOOR_OPEN_VALUE then
- setOutput(tDoorControls.iAlarm, true)
- closeDoor()
- setOutput(tDoorControls.iAlarm, false)
- end
- os.reboot()
- end
- function toggleDoor()
- if sDoorStatus == S_DOOR_OPEN_VALUE then
- closeDoorSequence()
- else
- --Check if Nether Portal is open, if so, quickly close it.
- if sPortalStatus == S_NETHER_OPEN_VALUE then
- setOutput(tTeleportControls.iAlarm, true)
- setOutput(tPortalControls.iIgnite, false)
- closePortal()
- setOutput(tTeleportControls.iAlarm, false)
- sPortalStatus = S_NETHER_CLOSED_VALUE
- end
- openDoorSequence()
- end
- writeStatus()
- end
- function openDoorSequence()
- debug("in openDoor")
- setOutput(tDoorControls.iAlarm, true)
- sAlarmStatus = S_ALARM_ON_VALUE
- sleep(0.5)
- local y = 6
- local openingText = newText("Opening Door ", 6, y, "left", "slow")
- loadingPos.x, loadingPos.y = term.getCursorPos()
- parallel.waitForAll(showLoading, openDoor)
- sleep(0.5)
- setOutput(tDoorControls.iAlarm, false)
- sAlarmStatus = S_ALARM_OFF_VALUE
- openingText:slowDelete()
- openingText = newText("Door Open", 6, y, "left", "slow")
- sleep(0.5)
- openingText:slowDelete()
- sDoorStatus = S_DOOR_OPEN_VALUE
- sleep(1)
- fastRender = true
- end
- function closeDoorSequence()
- setOutput(tDoorControls.iAlarm, true)
- sAlarmStatus = S_ALARM_ON_VALUE
- sleep(0.5)
- local openingText = newText("Closing Door ", 3, 6, "left", "slow")
- loadingPos.x, loadingPos.y = term.getCursorPos()
- parallel.waitForAll(showLoading, closeDoor)
- sleep(0.5)
- setOutput(tDoorControls.iAlarm, false)
- sAlarmStatus = S_ALARM_OFF_VALUE
- openingText:slowDelete()
- openingText = newText("Door Closed", 3, 6, "left", "slow")
- sleep(0.5)
- openingText:slowDelete()
- sDoorStatus = S_DOOR_CLOSE_VALUE
- sleep(1)
- end
- function openDoor()
- fDelay = 20
- pulseOutput(tDoorControls.iMoveOut,1)
- sleep(0.4)
- pulseOutput(tDoorControls.iOpen, 4)
- sDoorStatus = S_DOOR_OPEN_VALUE
- writeStatus()
- stopLoading()
- if fDelay then
- tDoorControls.timer = os.startTimer(fDelay)
- end
- end
- function closeDoor()
- tDoorControls.timer = nil
- pulseOutput(tDoorControls.iClose, 4)
- sleep(0.4)
- pulseOutput(tDoorControls.iMoveIn, 1)
- sDoorStatus = S_DOOR_CLOSE_VALUE
- writeStatus()
- stopLoading()
- end
- function teleportSequence()
- local y = 6
- local guardText = ""
- local keptText = {}
- if sDoorStatus ~= S_DOOR_CLOSE_VALUE then
- closeDoorSequence()
- end
- if sPortalStatus ~= S_NETHER_CLOSED_VALUE then
- closePortalSequence()
- end
- setOutput(tTeleportControls.iAlarm, true)
- sTPAlarmStatus = S_ALARM_ON_VALUE
- sleep(0.5)
- guardText = newText("Closing Teleport Chamber in "..5, 3, y, "left", "slow")
- renderCountdown(5)
- for i = 5, 0, -1 do
- guardText = newText("Closing Teleport Chamber in "..i, 3, y, "left", "now")
- pMonitor.clear()
- renderCountdown(i)
- sleep(1)
- end
- pMonitor.clear()
- guardText:slowDelete()
- guardText = newText("Closing Teleport Chamber ", 3, y, "left", "slow")
- loadingPos.x, loadingPos.y = term.getCursorPos()
- parallel.waitForAll(showLoading, closeTeleport)
- sleep(0.5)
- setOutput(tTeleportControls.iAlarm, false)
- sTPAlarmStatus = S_ALARM_OFF_VALUE
- guardText:slowDelete()
- keptText[1] = newText("Teleport Chamber Closed", 3, y, "left", "slow")
- sTeleportStatus = S_TP_WALL_UP_VALUE
- --updatesave save file
- writeStatus()
- sleep(1)
- y = y + 2
- guardText = newText("Teleporting Target in "..3, 3, y, "left", "slow")
- renderCountdown(3)
- for i = 3, 0, -1 do
- guardText = newText("Teleporting Target in "..i, 3, y, "left", "now")
- pMonitor.clear()
- renderCountdown(i)
- sleep(1)
- end
- pMonitor.clear()
- activateTeleport()
- guardText:slowDelete()
- keptText[2] = newText("Target Teleported", 3, y, "left", "slow")
- sleep(1)
- y = y + 2
- setOutput(tTeleportControls.iAlarm, true)
- sTPAlarmStatus = S_ALARM_ON_VALUE
- guardText = newText("Opening Teleport Chamber ", 3, y, "left", "slow")
- loadingPos.x, loadingPos.y = term.getCursorPos()
- parallel.waitForAll(showLoading, openTeleport)
- sleep(0.5)
- setOutput(tTeleportControls.iAlarm, false)
- sTPAlarmStatus = S_ALARM_OFF_VALUE
- guardText:slowDelete()
- keptText[3] = newText("Teleport Chamber Open", 3, y, "left" ,"slow")
- sTeleportStatus = S_TP_WALL_DOWN_VALUE
- --updatesave save file
- writeStatus()
- sleep(0.5)
- for i = 1, #keptText do
- keptText[i]:slowDelete()
- end
- end
- function openTeleport()
- pulseOutput(tTeleportControls.iWallDown, 4)
- sTeleportStatus = S_TP_WALL_DOWN_VALUE
- writeStatus()
- stopLoading()
- end
- function closeTeleport()
- pulseOutput(tTeleportControls.iWallUp, 4)
- sTeleportStatus = S_TP_WALL_UP_VALUE
- writeStatus()
- stopLoading()
- end
- function togglePortal()
- if sPortalStatus == S_NETHER_OPEN_VALUE then
- closePortalSequence()
- else
- openPortalSequence()
- end
- writeStatus()
- end
- function openPortalSequence()
- local y = 6
- local guardText = ""
- local keptText = {}
- if sDoorStatus ~= S_DOOR_CLOSE_VALUE then
- closeDoorSequence()
- end
- setOutput(tTeleportControls.iAlarm, true)
- sTPAlarmStatus = S_ALARM_ON_VALUE
- sleep(0.5)
- guardText = newText("Raising Nether Portal in "..5, 3, y, "left", "slow")
- renderCountdown(5)
- for i = 5, 0, -1 do
- guardText = newText("Raising Nether Portal in "..i, 3, y, "left", "now")
- pMonitor.clear()
- renderCountdown(i)
- sleep(1)
- end
- pMonitor.clear()
- guardText:slowDelete()
- guardText = newText("Nether Portal Raising ", 3, y, "left", "slow")
- loadingPos.x, loadingPos.y = term.getCursorPos()
- parallel.waitForAll(showLoading, openPortal)
- sleep(0.5)
- setOutput(tTeleportControls.iAlarm, false)
- sTPAlarmStatus = S_ALARM_OFF_VALUE
- guardText:slowDelete()
- keptText[1] = newText("Nether Portal Raised", 3, y, "left", "slow")
- sPortalStatus = S_NETHER_OPEN_VALUE
- --updatesave save file
- writeStatus()
- sleep(1)
- y = y + 2
- guardText = newText("Attempting to Ignite Portal in "..3, 3, y, "left", "slow")
- renderCountdown(3)
- for i = 3, 0, -1 do
- guardText = newText("Attempting to Ignite Portal in "..i, 3, y, "left", "now")
- pMonitor.clear()
- renderCountdown(i)
- sleep(1)
- end
- pMonitor.clear()
- guardText:slowDelete()
- setOutput(tPortalControls.iIgnite, true)
- keptText[2] = newText("Portal Ignited", 3, y, "left", "slow")
- sleep(1)
- for i = 1, #keptText do
- keptText[i]:slowDelete()
- end
- end
- function openPortal()
- pulseOutput(tPortalControls.iUp, 6)
- stopLoading()
- end
- function closePortalSequence()
- local y = 6
- local guardText = ""
- local keptText = {}
- if sDoorStatus ~= S_DOOR_CLOSE_VALUE then
- closeDoorSequence()
- end
- guardText = newText("Closing Portal in "..3, 3, y, "left", "slow")
- renderCountdown(3)
- for i = 3, 0, -1 do
- guardText = newText("Closing Portal in "..i, 3, y, "left", "now")
- pMonitor.clear()
- renderCountdown(i)
- sleep(1)
- end
- pMonitor.clear()
- setOutput(tPortalControls.iIgnite, false)
- guardText:slowDelete()
- keptText[1] = newText("Portal Closed", 3, y, "left", "slow")
- sleep(0.5)
- y = y + 2
- setOutput(tTeleportControls.iAlarm, true)
- sTPAlarmStatus = S_ALARM_ON_VALUE
- sleep(1)
- guardText = newText("Lowering Nether Portal in "..5, 3, y, "left", "slow")
- renderCountdown(5)
- for i = 5, 0, -1 do
- guardText = newText("Lowering Nether Portal in "..i, 3, y, "left", "now")
- pMonitor.clear()
- renderCountdown(i)
- sleep(1)
- end
- pMonitor.clear()
- guardText:slowDelete()
- guardText = newText("Nether Portal Lowering ", 3, y, "left", "slow")
- loadingPos.x, loadingPos.y = term.getCursorPos()
- parallel.waitForAll(showLoading, closePortal)
- sleep(1)
- setOutput(tTeleportControls.iAlarm, false)
- sTPAlarmStatus = S_ALARM_OFF_VALUE
- guardText:slowDelete()
- keptText[2] = newText("Nether Portal Lowered", 3, y, "left", "slow")
- sPortalStatus = S_NETHER_CLOSED_VALUE
- --updatesave save file
- writeStatus()
- sleep(1)
- for i = 1, #keptText do
- keptText[i]:slowDelete()
- end
- end
- function closePortal()
- pulseOutput(tPortalControls.iDown, 6)
- stopLoading()
- end
- function activateTeleport()
- pulseOutput(tTeleportControls.iTeleport, 1)
- end
- function setOutput(colour, bool)
- if bool then
- rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colour))
- else
- rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colour))
- end
- end
- function toMonitor(startX, startY, sString)
- end
- if fs.exists(sSaveFile) then
- --Check to see if save file exists and open it to save out all of the current saved statuses
- local hRead = assert(fs.open(sSaveFile, "r")) --Will crash the program if the file cannot be opened
- sDoorStatus = hRead.readLine()
- sTeleportStatus = hRead.readLine()
- sPortalStatus = hRead.readLine()
- sAlarmStatus = hRead.readLine()
- sMonitorStatus = hRead.readLine()
- sTPAlarmStatus = hRead.readLine()
- hRead.close()
- if sDoorStatus == S_DOOR_OPEN_VALUE then
- tDoorControls.timer = os.startTimer(20)
- end
- else
- --set everything to the default values if there is no save file
- sDoorStatus = S_DOOR_CLOSE_VALUE
- sTeleportStatus = S_TP_WALL_DOWN_VALUE
- sPortalStatus = S_NETHER_CLOSED_VALUE
- sAlarmStatus = S_ALARM_OFF_VALUE
- sMonitorStatus = S_MONITOR_ON_VALUE
- sTPAlarmStatus = S_ALARM_OFF_VALUE
- closeDoor()
- openTeleport()
- --closePortal()
- --deactivatePortal()
- setOutput(tTeleportControls.iAlarm, false)
- writeStatus()
- end
- --run the program
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement