Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- -- turtle.select(1)
- -- local slot=1
- local function refuel()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel == "unlimited" or fuelLevel > 0 then
- return
- end
- local function tryRefuel()
- for n=1,16 do
- if turtle.getItemCount(n) > 0 then
- turtle.select(n)
- if turtle.refuel(1) then
- turtle.select(1)
- return true
- end
- end
- end
- turtle.select(1)
- return false
- end
- if not tryRefuel() then
- print( "Add more fuel to continue." )
- while not tryRefuel() do
- sleep(1)
- end
- print( "Resuming..." )
- end
- end
- function turnR(n)
- if n == nil then n=1 end
- for i = 1,n do
- turtle.turnRight()
- end
- end
- function turnL(n)
- if n == nil then n=1 end
- for i = 1,n do
- turtle.turnLeft()
- end
- end
- function go(n)
- refuel()
- if n == nil then n=1 end
- for i = 1,n do
- turtle.forward()
- end
- end
- function back(n)
- refuel()
- if n == nil then n=1 end
- for i = 1,n do
- turtle.back()
- end
- end
- function down(n)
- refuel()
- if n == nil then n=1 end
- for i = 1,n do
- if not turtle.down() then
- return false
- end
- end
- return true
- end
- function up(n)
- refuel()
- if n == nil then n=1 end
- for i = 1,n do
- turtle.up()
- end
- end
- function place(item)
- function checkRessources()
- if item == "block" then
- turtle.select(1)
- for i = 1,4 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- return true
- end
- end
- elseif item == "stair" then
- turtle.select(5)
- for i = 5,8 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- return true
- end
- end
- end
- return false
- end
- if not checkRessources() then
- print( "Add more Ressources to continue." )
- while not checkRessources() do
- sleep(1)
- end
- print( "Resuming..." )
- end
- turtle.place()
- end
- function placeDown(item)
- function checkRessources()
- if item == "block" then
- turtle.select(1)
- for i = 1,4 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- return true
- end
- end
- elseif item == "stair" then
- turtle.select(5)
- for i = 5,8 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- return true
- end
- end
- end
- return false
- end
- if not checkRessources() then
- print( "Add more Ressources to continue." )
- while not checkRessources() do
- sleep(1)
- end
- print( "Resuming..." )
- end
- turtle.placeDown()
- end
- -- find start pos
- go(2)
- turnR()
- go()
- down()
- -- loop
- local done=false
- while not done do
- place("block")
- turnR()
- back()
- place("block")
- turnR()
- back()
- place("block")
- turnL()
- back()
- place("block")
- back()
- for i = 1,3 do
- place("stair")
- if not down() then done=true break end
- place("block")
- up()
- if i % 2 == 0 then
- turnL()
- else
- turnR()
- end
- go()
- if i % 2 == 0 then
- turnR()
- else
- turnL()
- end
- place("stair")
- if not down() then done= true break end
- place("block")
- back()
- end
- end
- print("finished")
- --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement