Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("left")
- local selection = 1
- local function cPrint(height, string)
- local w,h = term.getSize()
- xPos = w/2 - string.len(string)/2
- term.setCursorPos(xPos, height)
- term.write(string)
- end
- local function printDoorMenu()
- if selection == 1 then cPrint(6, ">> Open")
- else cPrint(6, " Open") end
- if selection == 2 then cPrint(7, ">> Close")
- else cPritn(7, " Close") end
- if selection == 3 then cPrint(8, ">> Exit")
- else cPrint(8, " Exit") end
- end
- while true do
- term.clear()
- term.setCursorPos(1,1)
- pritnDoorMenu()
- event, key = os.pullEvent("key")
- if key == 200 and selection > 1 then selection = selection-1
- else if key == 208 and selection < 3 then selection = selection+1
- end
- if selection == 1 and key == 28 then
- rednet.send(174, "open")
- rednet.send(173, "open")
- cPrint(10, "Door Opened.")
- sleep(2)
- elseif selection == 2 and key == 28 then
- rednet.send(174, "close")
- rednet.send(173, "close")
- cPrint(10, "Door Closed.")
- sleep(2)
- elseif selection == 3 and key == 28 then
- os.reboot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment