Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local width = 9
- local depth = 20
- local chest_type = "ironchest:crystal_chest"
- local chest_size = 108
- local storage_slot_start = 4
- local planting = {
- {
- name = "minecraft:wheat_seeds",
- crop = "minecraft:wheat",
- slot = 2
- },
- {
- name = "minecraft:carrot",
- crop = "minecraft:carrots",
- slot = 3
- }
- }
- local planting_size = table.getn(planting)
- local plants = {
- {
- name = "minecraft:potatoes",
- seed = "minecraft:potato",
- age = 7
- },
- {
- name = "minecraft:wheat",
- seed = "minecraft:wheat_seeds",
- age = 7
- },
- {
- name = "minecraft:carrots",
- seed = "minecraft:carrot",
- age = 7
- },
- {
- name = "minecraft:beetroots",
- seed = "minecraft:beetroot_seeds",
- age = 3
- },
- {
- name = "thermal:bell_pepper",
- seed = "thermal:bell_pepper_seeds",
- age = 10
- },
- {
- name = "thermal:radish",
- seed = "thermal:radish_seeds",
- age = 10
- },
- {
- name = "thermal:rice",
- seed = "thermal:rice_seeds",
- age = 7
- },
- {
- name = "thermal:spinach",
- seed = "thermal:spinach_seeds",
- age = 7
- },
- {
- name = "thermal:eggplant",
- seed = "thermal:eggplant_seeds",
- age = 7
- }
- }
- local plants_size = table.getn(plants)
- function fuel_check()
- local fuelLevel = turtle.getFuelLevel()
- if turtle.getItemCount(1) < 1 then
- print("We are currently waiting to be refueled!")
- local waiting = true
- while waiting do
- if turtle.getItemCount(1) > 0 then
- print("Thank you!")
- waiting = false
- sleep(1)
- end
- end
- end
- if fuelLevel < 100 then
- turtle.select(1)
- turtle.refuel(2)
- print("Refueled.")
- end
- end
- function check_age()
- local _, data = turtle.inspectDown()
- for i = 1, plants_size do
- local plant = plants[i]
- if data.name == plant.name then
- if plant.age == data.state.age then
- print("fully grown")
- return true
- end
- end
- end
- return false
- end
- function get_plant()
- local _, data = turtle.inspectDown()
- for i = 1, plants_size do
- local plant = plants[i]
- if data.name == plant.name then
- return plant
- end
- end
- return nil
- end
- function select_seed(plant)
- for i = 1, planting_size do
- if planting[i].crop == plant.name then
- turtle.select(planting[i].slot)
- end
- end
- end
- function check_seeds()
- for i = 1, planting_size do
- local plant = planting[i]
- local item = turtle.getItemDetail(plant.slot)
- if item == nil then
- print("You need to put atleast 1 " .. plant.name .. " in slot " .. plant.slot .. ".")
- return false
- end
- if item.name ~= plant.name then
- print("You need to put atleast 1 " .. plant.name .. " in slot " .. plant.slot .. ".")
- return false
- end
- end
- return true
- end
- function empty_slots()
- for i = storage_slot_start, 16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- turtle.drop()
- end
- end
- end
- function harvest_crop()
- if check_age() then
- local plant = get_plant()
- select_seed(plant)
- turtle.digDown()
- turtle.placeDown()
- end
- end
- while true do
- fuel_check()
- if not check_seeds() then
- return
- end
- for w = 1, width do
- if w ~= 1 then
- fuel_check()
- for d = 1, depth do
- turtle.back()
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- end
- for d = 1, depth do
- harvest_crop()
- fuel_check()
- turtle.forward()
- end
- harvest_crop()
- end
- fuel_check()
- for d = 1, depth do
- turtle.back()
- end
- turtle.turnLeft()
- fuel_check()
- for w = 1, width-1 do
- turtle.forward()
- end
- turtle.turnLeft()
- empty_slots()
- turtle.turnRight()
- turtle.turnRight()
- os.sleep(30)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement