Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Configuration
- -- Strings and Variables
- local sDoorStatus = ""
- local sModem = "top"
- local sCastleName = "Temporary"
- local cID = 279
- local oldPull = os.pullEvent
- os.pullEvent = os.pullEventRaw
- -- Do not edit from here
- -- Functions
- local function menu(...)
- local sel = 1
- local list = {...}
- local offX,offY = term.getCursorPos()
- local curX,curY = term.getCursorPos()
- while true do
- if sel > #list then sel = 1 end
- if sel < 1 then sel = #list end
- for i = 1,#list do
- term.setCursorPos(offX,offY+i-1)
- if sel == i then
- print("["..list[i].."]") -- very customisible example print(">"..list[i])
- else
- print(" "..list[i].." ") -- very customisible
- end
- end
- while true do
- local e,e1,e2,e3,e4,e5 = os.pullEvent()
- if e == "key" then
- if e1 == 200 then -- up key
- sel = sel-1
- break
- end
- if e1 == 208 then -- down key
- sel = sel+1
- break
- end
- if e1 == 28 then
- term.setCursorPos(curX,curY)
- return list[sel],sel
- end
- end
- end
- end
- end
- function clearPrint(s, o, x, y)
- if not x or x < 0 then x = 1 end
- if not y or y < 0 then y = 1 end
- term.clear()
- term.setCursorPos(x,y)
- o(s)
- end
- function Open()
- sDoorStatus = "open"
- rednet.send(cID, sDoorStatus)
- print("\n\n\nSent command to "..sDoorStatus.." doors to computer with ID: "..cID)
- rednet.close(sModem)
- sleep(6)
- begin()
- end
- function Close()
- sDoorStatus = "close"
- rednet.send(cID, sDoorStatus)
- print("\n\n\nSent command to "..sDoorStatus.." doors to computer with ID: "..cID..".\n")
- print("Please wait...")
- rednet.close(sModem)
- sleep(6)
- begin()
- end
- function begin()
- term.clear()
- term.setCursorPos(1,1)
- local selection = ""
- sDoorStatus = ""
- rednet.open(sModem)
- clearPrint("This is only temporary system!", print)
- print("\nSelect an option:")
- local selection = menu(
- " Open ",
- " Close ")
- if selection == " Open " then
- Open()
- elseif selection == " Close " then
- Close()
- elseif selection == " Exit " then
- Exit()
- end
- end
- begin()
Add Comment
Please, Sign In to add comment