Advertisement
lucifersamfr

regulateWateringCan

Feb 4th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --temps de repos (s)
  2. rest=3600
  3. --temps d'arrosage par champ (s)
  4. watering=300
  5. --connection side
  6. side="top"
  7.  
  8. local fields = {}     --fields colors config
  9. table.insert(fields, colors.orange)     --NO
  10. table.insert(fields, colors.magenta)    --N
  11. table.insert(fields, colors.lightBlue)  --NE
  12. table.insert(fields, colors.yellow)     --O
  13. table.insert(fields, colors.lime)       --center
  14. table.insert(fields, colors.pink)       --E
  15. table.insert(fields, colors.gray)       --SO
  16. table.insert(fields, colors.lightGray)  --S
  17. table.insert(fields, colors.cyan)       --SE
  18.  
  19. -----------------------------------------------------------
  20.  
  21. function fertilize(field)
  22.   print("Watering "..field)
  23.   add(side,field)
  24.   sleep(watering)
  25.   rem(side,field)
  26.   return get(side)
  27. end
  28.  
  29. function get(side)
  30.   return redstone.getBundledOutput(side)
  31. end
  32.  
  33. function set(side, value)
  34.   return redstone.setBundledOutput(side, value)
  35. end
  36.  
  37. function test(side, color)
  38.   return colors.test(get(side), color)
  39. end
  40.  
  41. function add(side, color)
  42.   return set(side, colors.combine(get(side), color))
  43. end
  44.  
  45. function rem(side, color)
  46.   return set(side, colors.subtract(get(side), color))
  47. end
  48.  
  49. -----------------------------------------------------------
  50.  
  51. while true do
  52.   print("Regulating watering cans for "..#fields.." fields")
  53.   print("Connected side to rednet cable : "..side)
  54.   print("Sleep Time                     : "..rest.." seconds")
  55.   print("Watering Time /per field       : "..watering.." seconds")
  56.  
  57.   for i=1,#fields do
  58.     fertilize(fields[i])
  59.   end
  60.  
  61.   print("Sleeping for"..rest.." seconds.")
  62.   sleep(rest)
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement