Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local length = 40
- local height = 5
- local width = 5
- local function select_block()
- for slot=1,16 do
- if turtle.getItemCount(slot) ~= 0 then
- turtle.select(slot)
- return true
- end
- end
- return false
- end
- local function build_step()
- if select_block() then
- turtle.placeDown()
- return true
- end
- return false
- end
- local function build_line()
- for i=1, length-1 do
- build_step()
- turtle.forward()
- end
- build_step()
- end
- local function build_flat()
- for i=1, width -1 do
- build_line()
- if math.fmod(i, 2) == 1 then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- build_line()
- end
- local function build_volume()
- for i=1, height-1 do
- build_flat()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.up()
- end
- build_flat()
- if math.fmod(height, 2) == 1 then
- turtle.turnLeft()
- for i=1, width-1 do
- turtle.forward()
- end
- turtle.turnLeft()
- for i=1, length-1 do
- turtle.forward()
- end
- end
- turtle.forward()
- for i=1, height do
- turtle.down()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- need_fuel = height*width*length+length+width+height
- print("Fuel: "..turtle.getFuelLevel())
- print("Need: "..need_fuel)
- if turtle.getFuelLevel() > need_fuel then
- turtle.up()
- build_volume()
- else
- print("not enough fuel!!!")
- end
- print("Fuel: "..turtle.getFuelLevel())
Add Comment
Please, Sign In to add comment