Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local i,j,h,w,command,percentual
- local arg={...}
- command=arg[1]
- w=tonumber(arg[2])
- h=tonumber(arg[3])
- local function pUsages()
- print("Usages:")
- print("CC collect <width> <height>")
- print("CC make <width> <height>")
- print("CC place <width> <height>")
- print("CC help")
- end
- local function pHelp()
- local event,key
- print("CropCollector help:")
- print("Arguments:")
- print(" collect: The turtle will collect the wheat of the farm then it will replace the seeds")
- print(" make: The turtle will create a farm with the given width and height")
- print(" place: The turtle will place the seeds in the farm")
- print("\nPress any key to continue...")
- event,key=os.pullEvent("key")
- term.clear()
- term.setCursorPos(1,1)
- print("To use this program place the turtle in the upper left corner (facing the wheat), then place 2 chests to the sides of the turtle. (the 2 chests can be double)")
- print("In the left chest there will be the seeds.")
- print("The right chest is used to drop the seeds and the wheat.")
- print("\nPress any key to continue...")
- event,key=os.pullEvent("key")
- term.clear()
- term.setCursorPos(1,1)
- print("Be sure to have enough seeds on the left chest before you run the program")
- print("")
- print("Press any key to continue...")
- event,key=os.pullEvent("key")
- term.clear()
- term.setCursorPos(1,1)
- print("EXAMPLE:")
- print("")
- print("C=chest")
- print("S=seed chest ")
- print("W=wheat")
- print("T=turtle")
- print("")
- print("S")
- print("TWWWWW")
- print("CWWWWW")
- print(" WWWWW")
- end
- local function forward()
- while (true)
- do
- if (turtle.forward())
- then
- break
- end
- end
- end
- local function back()
- while (true)
- do
- if (turtle.back())
- then
- break
- end
- end
- end
- local function up()
- while (true)
- do
- if (turtle.up())
- then
- break
- end
- end
- end
- local function down()
- while (true)
- do
- if (turtle.down())
- then
- break
- end
- end
- end
- local function dropAll()
- local slot
- print("Dropping item...")
- for slot=1,16
- do
- turtle.select(slot)
- turtle.drop()
- end
- end
- local function pickUp()
- local slot
- slot=1
- print("Taking seeds...")
- for slot=1,16
- do
- turtle.select(slot)
- turtle.suck(64)
- end
- end
- local function select()
- local slot
- for slot=1,16
- do
- if (turtle.getItemCount(slot)>0)
- then
- turtle.select(slot)
- return
- end
- end
- end
- -----------------------------------------------------
- if (command=="help")
- then
- pHelp()
- return
- end
- if (#arg~=3)
- then
- pUsages()
- return
- elseif (command~="collect" and command~="make" and command~="place")
- then
- pUsages()
- return
- elseif (w<1 or h<1)
- then
- print("The width and height must be greater than 0")
- return
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Starting...")
- if (command=="collect")
- then
- print("Prepare to collect "..tostring(w*h).." items")
- elseif (command=="place")
- then
- print("Prepare to plant "..tostring(w*h).." seeds")
- elseif (command=="make")
- then
- print("Prepare to make a "..tostring(w).."x"..tostring(h).." farm")
- end
- turtle.select(1)
- if (command=="place")
- then
- turtle.turnLeft()
- pickUp()
- turtle.turnRight()
- end
- up()
- forward()
- for i=1,h
- do
- for j=1,w-1
- do
- if (command=="collect" or command=="make")
- then
- turtle.digDown()
- elseif (command=="place")
- then
- select()
- turtle.placeDown()
- end
- forward()
- end
- print(tostring((i*w*100)/(w*h)).."% completed")-- w*h/i*w=100/x
- if (command=="collect" or command=="make")
- then
- turtle.digDown()
- elseif (command=="place")
- then
- select()
- turtle.placeDown()
- end
- if (i%2==1)
- then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- forward()
- if (i<h-1)
- then
- if (command=="collect" or command=="make")
- then
- turtle.digDown()
- elseif (command=="place")
- then
- select()
- turtle.placeDown()
- end
- end
- if (i%2==1)
- then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- print("Finished.")
- if (h%2==1)
- then
- for i=1,w
- do
- forward()
- end
- turtle.turnRight()
- else
- back()
- turtle.turnLeft()
- end
- for i=0,h-1
- do
- forward()
- end
- turtle.turnRight()
- down()
- turtle.turnRight()
- dropAll()
- turtle.turnLeft()
- turtle.select(1)
- if (command=="collect")
- then
- shell.run("CC", "place "..tostring(w).." "..tostring(h))
- end
- --script by SolidSnake96AS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement