Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SPONGER
- -- NEEDS TO BE FACING POSITIVE X
- sponge_slot = 1
- fuel_slot = 2
- sponge_distance = 6
- move_counter = 79 -- trigger immediately
- init_x = 0
- init_y = 0
- init_z = 0
- x = init_x
- y = init_y
- z = init_z
- print("Enter # of blocks\n")
- print("forward\n")
- sponge_x = tonumber(io.read())
- print("Enter # of blocks\n")
- print("vertical\n")
- print(" (probably negative)\n")
- sponge_y = tonumber(io.read())
- print("Enter # of blocks\n")
- print("to the right\n")
- sponge_z = tonumber(io.read())
- function sponge_it()
- turtle.dig() -- remove potential block
- turtle.place()
- turtle.dig()
- end
- function turtle_down()
- if turtle.detectDown() then
- return true
- else
- y = y - 1
- refuel_every_eighty()
- turtle.down()
- return false
- end
- end
- function refuel_every_eighty()
- move_counter = move_counter + 1
- if move_counter >= 80 then
- move_counter = 0
- if turtle.getItemCount(fuel_slot) <= 1 then -- leave one always
- fuel_slot = fuel_slot + 1
- if fuel_slot >= 17 then
- exit()
- end
- end
- turtle.select(fuel_slot)
- turtle.refuel(1)
- turtle.select(sponge_slot)
- end
- end
- function sponge_y_way()
- local cant_go_down = false
- for i_sponge_y = 1, math.floor(math.abs(sponge_y / sponge_distance)) do
- for move_y = 1, sponge_distance do
- if sponge_y < 0 then
- cant_go_down = turtle_down()
- if cant_go_down then break end-- if can't go down any further, go back up (for clearing ocean floors)
- else
- y = y + 1
- refuel_every_eighty()
- turtle.up()
- end
- end
- sponge_it()
- if cant_go_down then break end-- if can't go down any further, go back up (for clearing ocean floors)
- end
- for move_y = 1, math.abs(init_y - y) do
- if sponge_y < 0 then
- y = y + 1
- refuel_every_eighty()
- turtle.up()
- else
- y = y - 1
- refuel_every_eighty()
- turtle.down()
- end
- end
- end
- function sponge_x_way()
- if sponge_x < 0 then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- for i_sponge_x = 1, math.floor(math.abs(sponge_x / sponge_distance)) do
- sponge_it()
- sponge_y_way()
- for move = 1, sponge_distance do
- refuel_every_eighty()
- turtle.forward()
- if sponge_x < 0 then
- x = x - 1
- else
- x = x + 1
- end
- end
- end
- sponge_it()
- sponge_y_way()
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1, math.abs(init_x - x) do
- refuel_every_eighty()
- turtle.forward()
- if sponge_x < 0 then
- x = x + 1
- else
- x = x - 1
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function sponge_x_z_way()
- for move_z_i = 1, math.floor(math.abs(sponge_z / sponge_distance)) do
- sponge_x_way()
- if sponge_z < 0 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- for move_z = 1, sponge_distance do
- refuel_every_eighty()
- turtle.forward()
- if sponge_z < 0 then
- z = z - 1
- else
- z = z + 1
- end
- end
- if sponge_z < 0 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- if move_z_i == math.floor(math.abs(sponge_z / sponge_distance)) then
- sponge_x_way()
- end
- end
- if sponge_z < 0 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- for i = 1, math.abs(init_y - y) do
- refuel_every_eighty()
- turtle.forward()
- if sponge_z < 0 then
- z = z + 1
- else
- z = z - 1
- end
- end
- if sponge_z < 0 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- sponge_x_z_way()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement