Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --v2.1 by GraySloth 2013-Feb-23
- --here is an old video demonstration of my scripts, it is almost good. http://youtu.be/9vhl7dSENs8
- local tArgs = { ... }
- if #tArgs ~= 2 then
- print( "Usage: stairs [up|down] <#height>" )
- return
- end
- local size = tonumber( tArgs[2] )
- if size < 1 then
- print( "stairs height must be positive" )
- return
- end
- --functions
- function fuelCheck()
- if turtle.getFuelLevel() == "unlimited" then
- return true
- elseif turtle.getFuelLevel() < 2 then
- print("Traveled "..dist.." of "..tArgs[2]..", Need more fuel")
- print("Searching for fuel hold ctrl+t to stop")
- while turtle.getFuelLevel() < 10 do
- for n=1,16 do
- if turtle.getFuelLevel() < 10 then
- turtle.select(n)
- turtle.refuel(1)
- end
- end
- end
- print("Refueled: "..turtle.getFuelLevel())
- end
- end
- local dist = 0
- function count()
- dist = dist + 1
- if (math.fmod( dist, 8 ) == 0) or (math.fmod( dist, tArgs[2] ) == 0) then
- print("Traveled "..dist.." of "..tArgs[2]..", Fuel: "..turtle.getFuelLevel())
- end
- end
- --Main
- local stop = 0
- print("Fuel level: "..turtle.getFuelLevel())
- if (tArgs[1] == ("down")) or (tArgs[1] == ("dn")) then
- for i = 1, size do
- fuelCheck()
- if turtle.digDown() then
- stop = 0
- else
- stop = stop + 1
- end
- turtle.down()
- turtle.dig()
- while not turtle.forward() do
- turtle.dig()
- end
- turtle.digUp()
- count()
- if stop == 4 then
- print("Traveled "..dist.." of "..tArgs[2]..", Fuel: "..turtle.getFuelLevel())
- print("stopped")
- return
- end
- end
- elseif tArgs[1] == ("up") then
- for i = 1, size do
- fuelCheck()
- turtle.dig()
- while not turtle.forward() do
- turtle.dig()
- end
- if turtle.digUp() then
- stop = 0
- else
- stop = stop + 1
- end
- turtle.up()
- turtle.digUp()
- count()
- if stop == 4 then
- print("Traveled "..dist.." of "..tArgs[2]..", Fuel: "..turtle.getFuelLevel())
- print("stopped")
- return
- end
- end
- else
- print( "Usage: stairs <up|down> <height>" )
- return
- end
- print("Done")
Advertisement
Add Comment
Please, Sign In to add comment