Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- How to use...
- Place the turle between 2 blocks and write "room <lenght> <with>"
- BLOCK
- TURTLE
- BLOCK
- ]]--
- local args = {...}
- local xCurrent, zCurrent = 1, 1
- local xMax, zMax
- local facing = 0 --start 0, gedreht 1
- if #args == 2 then
- xMax = tonumber(args[1])
- zMax = tonumber(args[2])
- elseif #args==0 then
- xMax, zMax = 3, 3
- end
- function clearInventory()
- if turtle.getItemDetail(1).name=="enderstorage:ender_storage" then
- if turtle.detectDown() then
- turtle.digDown()
- end
- turtle.select(1)
- turtle.placeDown()
- for selSlot = 2,16 do
- turtle.select(selSlot)
- turtle.dropDown()
- end
- turtle.select(1)
- turtle.digDown()
- end
- end
- function dig()
- if turtle.detectUp() then
- turtle.digUp()
- end
- if turtle.detect() then
- a, data = turtle.inspect()
- if data.name =="minecraft:sand" or data.name == "minecraft:gravel" then
- while turtle.detect() do
- turtle.dig()
- sleep(1)
- data = turtle.inspect()
- end
- else
- turtle.dig()
- end
- end
- if turtle.detectDown() then
- turtle.digDown()
- end
- end
- function digUpDown()
- if turtle.detectUp() then
- turtle.digUp()
- end
- if turtle.detectDown() then
- turtle.digDown()
- end
- end
- function digForward()
- while xCurrent < xMax do
- dig()
- turtle.forward()
- xCurrent = xCurrent +1
- end
- end
- function rotate()
- if facing==0 then
- turtle.turnRight()
- dig()
- turtle.forward()
- turtle.turnRight()
- facing = 1
- else
- if facing==1 then
- turtle.turnLeft()
- dig()
- turtle.forward()
- turtle.turnLeft()
- facing = 0
- end
- end
- end
- function returnZ()
- turtle.turnRight()
- while zCurrent>1 do
- turtle.forward()
- zCurrent = zCurrent-1
- end
- turtle.turnRight()
- end
- function ende()
- if facing==0 then
- digUpDown()
- turtle.turnLeft()
- turtle.turnLeft()
- xCurrent = 1
- while xCurrent < xMax do
- turtle.forward()
- xCurrent = xCurrent+1
- end
- returnZ()
- elseif facing==1 then
- digUpDown()
- returnZ()
- clearInventory()
- end
- end
- function start()
- running = true
- while running do
- if xCurrent==xMax then
- clearInventory()
- rotate()
- xCurrent = 1
- zCurrent = zCurrent+1
- end
- digForward()
- if zCurrent==zMax then
- running=false
- end
- end
- ende()
- clearInventory()
- end
- --Begin
- if #args == 2 then
- start()
- elseif #args == 0 then
- start()
- else
- print("Usage: room <x> <z>")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement