Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x = 0
- local y = 0
- local xPos = 0
- local yPos = 0
- local last = false
- local done = false
- local levelDone = false
- local function goDwn()
- local floor = false
- for i=0, 6 do
- if not turtle.down() then
- floor = true
- end
- end
- return floor
- end
- local function drain()
- turtle.select(1)
- turtle.placeUp()
- sleep(1)
- turtle.digUp()
- end
- local function nextLine()
- drain()
- local startPos = yPos
- turtle.turnRight()
- for i=0, 6 do
- if yPos < y then
- if turtle.forward() then
- yPos = yPos+1
- end
- end
- end
- turtle.turnLeft()
- if startPos == yPos then
- if goDwn() then
- last = true
- end
- turtle.turnLeft()
- for i=0, y-1 do
- turtle.forward()
- end
- yPos = 0
- turtle.turnRight()
- if xPos == x-1 then
- for i=0, x do
- turtle.back()
- end
- xPos = 0
- end
- if last == true then
- done = true
- end
- levelFinished = true
- end
- end
- local function startDraining()
- print("enter x: ")
- x = tonumber(read())
- print("enter y: ")
- y = tonumber(read())
- turtle.down()
- turtle.down()
- turtle.down()
- while not done do
- drain()
- levelFinished = false
- for i=0, x-1 do
- if turtle.forward() then
- xPos = xPos+1
- end
- if xPos % 6 == 0 then
- drain()
- end
- if xPos == x then
- nextLine()
- end
- end
- drain()
- if not levelFinished then
- for i=0, x-1 do
- if turtle.back() then
- xPos = xPos-1
- end
- if xPos % 6 == 0 then
- drain()
- end
- if xPos == 0 then
- drain()
- nextLine()
- end
- end
- end
- end
- end
- if turtle.getItemCount(1) == 0 then
- print("No sponge found in slot 1")
- else
- print("Sponge found")
- startDraining()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement