Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- data entry --
- local Args = {...}
- if #Args ~= 2 then
- print("Usage: farm <length> <width>")
- return
- end
- -- vars --
- lenght = tonumber ( Args[1] )
- lenght1 = tonumber ( Args[1] )
- width = tonumber ( Args[2] )
- -- check fuel level --
- function checkfuel()
- --term.clear()
- print( "Fuel level is "..turtle.getFuelLevel() )
- if turtle.getFuelLevel() < 80 then
- print("Add coal on inventory!")
- for n=1,16 do
- local nCount = turtle.getItemCount(n)
- if nCount > 0 then
- turtle.select( n )
- if turtle.refuel(1) then
- print( "New Fuel level is "..turtle.getFuelLevel() )
- end
- end
- end
- end
- end
- function task()
- checkfuel()
- turtle.forward()
- turtle.digDown()
- turtle.down()
- turtle.suckDown()
- turtle.up()
- turtle.digDown()
- turtle.select( 1 )
- if turtle.placeDown() then
- lenght = lenght - 1
- else
- turtle.select(2)
- if turtle.placeDown() then
- lenght = lenght - 1
- else
- turtle.select(3)
- if turtle.placeDown() then
- lenght = lenght - 1
- if lenght == 0 then
- turtle.turtleRight()
- turtle.forward()
- turtle.turnLeft()
- width = width - 1
- end
- else
- print("please add seeds on slot 1,2 and 3")
- end
- end
- end
- end
- function task1()
- checkfuel()
- turtle.forward()
- turtle.digDown()
- turtle.down()
- turtle.suckDown()
- turtle.up()
- turtle.digDown()
- turtle.select( 1 )
- if turtle.placeDown() then
- lenght = lenght + 1
- else
- turtle.select(2)
- if turtle.placeDown() then
- lenght = lenght + 1
- else
- turtle.select(3)
- if turtle.placeDown() then
- lenght = lenght + 1
- if lenght == lenght1 then
- turtle.turtleLeft()
- turtle.forward()
- turtle.turnRight()
- width = width - 1
- end
- else
- print("please add seeds on slot 1,2 and 3")
- end
- end
- end
- end
- -- loop --
- function fLoop()
- while width > 0 do
- while lenght > 0 do
- task()
- end
- while lenght < 0 do
- task1()
- end
- end
- end
- function fStart()
- term.clear()
- print("==== starting planting ====")
- print("please add seeds on slot 1,2 and 3")
- sleep(2)
- turtle.turnRight()
- turtle.turnRight()
- fLoop()
- end
- -- program --
- fStart()
Advertisement
Add Comment
Please, Sign In to add comment