daily pastebin goal
27%
SHARE
TWEET

ComputerCraft Tutorial: cultivate0_2

hevohevo Nov 2nd, 2013 153 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- ########################
  2. -- cultivate <n>
  3. -- version 0.2
  4. -- ########################
  5.  
  6. -- #############
  7. -- config
  8. ARGS = {...}
  9. MAX = ARGS[1]
  10. SEED_SLOT = 1
  11. MEAL_SLOT = 2
  12.  
  13. -- ##################
  14. -- define functions
  15. function plantSeed()
  16.   turtle.select(SEED_SLOT)
  17.   if turtle.place() then
  18.     return true
  19.   else
  20.     print('failed: plantSeed')
  21.     return false
  22.   end
  23. end
  24.  
  25. function useMeals()
  26.   if turtle.getItemCount(MEAL_SLOT) < 4 then
  27.     print('failed: useMeals (meal < 4)')
  28.     return false
  29.   else
  30.     turtle.select(MEAL_SLOT)
  31.     turtle.place()
  32.     turtle.place()
  33.     turtle.place()
  34.     return true
  35.   end
  36. end
  37.  
  38. function harvest()
  39.   turtle.select(SEED_SLOT)
  40.   turtle.dig()
  41. end
  42.  
  43. -- ##################
  44. -- Main
  45. turtle.dig()
  46. for i=1,MAX do
  47.   print(i,'/',MAX)
  48.  
  49.   if plantSeed() == false then break end
  50.   if useMeals() == false then break end
  51.  
  52.   harvest()
  53. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top