Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ########################
- -- cultivate <n>
- -- version 0.3
- -- ########################
- -- #############
- -- config
- ARGS = {...}
- MAX = ARGS[1]
- SEED_SLOT = 1
- MEAL_SLOT = 2
- -- ##################
- -- define functions
- function plantSeed()
- turtle.select(SEED_SLOT)
- if turtle.place() then
- return true
- else
- print('failed: plantSeed')
- return false
- end
- end
- function getMeals()
- turtle.select(MEAL_SLOT)
- if turtle.suckUp() then
- -- succeed in sucking meals
- if turtle.getItemCount(MEAL_SLOT) < 4 then
- -- but, meals < 4
- print('failed: getMeals, meal < 4 ')
- return false
- else
- -- ok, meals > 3
- print('getMeals')
- return true
- end
- else
- -- failed to sucking meals
- print('failed: suckUp')
- return false
- end
- end
- function dropItems(begin_slot, end_slot)
- print('drop items: slots ',begin_slot,'-',end_slot)
- for i=begin_slot, end_slot do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(1)
- end
- function useMeals()
- if turtle.getItemCount(MEAL_SLOT) < 4 then
- if getMeals()==false then
- return false
- end
- end
- turtle.select(MEAL_SLOT)
- turtle.place()
- turtle.place()
- turtle.place()
- return true
- end
- -- useMeals() and useMeals2() are the same functions.
- function useMeals2()
- if (turtle.getItemCount(MEAL_SLOT) < 4) and (getMeals()==false) then
- return false
- else
- turtle.select(MEAL_SLOT)
- turtle.place()
- turtle.place()
- turtle.place()
- return true
- end
- end
- function harvest()
- turtle.select(SEED_SLOT)
- turtle.dig()
- end
- -- ##################
- -- Main
- turtle.dig()
- for i=1,MAX do
- print(i,'/',MAX)
- if plantSeed() == false then break end
- if useMeals() == false then break end
- harvest()
- if i%50==0 then dropItems(3,16) end
- end
- dropItems(3,16)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement