Skip to content

Instantly share code, notes, and snippets.

@Yepoleb
Created January 4, 2015 18:07
Show Gist options
  • Save Yepoleb/25027df58f87aab8e8e8 to your computer and use it in GitHub Desktop.
Save Yepoleb/25027df58f87aab8e8e8 to your computer and use it in GitHub Desktop.
local tArgs = { ... }
if #tArgs < 3 then
print("Usage: mine {1,2,3} <x> <y> [params]")
return
end
local height = tonumber(tArgs[1])
local def1 = tonumber(tArgs[2])
local def2 = tonumber(tArgs[3])
local rot = "l"
local ups = 3
local remain = height % 3
local chest = false
if #tArgs > 3 then
if string.find(tArgs[4], "r") ~= nil then
rot = "r"
elseif string.find(tArgs[4], "l") ~= nil then
rot = "l"
end
if string.find(tArgs[4], "f") ~= nil then
def1 = tonumber(tArgs[3])
def2 = tonumber(tArgs[2])
if rot == "r" then
turtle.turnRight()
rot = "l"
elseif rot == "l" then
turtle.turnLeft()
rot = "r"
end
end
if string.find(tArgs[4], "c") ~= nil then
chest = true
end
end
if turtle.detectDown() and (height >= 3) then
while turtle.up() == false do
turtle.digUp()
end
turtle.digUp()
end
function layer(mode)
for county = 1, def2 do
-- print("Y: " .. county)
for countx = 2, def1 do
-- print("X: " .. countx)
turtle.dig()
while turtle.forward() == false do
turtle.dig()
end
if mode > 1 then
turtle.digUp()
if mode > 2 then
turtle.digDown()
end
end
if turtle.getItemCount(16) > 0 then
turtle.select(1)
if chest == true then
turtle.placeDown()
for slot = 2, 16 do
turtle.select(slot)
if turtle.dropDown() == false then
print("Couldn't put items into the chest. Fix it and press enter!")
read()
end
turtle.select(1)
end
else
print("Fuel: " .. turtle.getFuelLevel())
write("Please press enter")
read()
turtle.refuel()
end
end
if turtle.getFuelLevel() < 1 then
write("Please put fuel into the inventory and press enter")
read()
turtle.refuel()
end
end
if rot == "r" then
turtle.turnRight()
turtle.dig()
while turtle.forward() == false do
turtle.dig()
end
if mode > 1 then
turtle.digUp()
if mode > 2 then
turtle.digDown()
end
end
turtle.turnRight()
rot = "l"
elseif (rot == "l") and (county < def2) then
turtle.turnLeft()
turtle.dig()
while turtle.forward() == false do
turtle.dig()
end
if mode > 1 then
turtle.digUp()
if mode > 2 then
turtle.digDown()
end
end
turtle.turnLeft()
rot = "r"
end
end
end
for counth = 1, math.floor(height / 3) do
layer(3)
print (counth .. math.floor(height / 3))
if ((counth == math.floor(height / 3)) and (remain == 0)) == false then
if counth < math.floor(height / 3) or remain == 0 then
ups = 3
else
ups = 2
end
print(ups)
for countup = 1, ups do
while turtle.up() == false do
turtle.digUp()
end
end
turtle.turnRight()
turtle.turnRight()
end
if remain ~= 1 then
turtle.digUp()
end
end
if remain > 0 then
layer(remain)
end
print("Fuel: " .. turtle.getFuelLevel())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment