Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tArgs = { ... }
- if #tArgs ~= 2 then
- print( "Anwendung: stripmine <Laenge> <Reihen>" )
- return
- end
- length = tonumber(tArgs[1])
- amount = tonumber(tArgs[2])
- if length < 0 then
- print("Die Laenge muss positiv sein.")
- return
- end
- if amount < 0 then
- print("Die Anzahl der Reihen muss positiv sein.")
- return
- end
- function checkSpace()
- if turtle.getItemCount(14) == 1 then
- back()
- unload()
- proceed()
- end
- end
- function forward()
- while not turtle.forward() do
- turtle.dig()
- turtle.attack()
- sleep(0.1)
- end
- end
- function unload()
- print( "Inventar leeren..." )
- for n = 1,14 do
- turtle.select(n)
- turtle.drop()
- end
- turtle.select(1)
- end
- function checkFuel()
- if turtle.getFuelLevel() <= 10 then
- turtle.select(15)
- turtle.refuel(1)
- turtle.select(1)
- end
- end
- function placeTorch()
- turtle.select(16)
- turtle.placeDown()
- turtle.select(1)
- end
- function stripper()
- xSteps = 0
- xPos = 0
- placeTorch()
- for i = 1, length do
- turtle.dig()
- checkSpace()
- forward()
- xPos = xPos + 1
- checkFuel()
- turtle.digDown()
- checkSpace()
- if xSteps == 12 then
- placeTorch()
- xSteps = 0
- else
- xSteps = xSteps + 1
- end
- end
- placeTorch()
- end
- function turn()
- turtle.turnRight()
- turtle.turnRight()
- end
- function back()
- turn()
- for i = 1, xPos do
- forward()
- end
- if zPos > 0 then
- turtle.turnRight()
- for i = 1, zPos do
- forward()
- end
- turtle.turnLeft()
- end
- end
- function proceed()
- turtle.turnLeft()
- for i = 1, zPos do
- forward()
- end
- turtle.turnLeft()
- for i = 1, xPos do
- forward()
- end
- end
- function row()
- row = 0
- zSteps = 0
- zPos = 0
- for i = 1, amount do
- row = row + 1
- if row == 1 then
- stripper()
- back()
- else
- turtle.turnLeft()
- if zPos ~= 0 then
- for i = 1, zPos do
- forward()
- checkFuel()
- end
- end
- for i = 1,3 do
- turtle.dig()
- checkSpace()
- forward()
- zPos = zPos + 1
- zSteps = zSteps + 1
- checkFuel()
- turtle.digDown()
- checkSpace()
- end
- turtle.turnLeft()
- stripper()
- back()
- end
- end
- unload()
- end
- checkFuel()
- turtle.digDown()
- checkSpace()
- row()
- turn()
- print("Auftrag beendet, Massa")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement