Advertisement
erice0703

TvTurtle

Feb 29th, 2024 (edited)
937
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.70 KB | None | 1 0
  1. local modem = peripheral.find("modem")
  2. local xi,yi,zi = gps.locate()
  3. local xf,yf,zf = 5600, 152, 1306
  4.  
  5. local function GrabItems()
  6.     local wool, monitor, computer = false, false, false
  7.     repeat
  8.         turtle.select(1)
  9.         turtle.suckUp()
  10.         local item = turtle.getItemDetail()
  11.         if item.name == "minecraft:white_wool" then
  12.             turtle.transferTo(5)
  13.             wool = true
  14.         elseif item.name == "computercraft:monitor_advanced" then
  15.             turtle.transferTo(6)
  16.             monitor = true
  17.         elseif item.name == "computercraft:computer_advanced" then
  18.             turtle.transferTo(7)
  19.             computer = true
  20.         end
  21.     until wool == true and monitor == true and computer == true
  22. end
  23.  
  24. local function Down(y)
  25.     local yf = y
  26.     local xi,yi,zi = gps.locate()
  27.     turtle.forward()
  28.     while yi ~= yf do
  29.         turtle.down()
  30.         xi,yi,zi = gps.locate()
  31.     end
  32. end
  33.    
  34. local function moveX(x,z)
  35.     local x,z = x,z
  36.     local xi,yi,zi = gps.locate()
  37.     turtle.turnLeft()
  38.     local difx = math.abs(x-xi)
  39.     for i=1,difx do
  40.     turtle.forward()
  41.     end
  42. end
  43.  
  44. local function moveZ(x,z)
  45.     local x,z = x,z
  46.     local xi,yi,zi = gps.locate()
  47.     turtle.turnRight()
  48.     local difz = math.abs(z-zi)
  49.     for i =1,difz do
  50.     turtle.forward()
  51.     end
  52. end
  53.  
  54. local function PlaceUp()
  55.     turtle.place()
  56.     turtle.up()
  57.     turtle.place()
  58. end
  59.  
  60. local function PlaceDown()
  61.     turtle.place()
  62.     turtle.down()
  63.     turtle.place()
  64. end
  65. local function ForwardRight()
  66.     turtle.turnRight()
  67.     turtle.forward()
  68.     turtle.turnLeft()
  69. end
  70. local function ForwardLeft()
  71.     turtle.turnLeft()
  72.     turtle.forward()
  73.     turtle.turnRight()
  74. end
  75. local function backing()
  76.     turtle.select(5)
  77.     PlaceUp()
  78.     ForwardLeft()
  79.     PlaceDown()
  80.     ForwardLeft()
  81.     PlaceUp()
  82. end
  83.  
  84.  
  85. local function PlaceTV()
  86.     turtle.select(6)
  87.     turtle.back()
  88.    
  89.     PlaceDown()
  90.     ForwardRight()
  91.     PlaceUp()
  92.     ForwardRight()
  93.     PlaceDown()
  94. end
  95.  
  96. local function PlaceComputer()
  97.     turtle.select(7)
  98.     turtle.back()
  99.     turtle.turnLeft()
  100.     turtle.back()
  101.     turtle.place()
  102.    
  103. end
  104. local function Dig()
  105.     turtle.dig()
  106.     turtle.forward()
  107.     turtle.digUp()
  108. end
  109. local function RemoveBacking()
  110.     turtle.turnRight()
  111.     turtle.forward()
  112.     turtle.turnLeft()
  113.     turtle.forward()
  114.     turtle.forward()
  115.     turtle.turnLeft()
  116.     Dig()
  117.     turtle.forward()
  118.     Dig()
  119.     turtle.forward()
  120.     Dig()
  121. end
  122.  
  123. local function Return()
  124.     local x,y,z = 5600, 155, 1308
  125.     local xi,yi,zi = gps.locate()
  126.     turtle.down()
  127.     turtle.forward()
  128.     turtle.turnLeft()
  129.     for i=1,(math.abs(x-xi)) do
  130.         turtle.forward()
  131.     end
  132.     for i=1,3 do
  133.         turtle.up()
  134.     end
  135.     turtle.forward()
  136.     turtle.turnRight()
  137.     turtle.turnRight()
  138.  
  139. end
  140.  
  141.  
  142. GrabItems()
  143. Down(yf)
  144. moveX(xf,zf)
  145. turtle.turnRight()
  146. turtle.up()
  147. turtle.forward()
  148. turtle.turnRight()
  149. backing()
  150. PlaceTV()
  151. RemoveBacking()
  152. PlaceComputer()
  153. sleep(0.1)
  154. local pc = peripheral.wrap("front")
  155. pc.turnOn()
  156. Return()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement