Guest User

Untitled

a guest
Jan 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. -- Configuration
  2. -- Strings and Variables
  3. local sDoorStatus = ""
  4. local sModem = "top"
  5. local sCastleName = "Temporary"
  6. local cID = 279
  7. local oldPull = os.pullEvent
  8. os.pullEvent = os.pullEventRaw
  9.  
  10. -- Do not edit from here
  11.  
  12. -- Functions
  13.  
  14. local function menu(...)
  15. local sel = 1
  16. local list = {...}
  17. local offX,offY = term.getCursorPos()
  18. local curX,curY = term.getCursorPos()
  19. while true do
  20. if sel > #list then sel = 1 end
  21. if sel < 1 then sel = #list end
  22. for i = 1,#list do
  23. term.setCursorPos(offX,offY+i-1)
  24. if sel == i then
  25. print("["..list[i].."]") -- very customisible example print(">"..list[i])
  26. else
  27. print(" "..list[i].." ") -- very customisible
  28. end
  29. end
  30. while true do
  31. local e,e1,e2,e3,e4,e5 = os.pullEvent()
  32. if e == "key" then
  33. if e1 == 200 then -- up key
  34. sel = sel-1
  35. break
  36. end
  37. if e1 == 208 then -- down key
  38. sel = sel+1
  39. break
  40. end
  41. if e1 == 28 then
  42. term.setCursorPos(curX,curY)
  43. return list[sel],sel
  44. end
  45. end
  46. end
  47. end
  48. end
  49.  
  50.  
  51. function clearPrint(s, o, x, y)
  52. if not x or x < 0 then x = 1 end
  53. if not y or y < 0 then y = 1 end
  54. term.clear()
  55. term.setCursorPos(x,y)
  56. o(s)
  57. end
  58.  
  59. function Open()
  60. sDoorStatus = "open"
  61. rednet.send(cID, sDoorStatus)
  62. print("\n\n\nSent command to "..sDoorStatus.." doors to computer with ID: "..cID)
  63. rednet.close(sModem)
  64. sleep(6)
  65. begin()
  66. end
  67.  
  68. function Close()
  69. sDoorStatus = "close"
  70. rednet.send(cID, sDoorStatus)
  71. print("\n\n\nSent command to "..sDoorStatus.." doors to computer with ID: "..cID..".\n")
  72. print("Please wait...")
  73. rednet.close(sModem)
  74. sleep(6)
  75. begin()
  76. end
  77.  
  78. function begin()
  79. term.clear()
  80. term.setCursorPos(1,1)
  81. local selection = ""
  82. sDoorStatus = ""
  83. rednet.open(sModem)
  84. clearPrint("This is only temporary system!", print)
  85. print("\nSelect an option:")
  86. local selection = menu(
  87. " Open ",
  88. " Close ")
  89. if selection == " Open " then
  90. Open()
  91. elseif selection == " Close " then
  92. Close()
  93. elseif selection == " Exit " then
  94. Exit()
  95. end
  96. end
  97.  
  98. begin()
Add Comment
Please, Sign In to add comment