Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- version = "5"
- term.clear()
- term.setCursorPos(1, 1)
- --print(version)
- sleep(3)
- done = 0
- for l=1,10 do
- if fs.exists("farmapi/gotoapi") == false then do
- print("downloading goto-API")
- shell.run("mkdir","farmapi")
- shell.run("cd","farmapi")
- shell.run("pastebin","get","a3GBewNp","gotoapi")
- shell.run("cd","..")
- if fs.exists("farmapi/gotoapi") == true then
- print("download complete")
- elseif fs.exists("farmapi/gotoapi") == false then
- print("download failed")
- end
- end
- else do
- term.clear()
- term.setCursorPos(1, 1)
- print("recentering")
- os.loadAPI("farmapi/gotoapi")
- while true do
- if done ~= 4 then do
- ---------------------
- ---------------------
- ---------------------
- --CHANGE HERE START--
- ---------------------
- ---------------------
- ---------------------
- --"1" is Normal, "2" is Pumpkin/Melon/Probably Sugar Cane
- Mode = 1
- Farm_Lenth = 5
- Farm_Width = 5
- -- sort for specific crop
- --whether or not to sort, 1 is yes, 0 is no
- sortblock = 0
- --name of the crop
- crop_name = "minecraft:pumpkin"
- --max age of crop should probably be left at 7
- crop_max_age = 7
- --setup location
- setuploc = {361, 89, 629, "e"}
- --chest location
- chestloc = {359, 88, 629, "e"}
- --chest 2 = "up", 1 = "down", or 0 = "forward"
- chestdirection = 1
- --misc
- --ignore if a crop has no age value should be set at 1 for Pumpkin/Melon and 0 for Normal
- Override_ignore_nil_age = 0
- ignore_nil_age = 1
- override_stages = 0
- turnleftchest = 0
- totalstages = 1
- -------------------
- -------------------
- --CHANGE HERE END--
- -------------------
- -------------------
- --unused!!!! Recenter Values
- turn_right_recenter_times = 0
- forward_recenter_times = 0
- function goto(gtable)
- gototable = {}
- goit = 1
- while goit < 5 do
- if gtable[goit] ~= nil then
- table.insert(gototable, gtable[goit])
- elseif gtable[goit] == nil then
- table.insert(gototable, gtable[goit])
- break
- end
- goit = goit + 1
- end
- gotoapi.gotoapi(gototable[1], gototable[2], gototable[3], gototable[4])
- end
- if Override_ignore_nil_age == 0 then
- if Mode == 2 then
- ignore_nil_age = 1
- elseif Mode == 1 then
- ignore_nil_age = 0
- end
- end
- st_width = Farm_Width
- lenth = Farm_Lenth
- if override_stages == 1 then
- totalsteps = totalstages
- if Mode == 2 then
- grabstage = 5
- elseif Mode == 1 then
- grabstage = 2
- end
- elseif Mode == 2 then
- if override_stages == 0 then
- grabstage = 5
- totalstages = 1
- totalsteps = 1
- end
- elseif Mode == 1 then
- if override_stages == 0 then
- grabstage = 2
- totalstages = 2
- totalsteps = 2
- end
- end
- totalsteps = totalstages
- endsteps = totalsteps + 1
- sub_lenth = lenth - 1
- function chest()
- term.clear()
- term.setCursorPos(1, 1)
- print("going to chest")
- goto(chestloc)
- if Mode == 2 then
- chest = 1
- elseif Mode == 1 then
- chest = 2
- end
- term.clear()
- term.setCursorPos(1, 1)
- print("putting in chest")
- while chest <= 16 do
- turtle.select(chest)
- if chestdirection == 0 then
- turtle.drop()
- elseif chestdirection == 1 then
- turtle.dropDown()
- elseif chestdirection == 2 then
- turtle.dropUp()
- end
- chest = chest + 1
- end
- if turnleftchest == 1 then
- turtle.turnLeft()
- end
- term.clear()
- term.setCursorPos(1, 1)
- print("Resetting")
- sleep(20)
- os.reboot()
- end
- function turn()
- if right == 1 then
- --print("right")
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- dist = sub_lenth
- width = width - 1
- right = 0
- else
- --print("left")
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- dist = sub_lenth
- width = width - 1
- right = 1
- end
- end
- function recenter()
- working_turn_right_recenter_times = turn_right_recenter_times
- working_forward_recenter_times = forward_recenter_times
- goto(setuploc)
- if turn_right_recenter_times ~= 0 then
- while working_turn_right_recenter_times ~= 0 do
- turtle.turnRight()
- working_turn_right_recenter_times = working_turn_right_recenter_times - 1
- end
- end
- right = 1
- turtle.select(1)
- dist = lenth - 1
- if forward_recenter_times ~= 0 then
- while working_forward_recenter_times ~= 0 do
- turtle.forward()
- working_forward_recenter_times = working_forward_recenter_times - 1
- end
- end
- end
- function stage1()
- term.setCursorPos(1, 1)
- term.clearLine()
- print ("Stage: " .. done .. "/" .. totalsteps.. " Harvest and Plant")
- success, data = turtle.inspectDown()
- if success then
- if data.state.age ~= nil then
- term.setCursorPos(1, 2)
- term.clearLine()
- percentagefloat = (data.state.age - 0) / (7 - 0) * 100
- percentage = math.floor(percentagefloat+0.5)
- print("Crop Age: " .. percentage .. "%")
- end
- -- if ignore_nil_age == 1 then
- -- if data.state.age == nil then
- -- data.state.age = crop_max_age
- -- end
- --end
- if data.name == crop_name or sortblock == 0 then
- if data.state.age == crop_max_age or ignore_nil_age == 1 then
- --print("Age Check 2: " .. data.state.age)
- turtle.digDown()
- turtle.suckDown()
- --term.setCursorPos(1, 3)
- --term.clearLine()
- --print("dig")
- end
- end
- if Mode == 1 then
- turtle.placeDown()
- end
- end
- end
- function stage2()
- term.setCursorPos(1, 1)
- term.clearLine()
- print ("Stage: " .. done .. "/" .. totalsteps .. " Cleanup")
- turtle.suckDown()
- --print("grab")
- end
- if width == 0 or width == nil then
- done = done + 1
- --print ("add")
- --print ("Steps: " .. done)
- if done == endsteps then
- chest()
- done = 0
- end
- width = st_width
- --print("width: " .. width)
- recenter()
- elseif width ~= 0 then
- if dist ~= 0 then
- if done == 1 then
- term.clear()
- while width ~= 0 do
- while dist ~= 0 do
- stage1()
- turtle.forward()
- stage1()
- --print("dig")
- dist = dist - 1
- end
- turn()
- end
- elseif done == grabstage then
- term.clear()
- while width ~= 0 do
- while dist ~= 0 do
- stage2()
- turtle.forward()
- stage2()
- dist = dist - 1
- end
- turn()
- end
- --unused planting phase not needed because it can be done after digging
- elseif done == 9 then
- while width ~= 0 do
- while dist ~= 0 do
- turtle.placeDown()
- turtle.forward()
- print("plant")
- print ("Steps: " .. done)
- dist = dist - 1
- end
- turn()
- end
- --end- unused planting phase end
- end
- end
- end
- end
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment