Advertisement
thatparadox

PortalICBMpanel

Dec 23rd, 2013
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.47 KB | None | 0 0
  1. for k,v in pairs(rs.getSides()) do
  2.   if peripheral.getType(v)=='monitor' then
  3.    side = v
  4.    mon = peripheral.wrap(side)
  5.    break
  6.   end
  7. end
  8. for k,v in pairs(rs.getSides()) do
  9.   if peripheral.getType(v)=='modem' then
  10.    rednet.open(v)
  11.    break
  12.   end
  13. end
  14. monX, monY = mon.getSize()
  15.  
  16. portal = "n"
  17. launch = false
  18. update = false
  19. x = 0
  20. y = 0
  21. z = 0
  22. setX = 0
  23. setY = 0
  24. setZ = 0
  25.  
  26.  
  27. local function link()
  28.     mon.setCursorPos(1,1)
  29.     mon.setBackgroundColor(colors.black)
  30.     mon.clear()
  31.     mon.setBackgroundColor(colors.green)
  32.     for i = 1,monY,2 do
  33.       mon.setCursorPos(1,i)
  34.       for k = 1,monX do
  35.         mon.write(" ")
  36.       end
  37.     end
  38.     mon.setBackgroundColor(colors.lime)
  39.     for i = 2,monY,2 do
  40.       mon.setCursorPos(1,i)
  41.       for k = 1,monX do
  42.         mon.write(" ")
  43.       end
  44.     end
  45.     for i = 2, monY,2 do
  46.       if fs.exists(tostring(i.."prt")) then
  47.         file = fs.open(tostring(i.."prt"),"r")
  48.         data = file.readAll()
  49.         file.close()
  50.         data = textutils.unserialize(data)
  51.         for key,value in pairs(data) do
  52.             if tostring(key) == "name" then
  53.               mon.setCursorPos(monX/2-string.len(tostring(value))/2, i)
  54.               mon.write(tostring(value))
  55.             end
  56.         end
  57.       else
  58.         mon.setCursorPos(monX/2-7, i)
  59.         mon.write("Set Portal Link")
  60.       end
  61.     end
  62.     mon.setBackgroundColor(colors.red)
  63.     for i = 1,monY do
  64.       mon.setCursorPos(monX-3,i)
  65.       mon.write(" X ")
  66.     end
  67.     mon.setBackgroundColor(colors.green)
  68.     for i = 1, monY,2 do
  69.       if fs.exists(tostring(i.."prt")) then    
  70.         file = fs.open(tostring(i.."prt"),"r")
  71.         data = file.readAll()
  72.         file.close()
  73.         data = textutils.unserialize(data)
  74.         for key,value in pairs(data) do
  75.             if tostring(key) == "name" then
  76.               mon.setCursorPos(monX/2-string.len(tostring(value))/2, i)
  77.               mon.write(tostring(value))
  78.             end
  79.         end
  80.       else
  81.         mon.setCursorPos(monX/2-7, i)
  82.         mon.write("Set Portal Link")
  83.       end
  84.     end
  85.     event, param1, param2, param3 = os.pullEvent("monitor_touch")
  86.     if param2 > monX-3 then
  87.       fs.delete(tostring(param3.."prt"))
  88.     elseif fs.exists(tostring(param3.."prt")) then
  89.       rednet.send(tonumber(linkTurtle), param3)
  90.       id = nil
  91.       while id ~= tonumber(linkTurtle) do
  92.         id, message = rednet.receive()
  93.       end
  94.       if message == "true" then
  95.         mon.setBackgroundColor(colors.black)
  96.         mon.setTextColor(colors.yellow)
  97.         mon.clear()
  98.         mon.setCursorPos(monX/2-8, monY/2)
  99.         mon.write("Link Book changed")
  100.         mon.setCursorPos(monX/2-12, monY/2+2)
  101.         mon.write("Reset target coordinates!")
  102.         file = fs.open(tostring(param3.."prt"), "r")
  103.         info = file.readAll()
  104.         file.close()
  105.         info = textutils.unserialize(info)
  106.         for key, value in pairs(info) do
  107.             if key == "x" then
  108.                 prtX = value
  109.             elseif key == "y" then
  110.                 prtY = value
  111.             elseif key == "z" then
  112.                 prtZ = value
  113.             end
  114.         end
  115.         update = true
  116.         adjX = (locX - prtX)
  117.         adjY = (locY - prtY)
  118.         adjZ = (locZ - prtZ)
  119.         file = fs.open("adj","w")
  120.         file.write(param3.."prt")
  121.         file.close()
  122.         adj = param3.."prt"
  123.         sleep(2.5)
  124.       elseif message == "false" then
  125.         mon.setBackgroundColor(colors.black)
  126.         mon.setTextColor(colors.red)
  127.         mon.clear()
  128.         mon.setCursorPos(monX/2-15, monY/2)
  129.         mon.write("Turtle unable to change Link Book")
  130.         sleep(5)
  131.       end
  132.       mon.clear()
  133.     else
  134.       mon.setBackgroundColor(colors.black)
  135.       mon.setTextColor(colors.green)
  136.       mon.clear()
  137.       mon.setCursorPos(monX/2-15, monY/2)
  138.       mon.write("Follow Prompts On The Computer Bellow")
  139.       term.clear()
  140.       term.setCursorPos(1,1)
  141.       for i = 1, monY do
  142.         if fs.exists(tostring(i.."prt")) then
  143.           tSlot = i
  144.         end
  145.       end
  146.       tSlot = tSlot + 1
  147.       print("When linking the Linking Book face north. Then place Linking book in slot "..tSlot.." of your turtle positioned above the portal receptacle. Press Enter to continue. ")
  148.       dud = read()
  149.       term.clear()
  150.       term.setCursorPos(1,1)
  151.       write("Set the display name for Link: ")
  152.       name = read()
  153.       term.clear()
  154.       term.setCursorPos(1,1)
  155.       write("Set the X coordinate of Link location: ")
  156.       adjX = read()
  157.       term.clear()
  158.       term.setCursorPos(1,1)
  159.       write("Set the Y coordinate of Link location: ")
  160.       adjY = read()
  161.       term.clear()
  162.       term.setCursorPos(1,1)
  163.       write("Set the Z coordinate of Link location: ")
  164.       adjZ = read()
  165.       table = {name = name, x = adjX, y = adjY, z = adjZ}
  166.       table = textutils.serialize(table)
  167.       for i = 1, monY do
  168.         if fs.exists(tostring(i.."prt")) == false then
  169.           file = fs.open(tostring(i.."prt"), "w")
  170.           file.write(table)
  171.           file.close()
  172.           adj = i.."prt"
  173.           file = fs.open("adj", "w")
  174.           file.write(adj)
  175.           file.close()
  176.           break
  177.         end
  178.       end
  179.       rednet.send(tonumber(linkTurtle), tostring(tSlot))
  180.       while waitID ~= tonumber(linkTurtle) do
  181.         term.clear()
  182.         term.setCursorPos(1,1)
  183.         print("Waiting for Turtle.")
  184.         waitID, message = rednet.receive(5)
  185.       end
  186.       if message ~= "true" then
  187.         print("Turtle cannot place book. Deleting link.")
  188.         sleep(10)      
  189.         fs.delete(tostring(tSlot.."prt"))
  190.       end
  191.     end
  192.     update = true
  193.     display()
  194. end
  195.  
  196. local function bookmarks()
  197.     mon.setCursorPos(1,1)
  198.     mon.setBackgroundColor(colors.black)
  199.     mon.clear()
  200.     mon.setBackgroundColor(colors.green)
  201.     for i = 1,monY,2 do
  202.       mon.setCursorPos(1,i)
  203.       for k = 1,monX do
  204.         mon.write(" ")
  205.       end
  206.     end
  207.     mon.setBackgroundColor(colors.lime)
  208.     for i = 2,monY,2 do
  209.       mon.setCursorPos(1,i)
  210.       for k = 1,monX do
  211.         mon.write(" ")
  212.       end
  213.     end
  214.     for i = 2, monY,2 do
  215.       if fs.exists(tostring(i)) then
  216.         file = fs.open(tostring(i),"r")
  217.         data = file.readAll()
  218.         file.close()
  219.         data = textutils.unserialize(data)
  220.         for key,value in pairs(data) do
  221.             if tostring(key) == "name" then
  222.               mon.setCursorPos(monX/2-string.len(tostring(value))/2, i)
  223.               mon.write(tostring(value))
  224.             end
  225.         end
  226.       else
  227.         mon.setCursorPos(monX/2-5, i)
  228.         mon.write("Set Bookmark")
  229.       end
  230.     end
  231.     mon.setBackgroundColor(colors.red)
  232.     for i = 1,monY do
  233.       mon.setCursorPos(monX-3,i)
  234.       mon.write(" X ")
  235.     end
  236.     mon.setBackgroundColor(colors.green)
  237.     for i = 1, monY,2 do
  238.       if fs.exists(tostring(i)) then
  239.        
  240.         file = fs.open(tostring(i),"r")
  241.         data = file.readAll()
  242.         file.close()
  243.         data = textutils.unserialize(data)
  244.         for key,value in pairs(data) do
  245.             if tostring(key) == "name" then
  246.               mon.setCursorPos(monX/2-string.len(tostring(value))/2, i)
  247.               mon.write(tostring(value))
  248.             end
  249.         end
  250.       else
  251.         mon.setCursorPos(monX/2-5, i)
  252.         mon.write("Set Bookmark")
  253.       end
  254.     end
  255.     event, param1, param2, param3 = os.pullEvent("monitor_touch")
  256.     if param2 > monX-3 then
  257.       fs.delete(tostring(param3))
  258.     elseif fs.exists(tostring(param3)) then
  259.       file = fs.open(tostring(param3), "r")
  260.       info = file.readAll()
  261.       file.close()
  262.       info = textutils.unserialize(info)
  263.       for key, value in pairs(info) do
  264.         if key == "x" then
  265.           setX = value
  266.         elseif key == "y" then
  267.           setY = value
  268.         elseif key == "z" then
  269.           setZ = value
  270.         end
  271.       update = true
  272.       end
  273.       mon.clear()
  274.     else
  275.       mon.setBackgroundColor(colors.black)
  276.       mon.setTextColor(colors.green)
  277.       mon.clear()
  278.       mon.setCursorPos(monX/2-15, monY/2)
  279.       mon.write("Follow Prompts On The Computer Bellow")
  280.       term.clear()
  281.       term.setCursorPos(1,1)
  282.       write("Set the name for bookmark: ")
  283.       name = read()
  284.       term.clear()
  285.       term.setCursorPos(1,1)
  286.       write("Set the X coordinate: ")
  287.       wpX = read()term.clear()
  288.       term.setCursorPos(1,1)
  289.       write("Set the Y coordinate: ")
  290.       wpY = read()term.clear()
  291.       term.setCursorPos(1,1)
  292.       write("Set the Z coordinate: ")
  293.       wpZ = read()
  294.       term.clear()
  295.       term.setCursorPos(1,1)
  296.       write("Done!")
  297.       table = {name = name, x = wpX, y = wpY, z = wpZ}
  298.       table = textutils.serialize(table)
  299.       for i = 1, monY do
  300.         if fs.exists(tostring(i)) == false then
  301.           file = fs.open(tostring(i), "w")
  302.           file.write(table)
  303.           file.close()
  304.           break
  305.         end
  306.       end
  307.     end
  308.     display()
  309. end
  310.  
  311. local function coords()
  312.   mon.setTextScale(1)
  313.   mon.setTextColor(colors.yellow)
  314.   mon.setBackgroundColor(colors.black)
  315.   if portal == "y" then
  316.     for i = 1, monX do
  317.         mon.setCursorPos(i,1)
  318.         mon.write(" ")
  319.     end
  320.     mon.setCursorPos(1,1)
  321.     mon.write("X: "..x-adjX)
  322.     mon.setCursorPos(monX/2-2,1)
  323.     mon.write("Y: "..y-adjY)
  324.     mon.setCursorPos(monX-8,1)
  325.     mon.write("Z: "..z-adjZ)   
  326.     dist = math.floor(math.sqrt( (x-locX-adjX)^2 + (y-locY-adjY)^2 + (z-locZ-adjZ)^2 ))
  327.     for i = 1, monX do
  328.         mon.setCursorPos(i,3)
  329.         mon.write(" ")
  330.     end
  331.     for i = monY/4, monY/4+2 do
  332.         for k = 1, monX do
  333.             mon.setCursorPos(k,i)
  334.             mon.write(" ")
  335.         end
  336.     end
  337.     if fs.exists(adj) then
  338.         file = fs.open(adj, "r")
  339.         info = textutils.unserialize(file.readAll())
  340.         file.close()
  341.     else
  342.         file = fs.open("0prt", "r")
  343.         info = textutils.unserialize(file.readAll())
  344.         file.close()
  345.     end
  346.     for key, value in pairs(info) do
  347.         if key == "name" then
  348.             linkB = value
  349.         end
  350.     end
  351.     mon.setCursorPos((monX/2) - (string.len("Using Link: "..linkB)/2), 3)
  352.     mon.write("Using Link: "..linkB)
  353.     mon.setCursorPos((monX/2)-(string.len("Distance: "..dist)/2), monY/4+1)   --fix
  354.     mon.write("Distance: "..dist)
  355.     if adj == "0prt" then
  356.         dist = "No link Set"
  357.     else
  358.         dist = math.floor(math.sqrt( (x-locX)^2 + (y-locY)^2 + (z-locZ)^2 ))
  359.     end
  360.     mon.setCursorPos((monX/2)-(string.len("Distance from link: "..dist)/2), monY/4+2)   --fix
  361.     mon.write("Distance from link: "..dist)
  362.   else
  363.     for i = 1, monX do
  364.         mon.setCursorPos(i,1)
  365.         mon.write(" ")
  366.     end
  367.     mon.setCursorPos(1,1)
  368.     mon.write("X: "..x)
  369.     mon.setCursorPos(monX/2-2,1)
  370.     mon.write("Y: "..y)
  371.     mon.setCursorPos(monX-8,1)
  372.     mon.write("Z: "..z)
  373.     dist = math.floor(math.sqrt( (x-locX)^2 + (y-locY)^2 + (z-locZ)^2 ))
  374.     for i = 1, monX do
  375.         mon.setCursorPos(i,monY/4)
  376.         mon.write(" ")
  377.     end
  378.     for i = 1, monX do
  379.         mon.setCursorPos(i,monY/4+1)
  380.         mon.write(" ")
  381.     end
  382.     mon.setCursorPos((monX/2)-(string.len("Distance: "..dist)/2), monY/4+1)   --fix
  383.     mon.write("Distance: "..dist)
  384.   end
  385. end
  386.  
  387. function display()
  388.   mon.setTextScale(1)
  389.   mon.setTextColor(colors.yellow)
  390.   mon.setBackgroundColor(colors.black)
  391.   mon.clear()
  392.   coords()
  393.   if portal == "y" then
  394.     mon.setTextColor(colors.black)
  395.     mon.setBackgroundColor(colors.yellow)
  396.     for k = monY/4*2+1, monY do
  397.         for i = 1, monX/5*2 do
  398.             mon.setCursorPos(i, k)
  399.             mon.write(" ")
  400.         end
  401.     end
  402.     mon.setCursorPos(monX/10+2, monY/8*5+1)
  403.     mon.write("Bookmarks")
  404.     mon.setTextColor(colors.black)
  405.     mon.setBackgroundColor(colors.orange)
  406.     for k = monY/4*3+1, monY do
  407.         for i = 1, monX/5*2 do
  408.             mon.setCursorPos(i, k)
  409.             mon.write(" ")
  410.         end
  411.     end
  412.     mon.setCursorPos(monX/10+4, monY/8*7+1)
  413.     mon.write("Links")
  414.     mon.setBackgroundColor(colors.black)
  415.     for k = monY/4*3+1, monY do
  416.         for i = ((monX/5*2)/8*7)+1, monX/5*2+1 do
  417.             mon.setCursorPos(i, k)
  418.             mon.write(" ")
  419.         end
  420.     end
  421.     mon.setCursorPos(((monX/5*2)/8*7)+2, monY/4*3+2)
  422.     mon.setTextColor(colors.orange)
  423.     mon.write("X")
  424.   else
  425.     mon.setTextColor(colors.black)
  426.     mon.setBackgroundColor(colors.yellow)
  427.     for k = monY/2+1, monY do
  428.         for i = 1, monX/5*2 do
  429.             mon.setCursorPos(i, k)
  430.             mon.write(" ")
  431.         end
  432.     end
  433.     mon.setCursorPos(monX/10, monY/4*3+1)
  434.     mon.write("Bookmarks")
  435.   end
  436.   mon.setBackgroundColor(colors.red)
  437.   for k = monY/2+1, monY do
  438.     for i = monX/5*2+1, monX/5*3 do
  439.         mon.setCursorPos(i, k)
  440.         mon.write(" ")
  441.     end
  442.   end
  443.   mon.setCursorPos(monX/2-2, monY/4*3+1)
  444.   mon.setTextColor(colors.yellow)
  445.   mon.write("Launch")
  446.   mon.setBackgroundColor(colors.yellow)
  447.   for k = monY/2+1, monY do
  448.     for i = monX/5*3+1, monX do
  449.       mon.setCursorPos(i,k)
  450.       mon.write(" ")
  451.     end
  452.   end
  453.   mon.setCursorPos(monX/5*4-7, monY/8*5+1)
  454.   mon.setTextColor(colors.black)
  455.   mon.write(" Set Coordinates")
  456.   mon.setTextColor(colors.black)
  457.   mon.setBackgroundColor(colors.orange)
  458.   for k = monY/4*3+1, monY do
  459.     for i = monX/5*3+1, monX do
  460.         mon.setCursorPos(i, k)
  461.         mon.write(" ")
  462.     end
  463.   end
  464.   mon.setCursorPos((monX/5*4)-(string.len("Manage Missiles")/2)+2, monY/8*7+1)
  465.   mon.write("Manage Missiles")
  466. end
  467.  
  468.  
  469.  
  470. if fs.exists("location") then
  471.   file = fs.open("location","r")
  472.     loc = file.readAll()
  473.     file.close()
  474.     loc = textutils.unserialize(loc)
  475.     for key,value in pairs(loc) do
  476.         if tostring(key) == "x" then
  477.           locX = tonumber(value)
  478.         elseif tostring(key) == "y" then
  479.           locY = tonumber(value)
  480.         elseif tostring(key) == "z" then
  481.           locZ = tonumber(value)
  482.         end
  483.     end
  484.     file = fs.open("icbmCom", "r")
  485.     icbm = tonumber(file.readAll())
  486.     file.close()
  487.     if fs.exists("adj") then
  488.         portal = "y"
  489.         file = fs.open("adj","r")
  490.         adj = file.readAll()
  491.         file.close()   
  492.        
  493.         if fs.exists(adj) then
  494.             file = fs.open(adj, "r")
  495.             linkxyz = file.readAll()
  496.             file.close()
  497.         else
  498.             file = fs.open("0prt", "r")
  499.             linkxyz = file.readAll()
  500.             file.close()
  501.         end
  502.        
  503.         linkxyz = textutils.unserialize(linkxyz)
  504.         for key,value in pairs(linkxyz) do
  505.             if tostring(key) == "x" then
  506.                 adjX = tonumber(value)
  507.             elseif tostring(key) == "y" then
  508.                 adjY = tonumber(value)
  509.             elseif tostring(key) == "z" then
  510.                 adjZ = tonumber(value)
  511.             end
  512.         end
  513.         file = fs.open("linkTurtle", "r")
  514.         linkTurtle = tonumber(file.readAll())
  515.         file.close()
  516.     end
  517.     file = fs.open("icbmCom", "r")
  518.     icbm = tonumber(file.readAll())
  519.     file.close()
  520.     file = fs.open("missileTurtle", "r")
  521.     missileTurtle = tonumber(file.readAll())
  522.     file.close()
  523. else
  524.   mon.clear()
  525.   mon.setCursorPos(monX/2 - 16, monY/2)
  526.   mon.write("Follow instructions on computer below")
  527.   term.clear()
  528.   term.setCursorPos(1,1)
  529.   write("Enter the Launcher's X coordinate: ")
  530.   locX = read()
  531.   write("Enter the Launcher's Y (height) coordinate: ")
  532.   locY = read()
  533.   write("Enter the Launcher's Z coordinate: ")
  534.   locZ = read()
  535.   term.clear()
  536.   term.setCursorPos(1,1)
  537.   print("Place an Advanced Turtle on top of the launchers middle bottom block so it sits inside in the launcher in the middle (missiles will fire through the turtle) and install the missileTurtle Program on the turtle (Type: pastebin get <inset URL> startup) and run it by typing: startup")
  538.   print("Once the missileTurtle program is running press Enter")
  539.   read()
  540.   term.clear()
  541.   term.setCursorPos(1,1)
  542.   write("Now enter the ID of the Missile Turtle: ")
  543.   missileTurtle = tonumber(read())
  544.   file = fs.open("missileTurtle", "w")
  545.   file.write(missileTurtle)
  546.   file.close()
  547.   while true do
  548.     write("Are you launching through a portal? (y/n): ")
  549.     portal = read()
  550.     if portal == "y" or portal == "n" then
  551.       break
  552.     end
  553.   end
  554.   if portal == "y" then
  555.     term.clear()
  556.     term.setCursorPos(1,1)
  557.     print("While facing north the whole time, build a portal horizontally on top of the launcher so the missile will travel through it. Place the book receptacle then place a turtle on top of the receptacle. You may now stop facing north.")
  558.     print("Press enter to continue")
  559.     read()
  560.     term.clear()
  561.     term.setCursorPos(1,1)
  562.     print("Now install the linkTurtle Program on the turtle (Type: pastebin get T1H2HFMx startup) and run it by typing: startup. Then enter this computer's ID in to the turtle.")
  563.     print("Once the turtle program is running press Enter to continue.")
  564.     read()
  565.     write("Enter the ID of the Linkbook Turtle: ")
  566.     linkTurtle = tonumber(read())
  567.     file = fs.open("linkTurtle", "w")
  568.     file.write(linkTurtle)
  569.     file.close()
  570.     write("Enter a display name for the Linking Book: ")
  571.     name = read()
  572.     write("Enter linking book's X coordinate: ")
  573.     prtX = read()
  574.     write("Enter linking book's Y coordinate: ")
  575.     prtY = read()
  576.     write("Enter linking book's Z coordinate: ")
  577.     prtZ = read()
  578.     term.clear()
  579.     term.setCursorPos(1,1)
  580.     print("How many blocks above the base of the launcher is the portal?")
  581.     prtY = prtY + read()
  582.     adjX = (locX - prtX)
  583.     adjY = (locY - prtY)
  584.     adjZ = (locZ - prtZ)
  585.     linkxyz = {name = name, x = prtX, y = prtY, z = prtZ}
  586.     linkxyz = textutils.serialize(linkxyz)
  587.     adj = "1prt"
  588.     file = fs.open("adj", "w")
  589.     file.write(adj)
  590.     file.close()
  591.     file = fs.open("1prt", "w")
  592.     file.write(linkxyz)
  593.     file.close()
  594.     term.clear()
  595.     term.setCursorPos(1,1)
  596.   end
  597.   location = {x = locX, y = locY, z = locZ}
  598.   location = textutils.serialize(location)
  599.   file = fs.open("location", "w")
  600.   file.write(location)
  601.   file.close()
  602.   term.clear()
  603.   term.setCursorPos(1,1)
  604.   write("Enter the ID the ICBM launcher computer: ")
  605.   icbm = tonumber(read())
  606.   file = fs.open("icbmCom", "w")
  607.   file.write(icbm)
  608.   file.close()
  609.   term.clear()
  610.   term.setCursorPos(1,1)
  611.   print("Setup Complete!")
  612.   sleep(2)
  613. end
  614. display()
  615. while true do
  616.   event, param1, param2, param3, param4, param5 = os.pullEvent()
  617.   print(event)
  618.   if event == "modem_message" and param3 == icbm then
  619.     rednet.send(icbm, "ok1")
  620.     id, x = rednet.receive()
  621.     print("x: "..x)
  622.     rednet.send(icbm, "ok2")
  623.     id, y =rednet.receive()
  624.     print("y: "..y)
  625.     rednet.send(icbm, "ok3")
  626.     id, z = rednet.receive()
  627.     print("Z: "..z)
  628.     if launch == true then
  629.       rednet.send(icbm, "launch")
  630.       launch = false
  631.     elseif update == true then
  632.       print("sending update!")  
  633.       if portal == "y" then
  634.         print(setX)
  635.         print(adjX)
  636.         setX = setX + adjX
  637.         setY = setY + adjY
  638.         setZ = setZ + adjZ
  639.       end
  640.       rednet.send(icbm, "coords")
  641.       rednet.receive()
  642.       rednet.send(icbm, setX)
  643.       rednet.receive()
  644.       rednet.send(icbm, setY)
  645.       rednet.receive()
  646.       rednet.send(icbm, setZ)
  647.       update = false
  648.     else
  649.       rednet.send(icbm, "dud")
  650.     end
  651.     coords()
  652.   elseif event == "monitor_touch" and param2 > monX/5*3+1 and param3 > monY/2 and param3 < monY/4*3+1 then
  653.     mon.setBackgroundColor(colors.black)
  654.     mon.clear()
  655.     coords()
  656.     mon.setCursorPos(monX/2- 14, monY/2)
  657.     mon.setTextColor(colors.red)
  658.     mon.write("ENTER COORDINATES INTO COMPUTER")
  659.     term.clear()
  660.     term.setCursorPos(1,1)
  661.     write("Enter X: ")
  662.     setX = read()
  663.     term.clear()
  664.     term.setCursorPos(1,1)
  665.     write("Enter Y: ")
  666.     setY = read()
  667.     term.clear()
  668.     term.setCursorPos(1,1)
  669.     write("Enter Z: ")
  670.     setZ = read()
  671.     term.clear()
  672.     term.setCursorPos(1,1)
  673.     print("Done!")
  674.     os.sleep(1)
  675.     term.clear()
  676.     update = true
  677.     display()
  678.   elseif event == "monitor_touch" and param2 > monX/5*2+1 and param2 < monX/5*3 and param3 > monY/2 then
  679.     mon.setBackgroundColor(colors.black)
  680.     mon.clear()
  681.     mon.setTextColor(colors.yellow)
  682.     mon.setCursorPos(monX/2 -8, 1)
  683.     mon.write("CONFIRM LAUNCH AT")
  684.     leng = string.len("X: "..tostring(x).." Y: "..tostring(y).." Z: "..tostring(z))
  685.     mon.setCursorPos((monX/2)-leng/2+1, 3)
  686.     mon.write("X: "..x.." Y: "..y.." Z: "..z)
  687.     mon.setTextColor(colors.black)
  688.     mon.setBackgroundColor(colors.red)
  689.     for k = monY/2+1, monY do
  690.         for i = 1, monX/5*2 do
  691.           mon.setCursorPos(i, k)
  692.           mon.write(" ")
  693.         end
  694.     end
  695.     mon.setCursorPos(monX/5-3, monY/4*3+1)
  696.     mon.write("Launch")
  697.     mon.setBackgroundColor(colors.green)
  698.     for k = monY/2+1, monY do
  699.         for i = monX/5*3+1, monX do
  700.           mon.setCursorPos(i,k)
  701.           mon.write(" ")
  702.         end
  703.     end
  704.     mon.setCursorPos(monX/5*4-7, monY/4*3+1)
  705.     mon.write("Abort Launch")
  706.     event, param1, param2, param3 = os.pullEvent("monitor_touch")
  707.     if param2 > monX/5*3 and param3 > monY/2 then
  708.         launch = false
  709.         print(launch)
  710.     elseif param2 < monX/5*2 and param3 > monY/2 then
  711.         launch = true
  712.     end
  713.     display()
  714.   elseif event == "monitor_touch" and param2 < monX/5*2 and param3 > monY/2 and portal == "n" then
  715.     bookmarks()
  716.   elseif event == "monitor_touch" and param2 < monX/5*2 and param3 > monY/2 and param3 < monY/4*3+1 and portal == "y" then
  717.     bookmarks()
  718.   elseif event == "monitor_touch" and param2 < (monX/5*2)/8*7 and param3 > monY/4*3 and portal == "y" then
  719.     link()
  720.   elseif event == "monitor_touch" and param2 < monX/5*2+1 and param3 > monY/4*3 then
  721.     mon.clear()
  722.     rednet.send(linkTurtle, "off")
  723.     id, message = rednet.receive(10)
  724.     if adj == "0prt" then
  725.         if message == "true" then
  726.             mon.setCursorPos(monX/2 - string.len("Portal disabled.")/2+1, monY/2)
  727.             mon.write("Portal disabled!")
  728.             sleep(2)
  729.             display()
  730.         else
  731.             mon.setCursorPos(monX/2 - string.len("Portal is already disabled.")/2+1, monY/2)
  732.             mon.write("Portal is already disabled.")
  733.             sleep(1.5)
  734.             display()
  735.         end
  736.     elseif id == tonumber(linkTurtle) and message == "true" then
  737.         mon.setCursorPos(monX/2 - string.len("Portal disabled!")/2+1, monY/2)
  738.         mon.write("Portal disabled!")
  739.         table = {name = "Portal Inactive", x = 0, y = 0, z = 0}
  740.         table = textutils.serialize(table)
  741.         file = fs.open("0prt", "w")
  742.         file.write(table)
  743.         file.close()
  744.         adjX = 0
  745.         adjY = 0
  746.         adjZ = 0
  747.         adj = "0prt"
  748.         file = fs.open("adj","w")
  749.         file.write("0prt")
  750.         file.close()
  751.         update = true
  752.         sleep(2)
  753.         display()
  754.     else
  755.         mon.setCursorPos(monX/2 - string.len("Turtle Error. Portal still active!")/2+1, monY/2)
  756.         mon.write("Turtle Error. Portal still active!")
  757.         sleep(2)
  758.         display()
  759.     end
  760.   elseif event == "monitor_touch" and param2 > monX/5*3+1 and param3 >monY/4*3 then
  761.     sleep(1)
  762.     rednet.send(missileTurtle, "getList")
  763.     while id ~= missileTurtle do
  764.         id, message = rednet.receive()
  765.     end
  766.     missiles = textutils.unserialize(message)
  767.     mon.setTextColor(colors.white)
  768.     mon.clear()
  769.         mon.setBackgroundColor(colors.black)
  770.     for i = 1, 12, 2 do
  771.         for v = 1, monX do
  772.             mon.setCursorPos(v, i)
  773.             mon.write(" ")
  774.         end
  775.     end
  776.     mon.setBackgroundColor(colors.blue)
  777.     for i = 2, 12, 2 do
  778.         for v = 1, monX do
  779.             mon.setCursorPos(v, i)
  780.             mon.write(" ")
  781.         end
  782.     end
  783.     for i = 1, 12 do
  784.         for k,v in pairs(missiles[i]) do
  785.             if bit.band(i, 1) == 0 then
  786.                 mon.setBackgroundColor(colors.blue)
  787.             else
  788.                 mon.setBackgroundColor(colors.black)
  789.             end
  790.             if k == "name" then
  791.                 mon.setCursorPos(1, i)
  792.                 mon.write(v..":")
  793.             elseif k == "count" then
  794.                 mon.setCursorPos(monX/2, i)
  795.                 mon.write(tostring(v))
  796.             end
  797.         end
  798.     end
  799.     mon.setBackgroundColor(colors.lime)
  800.     for i = 1, 13 do
  801.             mon.setCursorPos(monX - 5, i)
  802.             mon.write("Rename")
  803.     end
  804.     event, param1,param2,param3 = os.pullEvent("monitor_touch")
  805.     if param2 > monX - 5 then
  806.         mon.setBackgroundColor(colors.black)
  807.         mon.clear()
  808.         mon.setCursorPos(monX/2 - string.len("Follow Instructions on the computer below.")/2-1, monY/2)
  809.         mon.write("Follow Instructions on the computer below.")
  810.         term.clear()
  811.         term.setCursorPos(1,1)
  812.         print("Enter the type of missile in slot "..param3..". Leave blank if empty.")
  813.         write("> ")
  814.         mName = read()
  815.         id = nil
  816.         while id ~= missileTurtle do
  817.             rednet.send(missileTurtle, "setName")
  818.             id, message = rednet.receive()
  819.             if id == missileTurtle then
  820.                 rednet.send(missileTurtle, mName)
  821.                 dud, dud2 = rednet.receive()
  822.                 rednet.send(missileTurtle, param3)
  823.                 print("sent")
  824.                 sleep(1)
  825.             else
  826.                 print("Communication Error With Turtle!!!")
  827.                 sleep(1)
  828.             end
  829.         end
  830.         term.clear()
  831.         term.setCursorPos(1,1) 
  832.     else
  833.     rednet.send(missileTurtle, tostring(param3))
  834.     mon.clear()
  835.     end
  836.     display()
  837.   end
  838. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement