Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local distance = 0
- local width = 0
- local direction = 0
- local multi = 0
- local multiCounter = 0
- local torchCounter = 0
- local tracker = 0
- local torchSlot = 0
- local buildSlot = 0
- function forward(a)
- local i = 0
- while i < a do
- while turtle.detectUp() do
- turtle.digUp()
- end
- while turtle.detect() do
- turtle.dig()
- end
- if turtle.forward() then
- tracker = tracker + 1
- end
- if turtle.detectDown() == false then
- for i = 1, 16 do
- local item_data = turtle.getItemDetail(i)
- if item_data then
- if item_data.name == "minecraft:cobblestone" then
- buildSlot = i
- print("New Build Slot: ", buildSlot)
- break
- end
- end
- end
- turtle.select(buildSlot)
- turtle.placeDown()
- turtle.select(1)
- end
- torchCounter = torchCounter + 1
- torchCheck()
- i = i+1
- end
- end
- function turn()
- if direction == 0 then
- turtle.turnLeft()
- elseif direction == 1 then
- turtle.turnRight()
- end
- forward(width+1)
- if direction == 0 then
- turtle.turnLeft()
- direction = 1
- elseif direction == 1 then
- turtle.turnRight()
- direction = 0
- end
- end
- function torchCheck()
- if torchCounter >= 11 then
- for i = 1, 16 do
- local item_data = turtle.getItemDetail(i)
- if item_data then
- if item_data.name == "minecraft:torch" then
- torchSlot = i
- print("New Torch Slot: ", torchSlot)
- break
- end
- end
- end
- turtle.select(torchSlot)
- if turtle.getItemCount() >= 1 then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.place()
- torchCounter = 0
- turtle.turnLeft()
- turtle.turnLeft()
- end
- turtle.select(1)
- end
- end
- function checkIfFuel()
- return turtle.refuel(0)
- end
- function refuel()
- local fuelLimit = turtle.getFuelLimit()
- if turtle.getFuelLevel() < (fuelLimit / 8) then
- print("Fuel Limit: ", fuelLimit)
- print("Current Fuel: ", turtle.getFuelLevel())
- for i = 1, 16 do
- turtle.select(i)
- if checkIfFuel() then
- turtle.refuel()
- end
- end
- end
- end
- function transfer()
- if direction == 1 then
- turtle.turnLeft()
- elseif direction == 0 then
- turtle.turnRight()
- end
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.up()
- for i = 1, multiCounter * (2 * width + 2) do
- while turtle.detect() do
- turtle.dig()
- end
- if turtle.forward() then
- tracker = tracker + 1
- end
- end
- turtle.down()
- if direction == 1 then
- turtle.turnLeft()
- elseif direction == 0 then
- turtle.turnRight()
- end
- end
- function checkInventory()
- empty_slots = 0
- for i = 1, 16 do
- if turtle.getItemCount(i) == 0 then
- empty_slots = empty_slots + 1
- end
- end
- if empty_slots <= 3 then
- transfer()
- clearInventory()
- transfer()
- end
- end
- function clearInventory()
- for i = 1, 16 do
- local item_data = turtle.getItemDetail(i)
- if item_data then
- if item_data.name ~= "minecraft:torch" then
- turtle.select(i)
- turtle.drop()
- end
- end
- end
- end
- function start()
- print("Starting!")
- os.sleep(2)
- print("Fuel Limit: ", turtle.getFuelLimit())
- print("Current Fuel: ", turtle.getFuelLevel())
- turtle.select(1)
- while multiCounter < multi do
- checkInventory()
- forward(distance)
- turn()
- forward(distance)
- turn()
- refuel()
- multiCounter = multiCounter + 1
- end
- transfer()
- clearInventory()
- turtle.turnLeft()
- turtle.turnLeft()
- print("Dunsoo!")
- print("I moved ", tracker, "blocks! :)")
- end
- print("Welcome to Voxxels Stripmining program")
- print("-----------------------------------")
- print("How far do you want to go?")
- input1 = io.read()
- distance = tonumber(input1)
- print("-----------------------------------")
- print("How many blocks between the tunnels?")
- input2 = io.read()
- width = tonumber(input2)
- print("----------------------------------")
- print("Left or Right?")
- print("(0 = Left ; 1 = Right)")
- input3 = io.read()
- direction = tonumber(input3)
- print("----------------------------------")
- print("Ok almost done.")
- print("How often should I repeat that?")
- input4 = io.read()
- multi = tonumber(input4)
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement