Advertisement
DemonicArcher

RedPortal

Oct 13th, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.75 KB | None | 0 0
  1. --side of the computer the monitor is on
  2. monitorSide = "left"
  3. --side of the computer the modem is on
  4. modemSide = "right"
  5.  
  6. monitor = peripheral.wrap(monitorSide)
  7. wireless = peripheral.wrap(modemSide)
  8. modem = peripheral.wrap(modemSide)
  9.  
  10. local slot
  11. -- How long to keep the portal open
  12. local gateTime = 8
  13.  
  14. -- what kind of book is in the Turtle for a specific
  15. -- slot number, keep it under 10 charcters
  16. local slot1Name = "Resonant"
  17. local slot2Name = "Redstone"
  18. local slot3Name = "Iron"
  19. local slot4Name = "N. Quartz"
  20. local slot5Name = "Gold"
  21. local slot6Name = "Diamond"
  22. local slot7Name = "Mob Ess."
  23. local slot8Name = "Huge Trees"
  24.  
  25. local slot9Name = "Lava"
  26. local slot10Name = "Empty"
  27. local slot11Name = "Empty"
  28. local slot12Name = "Empty"
  29. local slot13Name = "Empty"
  30. local slot14Name = "Empty"
  31. local slot15Name = "Empty"
  32. local slot16Name = "Empty"
  33.  
  34. local slot17Name = "Empty"
  35. local slot18Name = "Empty"
  36. local slot19Name = "Empty"
  37. local slot20Name = "Empty"
  38. local slot21Name = "Empty"
  39. local slot22Name = "Empty"
  40.  
  41. local pagesNameUp = "+"
  42. local pagesNameDown = "-"
  43. local pages = 1
  44. channel = 1
  45.  
  46. if fs.exists("knob") ~= true then
  47. shell.run "pastebin get GjVKY7nL knob"
  48. end
  49. os.loadAPI("knob") -- loads a custom API
  50. -- get the custom API ( pastebin get GjVKY7nL knobs)
  51.  
  52.  
  53.  
  54. -- calls a book
  55. function sendSlot(slot)
  56. knob.display()
  57. modem.open(channel)
  58. modem.transmit(pages,pages,slot)
  59. modem.close(channel)
  60. sleep(gateTime)
  61. end
  62.  
  63. -- tell the Turtle how long to keep the gate open
  64. function keepOpen(gateTime)
  65. modem.open(2)
  66. modem.transmit(2,2,gateTime)
  67. end
  68.  
  69. function Page1Knobs()
  70. channel = 1
  71. -- Starts the monitor and sets up the basics
  72. knob.startUp(monitorSide,1,colors.black,colors.lime)
  73. knob.header("Select an Age")
  74. -- adds the knobs to the monitor
  75. -- function new(name,xMin,xMax,yMin,yMax,text,textColor,bgColor) adds a button
  76.  
  77. knob.newKnob("Slot1",2,12,5,7,slot1Name,string.upper(slot1Name),colors.black,colors.blue,colors.blue,colors.black)
  78. knob.newKnob("Slot2",2,12,9,11,slot2Name,string.upper(slot2Name),colors.black,colors.red,colors.red,colors.black)
  79. knob.newKnob("Slot3",14,24,5,7,slot3Name,string.upper(slot3Name),colors.black,colors.brown,colors.brown,colors.black)
  80. knob.newKnob("Slot4",14,24,9,11,slot4Name,string.upper(slot4Name),colors.black,colors.magenta,colors.magenta,colors.black)
  81. knob.newKnob("Slot5",26,36,5,7,slot5Name,string.upper(slot5Name),colors.black,colors.yellow,colors.yellow,colors.black)
  82. knob.newKnob("Slot6",26,36,9,11,slot6Name,string.upper(slot6Name),colors.black,colors.cyan,colors.cyan,colors.black)
  83. knob.newKnob("Slot7",38,48,5,7,slot7Name,string.upper(slot7Name),colors.black,colors.green,colors.green,colors.black)
  84. knob.newKnob("Slot8",38,48,9,11,slot8Name,string.upper(slot8Name),colors.black,colors.lime,colors.lime,colors.black)
  85. knob.newKnob("PageUp",36,40,1,3,pagesNameUp,pagesNameUp,colors.black,colors.purple,colors.purple,colors.black)
  86.  
  87. knob.setState("Slot1",false)
  88. knob.setState("Slot2",false)
  89. knob.setState("Slot3",false)
  90. knob.setState("Slot4",false)
  91. knob.setState("Slot5",false)
  92. knob.setState("Slot6",false)
  93. knob.setState("Slot7",false)
  94. knob.setState("Slot8",false)
  95. knob.setState("PageUp",false)
  96. -- set them to false
  97.  
  98. if knob.getState("Slot1") == true then  
  99.   sendSlot(1)
  100.   knob.setState("Slot1",false)
  101.   knob.display()
  102. elseif knob.getState("Slot2") == true then
  103.   sendSlot(2)
  104.   knob.setState("Slot2",false)
  105.   knob.display()
  106. elseif knob.getState("Slot3") == true then
  107.   sendSlot(3)
  108.   knob.setState("Slot3",false)
  109.   knob.display()
  110. elseif knob.getState("Slot4") == true then
  111.   sendSlot(4)
  112.   knob.setState("Slot4",false)
  113.   knob.display()
  114. elseif knob.getState("Slot5") == true then
  115.   sendSlot(5)
  116.   knob.setState("Slot5",false)
  117.   knob.display()
  118. elseif knob.getState("Slot6") == true then
  119.   sendSlot(6)
  120.   knob.setState("Slot6",false)
  121.   knob.display()
  122. elseif knob.getState("Slot7") == true then
  123.   sendSlot(7)
  124.   knob.setState("Slot7",false)
  125.   knob.display()
  126. elseif knob.getState("Slot8") == true then
  127.   sendSlot(8)
  128.   knob.setState("Slot8",false)
  129.   knob.display()
  130.  
  131. elseif knob.getState("PageUp") == true then
  132.  pages = pages + 1
  133.  if pages == 1 then
  134.    Page1Knobs()
  135.  elseif pages==2 then
  136.    Page2Knobs()
  137.  elseif pages == 3 then
  138.    Page3Knobs()
  139.  end
  140. elseif knob.getState("Pagedown") == true then
  141.   pages = pages -1
  142.    if pages == 1 then
  143.    Page1Knobs()
  144.  elseif pages==2 then
  145.    Page2Knobs()
  146.  elseif pages == 3 then
  147.    Page3Knobs()
  148.  end
  149. end
  150.  
  151. end
  152.  
  153. function Page2Knobs()
  154. channel = 1
  155. -- Starts the monitor and sets up the basics
  156. knob.startUp(monitorSide,1,colors.black,colors.lime)
  157. knob.header("Select an Age")
  158. -- adds the knobs to the monitor
  159. -- function new(name,xMin,xMax,yMin,yMax,text,textColor,bgColor) adds a button
  160.  
  161. knob.newKnob("Slot9",2,12,5,7,slot9Name,string.upper(slot9Name),colors.black,colors.blue,colors.blue,colors.black)
  162. knob.newKnob("Slot10",2,12,9,11,slot10Name,string.upper(slot10Name),colors.black,colors.red,colors.red,colors.black)
  163. knob.newKnob("Slot11",14,24,5,7,slot11Name,string.upper(slot11Name),colors.black,colors.brown,colors.brown,colors.black)
  164. knob.newKnob("Slot12",14,24,9,11,slot12Name,string.upper(slot12Name),colors.black,colors.magenta,colors.magenta,colors.black)
  165. knob.newKnob("Slot13",26,36,5,7,slot13Name,string.upper(slot13Name),colors.black,colors.yellow,colors.yellow,colors.black)
  166. knob.newKnob("Slot14",26,36,9,11,slot14Name,string.upper(slot14Name),colors.black,colors.cyan,colors.cyan,colors.black)
  167. knob.newKnob("Slot15",38,48,5,7,slot15Name,string.upper(slot15Name),colors.black,colors.green,colors.green,colors.black)
  168. knob.newKnob("Slot16",38,48,9,11,slot16Name,string.upper(slot16Name),colors.black,colors.lime,colors.lime,colors.black)
  169. knob.newKnob("Pageup",36,40,1,3,pagesNameUp,pagesNameUp,colors.black,colors.purple,colors.purple,colors.black)
  170. knob.newKnob("PageDown",44,48,1,3,pagesNameDown,pagesNameDown,colors.black,colors.purple,colors.purple,colors.black)
  171.  
  172. knob.setState("Slot9",false)
  173. knob.setState("Slot10",false)
  174. knob.setState("Slot11",false)
  175. knob.setState("Slot12",false)
  176. knob.setState("Slot13",false)
  177. knob.setState("Slot14",false)
  178. knob.setState("Slot15",false)
  179. knob.setState("Slot16",false)
  180.  
  181. knob.setState("Pages",false)
  182. -- set them to false
  183.  
  184. if knob.getState("Slot9") == true then  
  185.   sendSlot(9)
  186.   knob.setState("Slot9",false)
  187.   knob.display()
  188. elseif knob.getState("Slot10") == true then
  189.   sendSlot(10)
  190.   knob.setState("Slot10",false)
  191.   knob.display()
  192. elseif knob.getState("Slot11") == true then
  193.   sendSlot(11)
  194.   knob.setState("Slot11",false)
  195.   knob.display()
  196. elseif knob.getState("Slot12") == true then
  197.   sendSlot(12)
  198.   knob.setState("Slot12",false)
  199.   knob.display()
  200. elseif knob.getState("Slot13") == true then
  201.   sendSlot(13)
  202.   knob.setState("Slot13",false)
  203.   knob.display()
  204. elseif knob.getState("Slot14") == true then
  205.   sendSlot(14)
  206.   knob.setState("Slot14",false)
  207.   knob.display()
  208. elseif knob.getState("Slot15") == true then
  209.   sendSlot(15)
  210.   knob.setState("Slot15",false)
  211.   knob.display()
  212. elseif knob.getState("Slot16") == true then
  213.   sendSlot(16)
  214.   knob.setState("Slot16",false)
  215.   knob.display()
  216.  
  217. elseif knob.getState("PageUp") == true then
  218.  pages = pages + 1
  219.  if pages == 1 then
  220.    Page1Knobs()
  221.  elseif pages==2 then
  222.    Page2Knobs()
  223.  elseif pages == 3 then
  224.    Page3Knobs()
  225.  end
  226. elseif knob.getState("Pagedown") == true then
  227.   pages = pages -1
  228.    if pages == 1 then
  229.    Page1Knobs()
  230.  elseif pages==2 then
  231.    Page2Knobs()
  232.  elseif pages == 3 then
  233.    Page3Knobs()
  234.  end
  235. end
  236.  
  237. end
  238.  
  239. function Page3Knobs()
  240. channel = 5
  241. -- Starts the monitor and sets up the basics
  242. knob.startUp(monitorSidmonitorSide,1,colors.black,colors.lime)
  243. knob.header("Select an Age")
  244. -- adds the knobs to the monitor
  245. -- function new(name,xMin,xMax,yMin,yMax,text,textColor,bgColor) adds a button
  246.  
  247. knob.newKnob("Slot17",2,12,5,7,slot9Name,string.upper(slot9Name),colors.black,colors.blue,colors.blue,colors.black)
  248. knob.newKnob("Slot18",2,12,9,11,slot10Name,string.upper(slot10Name),colors.black,colors.red,colors.red,colors.black)
  249. knob.newKnob("Slot19",14,24,5,7,slot11Name,string.upper(slot11Name),colors.black,colors.brown,colors.brown,colors.black)
  250. knob.newKnob("Slot20",14,24,9,11,slot12Name,string.upper(slot12Name),colors.black,colors.magenta,colors.magenta,colors.black)
  251. knob.newKnob("Slot21",26,36,5,7,slot13Name,string.upper(slot13Name),colors.black,colors.yellow,colors.yellow,colors.black)
  252. knob.newKnob("Slot22",26,36,9,11,slot14Name,string.upper(slot14Name),colors.black,colors.cyan,colors.cyan,colors.black)
  253.  
  254. knob.newKnob("PageDown",44,48,1,3,pagesNameDown,pagesNameDown,colors.black,colors.purple,colors.purple,colors.black)
  255.  
  256.  
  257. knob.setState("Slot17",false)
  258. knob.setState("Slot18",false)
  259. knob.setState("Slot19",false)
  260. knob.setState("Slot20",false)
  261. knob.setState("Slot21",false)
  262. knob.setState("Slot22",false)
  263.  
  264.  
  265. knob.setState("PageDown",false)
  266. -- set them to false
  267.  
  268. if knob.getState("Slot17") == true then  
  269.   sendSlot(17)
  270.   knob.setState("Slot17",false)
  271.   knob.display()
  272. elseif knob.getState("Slot18") == true then
  273.   sendSlot(18)
  274.   knob.setState("Slot18",false)
  275.   knob.display()
  276. elseif knob.getState("Slot19") == true then
  277.   sendSlot(19)
  278.   knob.setState("Slot19",false)
  279.   knob.display()
  280. elseif knob.getState("Slot20") == true then
  281.   sendSlot(20)
  282.   knob.setState("Slot20",false)
  283.   knob.display()
  284. elseif knob.getState("Slot21") == true then
  285.   sendSlot(21)
  286.   knob.setState("Slot21",false)
  287.   knob.display()
  288. elseif knob.getState("Slot22") == true then
  289.   sendSlot(22)
  290.   knob.setState("Slot22",false)
  291.   knob.display()
  292.  
  293.  
  294. elseif knob.getState("PageUp") == true then
  295.  pages = pages + 1
  296.  if pages == 1 then
  297.    Page1Knobs()
  298.  elseif pages==2 then
  299.    Page2Knobs()
  300.  elseif pages == 3 then
  301.    Page3Knobs()
  302.  end
  303. elseif knob.getState("Pagedown") == true then
  304.   pages = pages -1
  305.    if pages == 1 then
  306.    Page1Knobs()
  307.  elseif pages==2 then
  308.    Page2Knobs()
  309.  elseif pages == 3 then
  310.    Page3Knobs()
  311.  end
  312. end
  313. end
  314.  
  315. knob.startUp(monitorSide,1,colors.black,colors.lime)
  316. while true do
  317. knob.header("Select an Age")
  318. Page1Knobs()
  319.  
  320. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement