VanillaBean

superCropper

Jan 31st, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.76 KB | None | 0 0
  1. local r = require("robot")
  2. local p = require("cropPositions")
  3. local component = require("component")
  4. local ic = component.inventory_controller
  5.  
  6. superCropper = superCropper or {}
  7.  
  8. tools = {
  9.  
  10.     boneMeal = "Bone Meal",
  11.     seeds = "Seeds",
  12.     cropSticks = "Crop Sticks",
  13.     Crop = "Wheat",
  14.     Mattock = "Mattock"
  15.  
  16. }
  17.  
  18. inventory = {
  19.  
  20.     boneMeal = 1,
  21.     cropSticks = 2,
  22.     seeds = 3,
  23.     Crop = 4,
  24.     Mattock = 5,
  25.  
  26.     toolHold = 13
  27. }
  28.  
  29. function superCropper.equipTool(tool, count)
  30.  
  31.     currentSlot = r.select()
  32.     r.select(tool)
  33.     r.transferTo(inventory.toolHold, count)
  34.     r.select(inventory.toolHold)
  35.     ic.equip()
  36.     r.select(currentSlot)
  37.  
  38. end
  39.  
  40. function superCropper.crossBreedCrop()
  41.  
  42.     superCropper.equipTool(inventory.cropSticks, 2)
  43.     r.useDown()
  44.     r.Up()
  45. end
  46.  
  47. function superCropper.useBoneMeal()
  48.  
  49.     r.select(inventory.boneMeal)
  50.     local seedGrew = false
  51.  
  52.     repeat
  53.         seedGrew = r.placeDown()
  54.  
  55.     until seedGrew == false
  56.  
  57.  
  58. end
  59.  
  60. function superCropper.growSeeds()
  61.  
  62.     superCropper.equipTool(inventory.cropSticks, 1)
  63.     r.useDown()
  64.  
  65.     superCropper.equipTool(inventory.seeds, 1)
  66.     r.useDown()
  67.  
  68.     superCropper.useBoneMeal()
  69.     print("crop ready")
  70.  
  71. end
  72.  
  73. function superCropper.harvestCrop()
  74.     r.swingDown()
  75. end
  76.  
  77.  
  78.  
  79.  
  80. function superCropper.goToCenter(position)
  81.  
  82.   checkArg(1, position, "string")
  83.   if position == p.CENTER then
  84.  
  85.     print("Already in center")
  86.     return
  87.  
  88.   elseif position == p.HOME then
  89.     print("from home")
  90.     r.forward()
  91.   elseif position == p.NOON then
  92.     print("from noon")
  93.     r.back()
  94.   elseif position == p.NINE then
  95.     print("from nine")
  96.     r.turnRight()
  97.     r.forward()
  98.     r.turnLeft()
  99.   elseif position == p.THREE then
  100.     print("from three")
  101.     r.turnLeft()
  102.     r.forward()
  103.     r.turnRight()
  104.   end
  105.  
  106.   return p.CENTER
  107. end
  108.  
  109. function superCropper.goToHome(position)
  110.   if position == p.HOME then
  111.     return p.HOME
  112.   end
  113.  
  114.   superCropper.goToCenter(position)
  115.   r.back()
  116.   return p.HOME
  117. end
  118.  
  119. function superCropper.goToNine(position)
  120.   if position == p.NINE then
  121.     return p.NINE
  122.   end
  123.  
  124.   superCropper.goToCenter(position)
  125.   r.turnLeft()
  126.   r.forward()
  127.   r.turnRight()
  128.   return p.NINE
  129. end
  130.  
  131. function superCropper.goToNoon(position)
  132.   if position == p.NOON then
  133.     return p.NOON
  134.   end
  135.  
  136.   superCropper.goToCenter(position)
  137.   r.forward()
  138.   return p.NOON
  139. end
  140.  
  141. function superCropper.goToThree(position)
  142.   if position == p.THREE then
  143.     return p.THREE
  144.   end
  145.  
  146.   superCropper.goToCenter(position)
  147.   r.turnRight()
  148.   r.forward()
  149.   r.turnLeft()
  150.   return p.THREE
  151. end
  152.  
  153.  
  154.  
  155. pos = p.HOME
  156.  
  157. pos = superCropper.goToNine(pos)
  158. superCropper.growSeeds()
  159. pos = superCropper.goToNoon(pos)
  160. superCropper.growSeeds()
  161. pos = superCropper.goToThree(pos)
  162. superCropper.growSeeds()
  163. pos = superCropper.goToHome(pos)
  164.  
  165. return superCropper
Advertisement
Add Comment
Please, Sign In to add comment