Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function setFacingAngle(FacingAngle, WishedFacingAngle)
- if FacingAngle < WishedFacingAngle then
- for DiffFacingAngle = 1, (WishedFacingAngle - FacingAngle) do
- turtle.turnRight()
- FacingAngle = FacingAngle + 1
- end
- elseif FacingAngle > WishedFacingAngle then
- for DiffFacingAngle = 1, (FacingAngle - WishedFacingAngle) do
- turtle.turnLeft()
- FacingAngle = FacingAngle - 1
- end
- end
- return FacingAngle
- end
- local function refuel(coal_slot)
- turtle.select(coal_slot)
- boolRefuel = turtle.refuel(1)
- if boolRefuel then
- refuel_count = 0
- print("Successfully Refueled")
- else
- print("Out of fuel")
- while not(turtle.refuel(1)) do
- setFacingAngle(FacingAngle, FacingAngle + 2)
- setFacingAngle(FacingAngle, FacingAngle - 2)
- end
- end
- turtle.select(1)
- return refuel_count
- end
- local function moveForward(done_lenght, BoolIncreasingLenght, FacingAngle, Boolfb, moving_integer, digUpBool, refuel_count)
- local moving_count = 1
- for moving_count=1,moving_integer do
- if (refuel_count == 80) then
- refuel_count = refuel(2)
- end
- Bool1 = false
- while not(Bool1) do
- if (Boolfb) then
- turtle.dig()
- Bool1 = turtle.forward()
- if (digUpBool) then
- turtle.digUp()
- end
- else
- Bool1 = turtle.back()
- if not(Bool1) then
- setFacingAngle(FacingAngle, (FacingAngle + 2))
- turtle.dig()
- setFacingAngle(FacingAngle, (FacingAngle - 2))
- end
- end
- end
- moving_count = moving_count + 1
- refuel_count = refuel_count + 1
- if BoolIncreasingLenght then
- done_lenght = done_lenght + 1
- end
- end
- return done_lenght, refuel_count
- end
- local function moveUp(YPosition, Boolud, moving_integer, refuel_count)
- local moving_count = 1
- for moving_count=1,moving_integer do
- if (refuel_count == 80) then
- refuel_count = refuel(2)
- end
- Bool2 = false
- while not(Bool2) do
- if (Boolud) then
- turtle.digUp()
- Bool2 = turtle.up()
- else
- turtle.digDown()
- Bool2 = turtle.down()
- end
- end
- moving_count = moving_count + 1
- if (Boolud) then
- YPosition = YPosition + 1
- else
- YPosition = YPosition - 1
- end
- refuel_count = refuel_count + 1
- end
- return YPosition, refuel_count
- end
- local function inventoryManagement(saved_slots,refuel_count)
- turtle.select(1)
- n = saved_slots + 1
- repeat
- item_count = turtle.getItemCount(n)
- if (item_count ~= 0) then
- boolSlotOccupied = true
- n = n + 1
- else
- boolSlotOccupied = false
- end
- until (boolSlotOccupied == false) or (n == 17)
- if (n == 17) then
- print("Inventory full")
- FacingAngle = setFacingAngle(FacingAngle, (FacingAngle - 1))
- done_lenght , refuel_count = moveForward(done_lenght, false, FacingAngle, true, 1, true, refuel_count)
- done_lenght , refuel_count = moveForward(done_lenght, false, FacingAngle, false, 1, false, refuel_count)
- turtle.select(3)
- turtle.place()
- for u=(saved_slots+1),16 do
- turtle.select(u)
- turtle.drop()
- end
- turtle.select(1)
- FacingAngle = setFacingAngle(FacingAngle, (FacingAngle + 1))
- else
- print("Inventory OK")
- end
- return refuel_count
- end
- YPosition = 10
- FacingAngle = 2
- coal_slot = 2
- print("Please place torches in the first slot, coal in the second one and chests in the third one")
- print("How many parallel tunnels are you willing to dig ?")
- tunnels_integer = read()
- print("How long do you want each tunnel to be ?")
- tunnels_lenght = read()
- print("How many blocks do you want between two tunnels ?")
- tunnels_separation = read()
- local a = 1
- local i=1
- local refuel_count = 0
- refuel(2)
- YPosition, refuel_count = moveUp(YPosition, true, 1, refuel_count)
- for a=1,tunnels_integer do
- done_lenght = 0
- for i=1,(tunnels_lenght-done_lenght) do
- done_lenght, refuel_count = moveForward(done_lenght, true, FacingAngle, true, 1, true, refuel_count)
- turtle.digDown()
- if (0 == i%10) then
- turtle.turnRight()
- turtle.dig()
- turtle.place()
- turtle.turnLeft()
- end
- refuel_count = inventoryManagement(3,refuel_count)
- print("Momentum left before refueling: "..(80-refuel_count))
- end
- done_lenght, refuel_count = moveForward(done_lenght, false, FacingAngle, false, tunnels_lenght, true, refuel_count)
- FacingAngle = setFacingAngle(FacingAngle, (FacingAngle - 1))
- done_lenght, refuel_count = moveForward(done_lenght, false, FacingAngle, true, (tunnels_separation+1), false, refuel_count)
- FacingAngle = setFacingAngle(FacingAngle, (FacingAngle + 1))
- a = a + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement