Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = 10
- y = 10
- z = -10
- a = 1000
- cx = 1
- cy = -1
- cz = 0
- ca = 1000
- xb = x - 1
- yb = y - 1
- turtle_num = 1
- total_turtles = 2
- xc = xb - total_turtles
- store_x = -1
- store_y = -2
- store_z = turtle_num + 2
- cobble = 16
- filter = 1
- chest = 2
- cobble2 = 3
- ox = cx
- oy = cy
- oz = cz
- --functions
- function co()
- print(" x " .. cx .. " y " .. cy .. " z " .. cz .. " Angled at " .. ca)
- end
- function bull_up()
- if (turtle.detectUp() == false) then
- turtle.up()
- else
- repeat
- turtle.digUp()
- sleep(0.5)
- until turtle.detectUp() == false
- turtle.up()
- end
- end
- function bull_down()
- if (turtle.detectDown() == false) then
- turtle.down()
- else
- repeat
- turtle.digDown()
- sleep(0.5)
- until turtle.detectDown() == false
- turtle.down()
- end
- end
- function a_in()
- ca = ca + 90
- co()
- end
- function a_de()
- ca = ca - 90
- co()
- end
- function tl()
- turtle.turnLeft()
- a_in()
- end
- function tr()
- turtle.turnRight()
- a_de()
- end
- function t_180l()
- tl()
- tl()
- end
- function t_180r()
- tr()
- tr()
- end
- function x_in()
- cx = cx + 1
- co()
- end
- function x_de()
- cx = cx - 1
- co()
- end
- function y_in()
- cy = cy + 1
- co()
- end
- function y_de()
- cy = cy - 1
- co()
- end
- function z_in()
- cz = cz + 1
- co()
- end
- function z_de()
- cz = cz - 1
- co()
- end
- -- SAVING POSITION
- function save()
- xsave = cx
- ysave = cy
- zsave = cz
- asave = ca
- print("saving ")
- co()
- end
- -- REALIGNING AND LOCATING
- function realign_p()
- print("realigning")
- end
- function realign_0()
- realign_p()
- while (ca > a) do
- tr()
- end
- while (ca < a) do
- tl()
- end
- end
- function calibrate_x()
- realign_0()
- tr()
- while (turtle.detect() == false) do
- turtle.forward()
- x_de()
- end
- tl()
- cx = 1
- tl()
- while (turtle.detect() == false) do
- turtle.forward()
- x_in()
- end
- tr()
- x = cx
- tr()
- while (turtle.detect() == false) do
- turtle.forward()
- x_de()
- end
- tl()
- cx = 1
- end
- function calibrate_y()
- realign_0()
- t_180l()
- while (turtle.detect() == false) do
- turtle.forward()
- y_de()
- end
- t_180r()
- cy = 1
- while (turtle.detect() == false) do
- turtle.forward()
- y_in()
- end
- y = cy
- t_180l()
- while (turtle.detect() == false) do
- turtle.forward()
- y_de()
- end
- t_180r()
- end
- function calibrate_z()
- realign_0()
- while (turtle.detectUp() == false) do
- turtle.up()
- z_de()
- end
- cz = 1
- end
- function calibrate()
- calibrate_z()
- calibrate_x()
- calibrate_y()
- end
- function locate_store_z()
- if cz == store_z == false then
- while (cz < store_z) do
- turtle.up()
- z_in()
- end
- while (cz > store_z) do
- turtle.down()
- z_de()
- end
- end
- end
- function locate_store_x()
- while cx == store_x == false do
- if cx > store_x then
- tr()
- repeat
- turtle.forward()
- x_de()
- until cx == store_x
- tl()
- else
- tl()
- repeat
- turtle.forward()
- x_in()
- until cx == store_x
- tr()
- end
- end
- end
- function locate_store_y()
- while cy == store_y == false do
- if cy > store_y then
- t_180l()
- repeat
- turtle.forward()
- y_de()
- until cy == store_y
- t_180r()
- else
- repeat
- turtle.forward()
- y_in()
- until cy == store_y
- end
- end
- end
- function return_xsave()
- while cx == xsave == false do
- if cx > xsave then
- tr()
- repeat
- turtle.forward()
- x_de()
- until cx == xsave
- tl()
- else
- tl()
- repeat
- turtle.forward()
- x_in()
- until cx == xsave
- tr()
- end
- end
- end
- function return_ysave()
- while cy == ysave == false do
- if cy > ysave then
- t_180l()
- repeat
- turtle.forward()
- y_de()
- until cy == ysave
- t_180r()
- else
- repeat
- turtle.forward()
- y_in()
- until cy == ysave
- end
- end
- end
- function return_zsave()
- if cz == zsave == false then
- while (cz < zsave) do
- turtle.up()
- z_in()
- end
- while (cz > zsave) do
- turtle.down()
- z_de()
- end
- end
- end
- function return_ox()
- while cx == ox == false do
- if cx > ox then
- tr()
- repeat
- turtle.forward()
- x_de()
- until cx == ox
- tl()
- else
- tl()
- repeat
- turtle.forward()
- x_in()
- until cx == ox
- tr()
- end
- end
- end
- function return_oy()
- while cy == oy == false do
- if cy > oy then
- t_180l()
- repeat
- turtle.forward()
- y_de()
- until cy == oy
- t_180r()
- else
- repeat
- turtle.forward()
- y_in()
- until cy == oy
- end
- end
- end
- function return_oz()
- if cz == oz == false then
- while (cz < oz) do
- turtle.up()
- z_in()
- end
- while (cz > oz) do
- turtle.down()
- z_de()
- end
- end
- end
- -- PLACING
- function place_cobble_up()
- if (turtle.getItemCount(cobble) == 1) then
- cobble = cobble - 1
- end
- turtle.select(cobble)
- turtle.placeUp()
- turtle.select(1)
- end
- function place_cobble_down()
- if (turtle.getItemCount(cobble) == 1) then
- cobble = cobble - 1
- end
- turtle.select(cobble)
- turtle.placeDown()
- turtle.select(1)
- end
- function place_cobble()
- if (turtle.getItemCount(cobble) == 1) then
- cobble = cobble - 1
- end
- turtle.select(cobble)
- turtle.place()
- turtle.select(1)
- end
- function place_chest()
- turtle.select(chest)
- turtle.place()
- tr()
- turtle.forward()
- turtle.forward()
- tl()
- turtle.forward()
- tl()
- turtle.select(filter)
- turtle.place()
- tl()
- turtle.forward()
- tr()
- turtle.forward()
- turtle.forward()
- tr()
- turtle.select(1)
- end
- function locate_store()
- save()
- realign_0()
- turtle.digUp()
- turtle.up()
- z_in()
- turtle.up()
- z_in()
- place_cobble_down()
- zsave = cz
- locate_store_z()
- locate_store_x()
- locate_store_y()
- realign_0()
- t_180l()
- end
- function return_all()
- realign_0()
- return_ysave()
- return_xsave()
- return_zsave()
- turtle.digDown()
- turtle.down()
- z_de()
- turtle.down()
- z_de()
- place_cobble_up()
- realign_0()
- end
- function storing_setup()
- locate_store()
- place_chest()
- turtlechest = 1
- repeat
- turtle.up()
- z_in()
- place_chest()
- turtlechest = turtlechest + 1
- until turtlechest == total_turtles
- realign_0()
- return_all()
- end
- function storing()
- print("storing")
- save()
- locate_store()
- for num=1,15 do
- turtle.select(num)
- turtle.drop(64)
- sleep(1)
- end
- turtle.select(1)
- print("storing complete")
- return_all()
- end
- function storing_end()
- print("ending")
- save()
- locate_store()
- for num=1,15 do
- turtle.select(num)
- turtle.drop(64)
- sleep(1)
- end
- turtle.select(1)
- realign_0()
- print("program complete")
- end
- -- MAIN FUNCTIONS
- function realign_place_up()
- if (turtle.detectUp() == false) then
- place_cobble_up()
- end
- end
- function realign_place()
- if (turtle.detect() == false) then
- place_cobble()
- end
- end
- function realign_pad_rhs()
- realign_place_up()
- tr()
- realign_place()
- tl()
- end
- function realign_pad_lhs()
- tl()
- realign_place()
- tr()
- end
- function realign_pad_a()
- repeat
- realign_pad_rhs()
- turtle.forward()
- y_in()
- until cy == y
- realign_pad_rhs()
- realign_place()
- tl()
- end
- function realign_pad_b()
- repeat
- realign_pad_rhs()
- turtle.forward()
- x_in()
- until cx == x
- realign_pad_rhs()
- realign_place()
- tl()
- end
- function realign_pad_c()
- repeat
- realign_pad_rhs()
- turtle.forward()
- y_de()
- until cy == 1
- realign_pad_rhs()
- realign_place()
- tl()
- end
- function realign_pad_d()
- repeat
- realign_pad_rhs()
- turtle.forward()
- x_de()
- until cx == 1
- realign_pad_rhs()
- realign_place()
- tl()
- end
- function middle_pad_pos()
- turtle.forward()
- y_in()
- tl()
- turtle.forward()
- x_in()
- tr()
- end
- function middle_pad_a()
- repeat
- realign_place_up()
- turtle.forward()
- y_in()
- until cy == yb
- realign_place_up()
- t_180l()
- repeat
- turtle.forward()
- y_de()
- until cy == 2
- t_180l()
- end
- function mid_pad()
- middle_pad_pos()
- repeat
- middle_pad_a()
- tl()
- turtle.forward()
- tr()
- x_in()
- until cx == x
- end
- function align_pad()
- turtle.forward()
- y_in()
- turtle.forward()
- y_in()
- turtle.up()
- z_in()
- realign_pad_a()
- realign_pad_b()
- realign_pad_c()
- realign_pad_d()
- mid_pad()
- calibrate()
- storing_setup()
- turtle.down()
- z_de()
- tl()
- turtle_block = 1
- repeat
- turtle.forward()
- x_in()
- realign_pad_lhs()
- turtle_block = turtle_block + 1
- until turtle_block == total_turtles
- t_180l()
- repeat
- turtle.forward()
- x_de()
- until cx == 1
- realign_0()
- t_180l()
- turtle.forward()
- y_de()
- tr()
- turtle.dig()
- tl()
- turtle.forward()
- y_de()
- t_180l()
- realign_place()
- end
- function start()
- if turtle_num == 1 then
- align_pad()
- sleep(2)
- else
- repeat
- sleep(0.5)
- until turtle.detect() == true
- repeat
- sleep(0.5)
- until turtle.detect() == false
- sleep(2)
- turtle.forward()
- y_in()
- turtle.forward()
- y_in()
- calibrate()
- end
- if (turtle_num == total_turtles) then
- return_oz()
- repeat
- tl()
- turtle.dig()
- tr()
- turtle.forward()
- x_in()
- until cx == total_turtles
- return_oy()
- realign_0()
- sleep(5)
- else
- return_oz()
- return_ox()
- return_oy()
- realign_0()
- sleep(2)
- turtle.forward()
- y_in()
- tl()
- turtle.dig()
- tl()
- turtle.forward()
- y_de()
- realign_0()
- realign_place()
- repeat
- sleep(0.5)
- until turtle.detect() == false
- sleep (5)
- end
- end
- function dig_pos()
- repeat
- turtle.forward()
- y_in()
- until cy == 1
- calibrate_z()
- end
- function digging()
- realign_0()
- repeat
- bull_down()
- z_de()
- until cz == z
- calibrate_z()
- end
- function strip()
- if (turtle.detect() == false) then
- repeat
- turtle.forward()
- y_in()
- digging()
- storing()
- until turtle.detect() == true
- else
- calibrate_y()
- end
- end
- function next_row()
- return_oz()
- return_oy()
- locate_store_z()
- tl()
- rep = 0
- repeat
- turtle.forward()
- x_in()
- until rep == total_turtles
- turtle.down()
- z_de()
- turtle.down()
- z_de()
- realign_0()
- end
- function quarry()
- repeat
- dig_pos()
- strip()
- next_row()
- until cx > xc
- dig_pos()
- strip()
- storing_end()
- end
- start()
- quarry()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement