Advertisement
usmc3891

GPS Satellite

Jan 3rd, 2013
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.27 KB | None | 0 0
  1. if not turtle then
  2.     print("Error Not turtle")
  3.     return
  4. end
  5.  
  6. local mov = {}
  7.  
  8. mov.forward = function ()
  9.     while not turtle.forward() do
  10.         sleep(1)
  11.     end
  12.     return true
  13. end
  14. mov.back = function ()
  15.     while not turtle.back() do
  16.         sleep(1)
  17.     end
  18.     return true
  19. end
  20. mov.up = function ()
  21.     while not turtle.up() do
  22.         sleep(1)
  23.     end
  24.     return true
  25. end
  26. mov.down = function ()
  27.     while not turtle.down() do
  28.         sleep(1)
  29.     end
  30.     return true
  31. end
  32. mov.place = function ()
  33.     while not turtle.place() do
  34.         sleep(1)
  35.     end
  36. end
  37.  
  38. local base = nil
  39.  
  40. if turtle.getFuelLevel() < 600 then
  41.     print("600 fuel is required")
  42.     return
  43. else
  44.     if fs.exists("custom") then
  45.         print("custom program detected")
  46.         print("please Enter base Station number")
  47.         local failFlag = false
  48.         repeat
  49.             if failFlag then
  50.                 print("Error Not number")
  51.                 print("try again")
  52.             end
  53.             write(" > ")
  54.             base = tonumber(read())
  55.             failFlag = true
  56.         until type(base) == "number"
  57.     end
  58.     print("TURTLE MUST FACE WEST FOR ACCURATE GPS LOCATION!!!")
  59.     sleep(2)
  60.     print("Please Place 4 computers in slot one")
  61.     print("4 modems in slot two")
  62.     print("if mineing turtle then")
  63.     print("1 disk drive in slot three")
  64.     print("if not mining then")
  65.     print("4 disk drive in slot three")
  66.     print("blank floopy disk in slot four")
  67.     print("press Enter key to continue")
  68.     while true do
  69.         local event , key = os.pullEvent("key")
  70.         if key == 28 then break end
  71.     end
  72. end
  73.  
  74.  
  75. local x
  76. term.write("Please Enter X Coord: ")
  77. x = read()
  78.  
  79.  
  80. local z
  81. term.write("Please Enter Z Coord: ")
  82. z = read()
  83.  
  84.  
  85.  
  86.  
  87. local set = {}
  88. set[1] = {x = x-3,y = 255,z = z}
  89. set[2] = {x = x,y = 252,z = z-3}
  90. set[3] = {x = x+3,y = 255,z = z}
  91. set[4] = {x = x,y = 252,z = z+3}
  92.  
  93. print("Launching")
  94. while turtle.up() do -- sends it up till it hits max hight
  95. end
  96.  
  97. for a = 1,4 do
  98.     for i = 1,2 do
  99.         mov.forward()
  100.     end
  101.     turtle.select(1)
  102.     mov.place()
  103.     mov.back()
  104.     turtle.select(2)
  105.     mov.place()
  106.     mov.down()
  107.     mov.forward()
  108.     turtle.select(3)
  109.     mov.place()
  110.     turtle.select(4)
  111.     turtle.drop()
  112.     -- make disk custom
  113.     fs.delete("disk/startup")
  114.     file = fs.open("disk/startup","w")
  115.     file.write([[
  116. fs.copy("disk/install","startup")
  117. fs.delete("disk/startup")
  118. if fs.exists("disk/custom") then
  119.     fs.copy("disk/custom","custom")
  120.     fs.delete("disk/custom")
  121. end
  122. print("sleep in 10")
  123. sleep(10)
  124. os.reboot()
  125. ]])
  126.     file.close()
  127.     if fs.exists("custom") then
  128.         fs.copy("custom","disk/custom")
  129.     end
  130.         file = fs.open("disk/install","w")
  131.         file.write([[
  132. if fs.exists("custom") then
  133.     shell.run("custom","host",]]..set[a]["x"]..","..set[a]["y"]..","..set[a]["z"]..","..(base or "nil")..[[)
  134. else
  135.     shell.run("gps","host",]]..set[a]["x"]..","..set[a]["y"]..","..set[a]["z"]..[[)
  136. end
  137. ]])
  138.         file.close()
  139.     -- end make disk custom
  140.     turtle.turnLeft()
  141.     mov.forward()
  142.     mov.up()
  143.     turtle.turnRight()
  144.     mov.forward()
  145.     turtle.turnRight()
  146.     peripheral.call("front","turnOn")
  147.     mov.down()
  148.     turtle.suck()
  149.     turtle.select(3)
  150.     turtle.dig()
  151.     mov.up()
  152.     -- reboot would be here
  153.     turtle.turnRight()
  154.     for i = 1,3 do
  155.         mov.forward()
  156.     end
  157.     turtle.turnLeft()
  158.     mov.forward()
  159.     if a == 1 or a == 3 then
  160.         for i = 1,3 do
  161.         mov.down()
  162.         end
  163.     elseif a == 2 or a == 4 then
  164.         for i = 1,3 do
  165.         mov.up()
  166.         end
  167.     end
  168. end
  169.  
  170. while turtle.down() do -- brings turtle down
  171. end
  172. turtle = tMove
  173. print("Finished")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement