Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local side = "back" -- Change this to the side the transmitter is on
- -- DEFENSE SYSTEM
- -- Version: 1.4
- -- Code by: Nyaar
- local status = rs.getOutput(side)
- local loop = true
- local bRead = true
- local w,h = term.getSize()
- function printC(str, y)
- term.setCursorPos(1,y)
- term.clearLine()
- term.setCursorPos(w/2 - #str/2, y)
- term.write(str)
- end
- function printLB(str, y)
- term.setCursorPos(1, y)
- print(string.rep(str, w-1))
- end
- function logo(status)
- term.clear()
- term.setCursorPos(1,1)
- local sStatus = ""
- if (status == true) then
- printLB("=",1)
- print("| Defense System Status: Unarmed |")
- printLB("=",3)
- sStatus = "arm"
- else
- printLB("=",1)
- print("| Defense System Status: Armed |")
- printLB("=",3)
- sStatus = "disarm"
- end
- printC("Press ENTER to "..sStatus.." system.", 5)
- printC("Press BACKSPACE to quit.",6)
- end
- while (loop) do
- logo(status)
- bRead = true
- while (bRead) do
- local sEvent, param = os.pullEventRaw("key")
- if (sEvent == "key") then
- if (param == 28) then
- status = not status
- rs.setOutput(side,status)
- bRead = false
- elseif (param == 14) then
- bRead = false
- loop = false
- end
- end
- end
- end
- term.clear()
- term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment