Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- STAIR = 1
- SLAB = 2
- FUEL = 16
- N = 3
- function wait_for_enough_fuel(minLevel, slot)
- local qty = 0
- local refuel = function()
- turtle.select(slot)
- turtle.refuel()
- qty = turtle.getFuelLevel()
- print("fuel: ",qty)
- return qty
- end
- while refuel() < minLevel do
- print(string.format("Insert fuel-items into slot %d: %d/%d", slot, qty, minLevel))
- os.sleep(1)
- os.pullEvent("turtle_inventory")
- end
- end
- function set_block(slot, direction)
- turtle.select(slot)
- if direction==nil then
- turtle.place()
- elseif direction=="bottom" then
- turtle.placeDown()
- elseif direction=="top" then
- turtle.placeUp()
- end
- end
- function slide(direction, n)
- if direction == "left" then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- elseif direction=="right" then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- function stair3()
- turtle.forward()
- if not turtle.detectDown() then set_block(SLAB, "bottom") end
- turtle.back()
- set_block(STAIR)
- slide("left")
- turtle.forward()
- if not turtle.detectDown() then set_block(SLAB, "bottom") end
- turtle.back()
- set_block(STAIR)
- slide("left")
- turtle.forward()
- if not turtle.detectDown() then set_block(SLAB, "bottom") end
- turtle.back()
- set_block(STAIR)
- end
- -- main
- local args = {...}
- if args and args[1] then N = tonumber(args[1]) end
- wait_for_enough_fuel(100, FUEL)
- for i=1,N do
- stair3()
- turtle.up()
- turtle.forward()
- turtle.forward()
- set_block(SLAB, "bottom")
- set_block(SLAB, "bottom")
- slide("right")
- set_block(SLAB)
- turtle.turnRight()
- turtle.forward()
- set_block(SLAB,"bottom")
- set_block(SLAB,"bottom")
- turtle.back()
- set_block(STAIR)
- turtle.turnLeft()
- set_block(SLAB,"bottom")
- set_block(SLAB,"bottom")
- turtle.back()
- slide("right")
- turtle.up()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- set_block(SLAB, "bottom")
- slide("left")
- set_block(SLAB, "bottom")
- slide("right")
- slide("right")
- end
- --[[
- while true do
- local text = read()
- if text == "exit()" then break end
- local func = loadstring(text)
- setfenv(func, getfenv()) -- change func's environment(_G) to current one.
- local results = {pcall(func)} -- table: 1) exist_status, 2) run_status, 3) err_msg
- end
- --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement