Last active
December 14, 2015 11:09
-
-
Save Deaygo/5077293 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
height = 4 | |
level = height - 1 | |
length = 16 | |
fuelslot = 1 | |
local tArgs = { ... } | |
if #tArgs ~= 3 then | |
print( "Usage: stairs <width> <height> <depth>" ) | |
return | |
end | |
height = tonumber(tArgs[2]) | |
level = height - 1 | |
length = tonumber(tArgs[1]) | |
depth = tonumber(tArgs[3]) | |
function movedown() | |
if turtle.detectDown() then | |
turtle.digDown() | |
end | |
turtle.down() | |
end | |
test = 20 | |
function moveup() | |
if turtle.detectUp() then | |
turtle.digUp() | |
end | |
turtle.up() | |
end | |
function turnright() | |
turtle.turnRight() | |
end | |
function moveforward() | |
while turtle.detect() do | |
turtle.dig() | |
end | |
turtle.forward() | |
end | |
function hasfuel() | |
if turtle.getFuelLevel() == 0 then | |
return true | |
end | |
tried = false | |
while turtle.getFuelLevel() < 64 do | |
turtle.select(1) | |
if not turtle.refuel(1) then | |
if not tried then | |
print("Waiting for fuel") | |
end | |
tried = true | |
sleep(5) | |
end | |
end | |
test = test - 1 | |
return test > 0 | |
end | |
function moveupMulti(i) | |
i = i - 1 | |
while i > 0 do | |
moveup() | |
i = i - 1 | |
end | |
end | |
distance = 0 | |
while hasfuel() do | |
level = height - 1 | |
while level > 0 do | |
movedown() | |
level = level - 1 | |
end | |
if depth <= 0 then | |
break | |
end | |
moveupMulti(height - 1) | |
distance = distance + 1 | |
if distance > length then | |
distance = 0 | |
turnright() | |
end | |
moveforward() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment