Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- farm_crops
- -- pastebin run 36eK9aPm
- os.loadAPI("/dorflib/api/dt")
- os.loadAPI("/dorflib/api/dtb")
- function farm_crops()
- xcount = 1
- zcount = 1
- xcont = true
- zcont = true
- turtle.select(1)
- turner = turtle.turnRight
- print("starting")
- while xcont do
- print("xcount: ", xcount)
- while zcont do
- print("zcount: ", zcount)
- farm()
- if keep_going() then
- dt.fforward()
- zcount = zcount + 1
- else
- zcont = false
- end
- end
- if (xcount % 2) == 1 then
- turner = turtle.turnRight
- else
- turner = turtle.turnLeft
- end
- turner()
- if (keep_going) then
- dt.fforward()
- xcount = xcount + 1
- zcont = true
- else
- xcont = false
- zcont = false
- end
- turner()
- end
- end
- function keep_going()
- sf, bf = turtle.inspect()
- sd, bd = turtle.inspectDown()
- if (sf or (sd and (get_crop_age(bd.name) == 0))) then
- print("keep_going: stop")
- return false
- else
- print("keep_going: go")
- return true
- end
- end
- function farm()
- s, b = turtle.inspectDown()
- if s then
- name = b.name
- else
- name = ""
- end
- crop_age = get_crop_age(name)
- if (crop_age > 0) then
- if (b.state.age == crop_age) then
- dt.ddown()
- dtb.splace(turtle.placeDown)
- end
- end
- end
- function get_crop_age(name)
- if (name == "minecraft:wheat") then
- return 7
- elseif (name == "minecraft:potato") then
- return 7
- else
- return 0
- end
- end
- args = {...}
- if #args < 1 then
- farm_crops()
- else
- farm_crops()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement