INCSlayer

pc2

Dec 20th, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.22 KB | None | 0 0
  1. function portal()
  2. local Locations = {}
  3. -- Replace the Zeros with the computer ID of the corresponding Turtle(s) the command to get the ID is print(os.getComputerID()) within the lua editor
  4. local pt1 = 0
  5. local pt2 = 0
  6. local pt3 = 0
  7. -- Name Your Locations Here due to screen constraints make sure the names are not longer than 11 characters:
  8. -- Turtle 1:
  9. Locations[01] = ""
  10. Locations[02] = ""
  11. Locations[03] = ""
  12. Locations[04] = ""
  13. Locations[05] = ""
  14. Locations[06] = ""
  15. Locations[07] = ""
  16. Locations[08] = ""
  17. Locations[09] = ""
  18. Locations[10] = ""
  19. Locations[11] = ""
  20. Locations[12] = ""
  21. Locations[13] = ""
  22. Locations[14] = ""
  23. Locations[15] = ""
  24. Locations[16] = ""
  25. -- Turtle 2:
  26. Locations[17] = ""
  27. Locations[18] = ""
  28. Locations[19] = ""
  29. Locations[20] = ""
  30. Locations[21] = ""
  31. Locations[22] = ""
  32. Locations[23] = ""
  33. Locations[24] = ""
  34. Locations[25] = ""
  35. Locations[26] = ""
  36. Locations[27] = ""
  37. Locations[28] = ""
  38. Locations[29] = ""
  39. Locations[30] = ""
  40. Locations[31] = ""
  41. Locations[32] = ""
  42. -- Turtle 3:
  43. Locations[33] = ""
  44. Locations[34] = ""
  45. Locations[35] = ""
  46. Locations[36] = ""
  47. Locations[37] = ""
  48. Locations[38] = ""
  49. Locations[39] = ""
  50. Locations[40] = ""
  51. Locations[41] = ""
  52. Locations[42] = ""
  53. Locations[43] = ""
  54. Locations[44] = ""
  55. Locations[45] = ""
  56. Locations[46] = ""
  57. Locations[47] = ""
  58. Locations[48] = ""
  59. -- if the portal is behaving strangely or not working at all try increasing this number:
  60. local wait = 1
  61.  
  62. -- Monitor Output
  63. --primary monitor output:
  64.     if peripheral.isPresent("top") then
  65.         mon1 = peripheral.wrap("top")
  66.         mon1.setTextScale(2)
  67.         mon1.setCursorPos(1,1)
  68.         mon1.clearLine(1)
  69.         mon1.write("Destination:")
  70.         mon1.setCursorPos(1,2)
  71.     end
  72. --secondary monitor output to look properly the monitor needs to be 3 high and 5 wide:
  73.     if peripheral.isPresent("back:green") then
  74.         mon2 = peripheral.wrap("back:green")
  75.         mon2.setTextScale(1)
  76.         mon2.clear()
  77.         mon2.setCursorPos(1,1)
  78.         mon2.write("Destinations:")
  79.         mon2.setCursorPos(1,2)
  80. -- turtle 1 destinations
  81.         mon2.write ("01. " ..Locations[01])
  82.         mon2.setCursorPos(1,3)
  83.         mon2.write ("02. " ..Locations[02])
  84.         mon2.setCursorPos(1,4)
  85.         mon2.write ("03. " ..Locations[03])
  86.         mon2.setCursorPos(1,5)
  87.         mon2.write ("04. " ..Locations[04])
  88.         mon2.setCursorPos(1,6)
  89.         mon2.write ("05. " ..Locations[05])
  90.         mon2.setCursorPos(1,7)
  91.         mon2.write ("06. " ..Locations[06])
  92.         mon2.setCursorPos(1,8)
  93.         mon2.write ("07. " ..Locations[07])
  94.         mon2.setCursorPos(1,9)
  95.         mon2.write ("08. " ..Locations[08])
  96.         mon2.setCursorPos(1,10)
  97.         mon2.write ("09. " ..Locations[09])
  98.         mon2.setCursorPos(1,11)
  99.         mon2.write ("10. " ..Locations[10])
  100.         mon2.setCursorPos(1,12)
  101.         mon2.write ("11. " ..Locations[11])
  102.         mon2.setCursorPos(1,13)
  103.         mon2.write ("12. " ..Locations[12])
  104.         mon2.setCursorPos(1,14)
  105.         mon2.write ("13. " ..Locations[13])
  106.         mon2.setCursorPos(1,15)
  107.         mon2.write ("14. " ..Locations[14])
  108.         mon2.setCursorPos(1,16)
  109.         mon2.write ("15. " ..Locations[15])
  110.         mon2.setCursorPos(1,17)
  111.         mon2.write ("16. " ..Locations[16])
  112. -- turtle 2 destinations   
  113.         mon2.setCursorPos(18,2)
  114.         mon2.write ("17. " ..Locations[17])
  115.         mon2.setCursorPos(18,3)
  116.         mon2.write ("18. " ..Locations[18])
  117.         mon2.setCursorPos(18,4)
  118.         mon2.write ("19. " ..Locations[19])
  119.         mon2.setCursorPos(18,5)
  120.         mon2.write ("20. " ..Locations[20])
  121.         mon2.setCursorPos(18,6)
  122.         mon2.write ("21. " ..Locations[21])
  123.         mon2.setCursorPos(18,7)
  124.         mon2.write ("22. " ..Locations[22])
  125.         mon2.setCursorPos(18,8)
  126.         mon2.write ("23. " ..Locations[23])
  127.         mon2.setCursorPos(18,9)
  128.         mon2.write ("24. " ..Locations[24])
  129.         mon2.setCursorPos(18,10)
  130.         mon2.write ("25. " ..Locations[25])
  131.         mon2.setCursorPos(18,11)
  132.         mon2.write ("26. " ..Locations[26])
  133.         mon2.setCursorPos(18,12)
  134.         mon2.write ("27. " ..Locations[27])
  135.         mon2.setCursorPos(18,13)
  136.         mon2.write ("28. " ..Locations[28])
  137.         mon2.setCursorPos(18,14)
  138.         mon2.write ("29. " ..Locations[29])
  139.         mon2.setCursorPos(18,15)
  140.         mon2.write ("30. " ..Locations[30])
  141.         mon2.setCursorPos(18,16)
  142.         mon2.write ("31. " ..Locations[31])
  143.         mon2.setCursorPos(18,17)
  144.         mon2.write ("32. " ..Locations[32])
  145. -- turtle 3 destinations
  146.         mon2.setCursorPos(36,2)
  147.         mon2.write ("33. " ..Locations[33])
  148.         mon2.setCursorPos(36,3)
  149.         mon2.write ("34. " ..Locations[34])
  150.         mon2.setCursorPos(36,4)
  151.         mon2.write ("35. " ..Locations[35])
  152.         mon2.setCursorPos(36,5)
  153.         mon2.write ("36. " ..Locations[36])
  154.         mon2.setCursorPos(36,6)
  155.         mon2.write ("37. " ..Locations[37])
  156.         mon2.setCursorPos(36,7)
  157.         mon2.write ("38. " ..Locations[38])
  158.         mon2.setCursorPos(36,8)
  159.         mon2.write ("39. " ..Locations[39])
  160.         mon2.setCursorPos(36,9)
  161.         mon2.write ("40. " ..Locations[40])
  162.         mon2.setCursorPos(36,10)
  163.         mon2.write ("41. " ..Locations[41])
  164.         mon2.setCursorPos(36,11)
  165.         mon2.write ("42. " ..Locations[42])
  166.         mon2.setCursorPos(36,12)
  167.         mon2.write ("43. " ..Locations[43])
  168.         mon2.setCursorPos(36,13)
  169.         mon2.write ("44. " ..Locations[44])
  170.         mon2.setCursorPos(36,14)
  171.         mon2.write ("45. " ..Locations[45])
  172.         mon2.setCursorPos(36,15)
  173.         mon2.write ("46. " ..Locations[46])
  174.         mon2.setCursorPos(36,16)
  175.         mon2.write ("47. " ..Locations[47])
  176.         mon2.setCursorPos(36,17)
  177.         mon2.write ("48. " ..Locations[48])
  178. end
  179. -- terminal output:
  180.     term.clear()
  181.     term.setCursorPos(1,1)
  182.     print ("Valid Destination IDs are:")
  183. -- turtle 1 destinations
  184.     term.setCursorPos(1,2)
  185.     print ("01. " ..Locations[01])
  186.     term.setCursorPos(1,3)
  187.     print ("02. " ..Locations[02])
  188.     term.setCursorPos(1,4)
  189.     print ("03. " ..Locations[03])
  190.     term.setCursorPos(1,5)
  191.     print ("04. " ..Locations[04])
  192.     term.setCursorPos(1,6)
  193.     print ("05. " ..Locations[05])
  194.     term.setCursorPos(1,7)
  195.     print ("06. " ..Locations[06])
  196.     term.setCursorPos(1,8)
  197.     print ("07. " ..Locations[07])
  198.     term.setCursorPos(1,9)
  199.     print ("08. " ..Locations[08])
  200.     term.setCursorPos(1,10)
  201.     print ("09. " ..Locations[09])
  202.     term.setCursorPos(1,11)
  203.     print ("10. " ..Locations[10])
  204.     term.setCursorPos(1,12)
  205.     print ("11. " ..Locations[11])
  206.     term.setCursorPos(1,13)
  207.     print ("12. " ..Locations[12])
  208.     term.setCursorPos(1,14)
  209.     print ("13. " ..Locations[13])
  210.     term.setCursorPos(1,15)
  211.     print ("14. " ..Locations[14])
  212.     term.setCursorPos(1,16)
  213.     print ("15. " ..Locations[15])
  214.     term.setCursorPos(1,17)
  215.     print ("16. " ..Locations[16])
  216. -- turtle 2 destinations   
  217.     term.setCursorPos(18,2)
  218.     print ("17. " ..Locations[17])
  219.     term.setCursorPos(18,3)
  220.     print ("18. " ..Locations[18])
  221.     term.setCursorPos(18,4)
  222.     print ("19. " ..Locations[19])
  223.     term.setCursorPos(18,5)
  224.     print ("20. " ..Locations[20])
  225.     term.setCursorPos(18,6)
  226.     print ("21. " ..Locations[21])
  227.     term.setCursorPos(18,7)
  228.     print ("22. " ..Locations[22])
  229.     term.setCursorPos(18,8)
  230.     print ("23. " ..Locations[23])
  231.     term.setCursorPos(18,9)
  232.     print ("24. " ..Locations[24])
  233.     term.setCursorPos(18,10)
  234.     print ("25. " ..Locations[25])
  235.     term.setCursorPos(18,11)
  236.     print ("26. " ..Locations[26])
  237.     term.setCursorPos(18,12)
  238.     print ("27. " ..Locations[27])
  239.     term.setCursorPos(18,13)
  240.     print ("28. " ..Locations[28])
  241.     term.setCursorPos(18,14)
  242.     print ("29. " ..Locations[29])
  243.     term.setCursorPos(18,15)
  244.     print ("30. " ..Locations[30])
  245.     term.setCursorPos(18,16)
  246.     print ("31. " ..Locations[31])
  247.     term.setCursorPos(18,17)
  248.     print ("32. " ..Locations[32])
  249. -- turtle 3 destinations
  250.     term.setCursorPos(36,2)
  251.     print ("33. " ..Locations[33])
  252.     term.setCursorPos(36,3)
  253.     print ("34. " ..Locations[34])
  254.     term.setCursorPos(36,4)
  255.     print ("35. " ..Locations[35])
  256.     term.setCursorPos(36,5)
  257.     print ("36. " ..Locations[36])
  258.     term.setCursorPos(36,6)
  259.     print ("37. " ..Locations[37])
  260.     term.setCursorPos(36,7)
  261.     print ("38. " ..Locations[38])
  262.     term.setCursorPos(36,8)
  263.     print ("39. " ..Locations[39])
  264.     term.setCursorPos(36,9)
  265.     print ("40. " ..Locations[40])
  266.     term.setCursorPos(36,10)
  267.     print ("41. " ..Locations[41])
  268.     term.setCursorPos(36,11)
  269.     print ("42. " ..Locations[42])
  270.     term.setCursorPos(36,12)
  271.     print ("43. " ..Locations[43])
  272.     term.setCursorPos(36,13)
  273.     print ("44. " ..Locations[44])
  274.     term.setCursorPos(36,14)
  275.     print ("45. " ..Locations[45])
  276.     term.setCursorPos(36,15)
  277.     print ("46. " ..Locations[46])
  278.     term.setCursorPos(36,16)
  279.     print ("47. " ..Locations[47])
  280.     term.setCursorPos(36,17)
  281.     print ("48. " ..Locations[48])
  282. -- computer output
  283.     term.setCursorPos(1,18)
  284.     print ("99. close Portal")
  285.     term.setCursorPos(1,19)
  286.     write ("Enter Destination ID: ")
  287.     term.setCursorPos(23,19)
  288. -- Actual Code:
  289.     local Num1 = ( read() )
  290.     rednet.send(pt1,"99")
  291.     if pt2 > 1 then
  292.     rednet.send(pt2,"99")
  293.     end
  294.     if pt3 > 1 then
  295.     rednet.send(pt3,"99")
  296.     end
  297.     if peripheral.isPresent("top") then
  298.         mon1.clearLine(2)
  299.         mon1.setCursorPos(1,2) 
  300.         if Num1 == "99" then
  301.             mon1.write("Portal Closed")
  302.         else
  303.             mon1.write("Processing")
  304.         end
  305.         mon1.setCursorPos(1,2)
  306.     end
  307. function dest()
  308.     if peripheral.isPresent("top") then        
  309.         mon1.clearLine(2)
  310.         mon1.write(Locations[Num1])
  311.     end
  312. end
  313.     os.sleep(wait)
  314.     if tonumber(Num1) ~= nil then
  315.         Num1 = tonumber(Num1)
  316.         if (Num1>0) and (Num1<17) then
  317.             dest()
  318.             rednet.send(pt1,""..Num1)
  319.         elseif (Num1>16) and (Num1<33) then
  320.             dest()
  321.             local Num2 = Num1 - 16
  322.             rednet.send(pt2,""..Num2)
  323.         elseif (Num1>32) and (Num1<49) then
  324.             dest()
  325.             local Num3 = Num1 - 32
  326.             rednet.send(pt3,""..Num3)
  327.         end
  328.     else
  329.         if peripheral.isPresent("top") then
  330.             mon1.write("User Error")
  331.         end
  332.     end
  333. end
  334.  
  335. while true do
  336.         rednet.open("left")
  337.         portal()
  338. end
Advertisement
Add Comment
Please, Sign In to add comment