Ubidibity

seedbreeder-clone

Jul 21st, 2021 (edited)
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. SeedBreeder
  3. This is a AgriCraft seed breeder program for ComputerCraft/OpenComputers. Check Wiki for more information.
  4. Wiki: github.com/robokop92/SeedBreeder/wiki
  5. note to anyone finding br7W6U2q cloned from he original, as of 7-21-21 the wiki is unavailable. If I can make this work, I'll update this post at the bottom with a basic write up for usage.
  6. MADE BY: robokop92
  7. This is the OPENCOMPUTERS Version
  8. --]]
  9. component = require("component")
  10. shell = require("shell")
  11. side = require("sides")
  12. t = require("term")
  13. c = require("computer")
  14. r = require("robot")
  15. ser = require("serialization")
  16. fs = require("filesystem")
  17. inv = component.inventory_controller
  18. gen = component.generator
  19.  
  20. version = "1.0.0"
  21.  
  22. ----------------------------------------------------
  23. ------------------SOME VARIABLES--------------------
  24. ----------------------------------------------------
  25.  
  26. numOfSubGenerations = 40
  27. sleepAmountBetweenGenerations = 10
  28. sleepAmountWhenWachingSeeds = 5
  29.  
  30.  
  31. local args, opt= shell.parse(...)
  32. if args[1] ~= nil then
  33. numOfSubGenerations = args[1]*4
  34. end
  35. if args[2] ~= nil then
  36. sleepAmountBetweenGenerations = args[2]
  37. end
  38. if args[3] ~= nil then
  39. sleepAmountWhenWachingSeeds = args[3]
  40. end
  41.  
  42. startpos = {x = 0, y = -1, z = 2}
  43. pos = {x = 0, y = -1, z = 2}
  44. fl = {pos = {}}
  45. fl.pos[0] = {x = 0, y = 0, z = 1}
  46. fl.pos[1] = {x = -1, y = 0, z = 0}
  47. fl.pos[2] = {x = 0, y = 0, z = -1}
  48. fl.pos[3] = {x = 1, y = 0, z = 0}
  49. fl.pos[4] = {x = 0, y = 0, z = 0}
  50. fl.pos[5] = {x = 0, y = 1, z = 0}
  51.  
  52. cpos = {}
  53. cpos.anlzer = {x = -1, y = 0, z = 1}
  54. cpos.bin = {x = -1, y = 0, z = -1}
  55. cpos.chest = {x = 1, y = 0, z = -1}
  56.  
  57. slot = {sticks = {}, fuel = 1, rake = 4, seeds = 5, seedsExtra = 6}
  58. slot.sticks[1] = 2
  59. slot.sticks[2] = 3
  60.  
  61. ----------------------------------------------------
  62. -----------------LANG VARIABLES---------------------
  63. ----------------------------------------------------
  64. lang_noFuel = "Please insert a valid fuel in slot "..slot.fuel.."!"
  65. lang_noSticks = "Please insert Crop Sticks in slot "..slot.sticks[1].." or "..slot.sticks[2].."!"
  66. lang_noRake = "Please insert a Hand Rake in slot "..slot.rake.."!"
  67. lang_noSeed = "Please insert ONLY 1 valid seeds in slot "..slot.seeds.."!"
  68. lang_timeBtwGen = "Waiting time between generations: "
  69. lang_curGen = "Current generation: "
  70. lang_line = "---------------------------------------"
  71. ----------------------------------------------------
  72. ----------------ERROR MESSAGES----------------------
  73. ----------------------------------------------------
  74. function noFuel()
  75. while not gen.insert(1) do
  76. t.clear()
  77. t.setCursor(1,1)
  78. t.write(lang_noFuel)
  79. os.sleep(1)
  80. end
  81. t.clear()
  82. return true
  83. end
  84. function noSticks()
  85. while not tidySticks() do
  86. t.clear()
  87. t.setCursor(1,1)
  88. t.write(lang_noSticks)
  89. os.sleep(1)
  90. end
  91. t.clear()
  92. return true
  93. end
  94. function noRake()
  95. while not compareItemInSlot("AgriCraft:handRake",slot.rake) do
  96. t.clear()
  97. t.setCursor(1,1)
  98. t.write(lang_noRake)
  99. os.sleep(1)
  100. end
  101. t.clear()
  102. return true
  103. end
  104. function noSeeds()
  105. while not checkCount(slot.seeds,1) do
  106. t.clear()
  107. t.setCursor(1,1)
  108. t.write(lang_noSeed)
  109. os.sleep(1)
  110. end
  111. if seeds() >= 1 then
  112. t.clear()
  113. return true
  114. else
  115. noSeeds()
  116. end
  117. end
  118. ----------------------------------------------------
  119. --------------INVENTORY CONTROLLLER-----------------
  120. ----------------------------------------------------
  121. function compareItemInSlot(item,slot) -- Compares $item with the item in $slot
  122. itemInfo = inv.getStackInInternalSlot(slot)
  123. if itemInfo ~= nil then --If $slot has item
  124. --print("Comparing: "..item.." AND: "..itemInfo.name)
  125. if item == itemInfo.name then -- If $item matches item name in $slot
  126. return true
  127. end
  128. end
  129. return false
  130. end
  131. function checkCount(slot,count)
  132. itemInfo = inv.getStackInInternalSlot(slot)
  133. if itemInfo ~= nil and itemInfo.size >= count then
  134. return true
  135. end
  136. return false
  137. end
  138. function count(slot)
  139. itemInfo = inv.getStackInInternalSlot(slot)
  140. if itemInfo ~= nil then
  141. return itemInfo.size
  142. end
  143. return 0
  144. end
  145. function transferItem(fromSlot,toSlot)
  146. lastSl = r.select(fromSlot)
  147. r.transferTo(toSlot,64)
  148. r.select(lastSl)
  149. end
  150.  
  151. function isEquipEmpty()
  152. lastSl = r.select(slot.seeds)
  153. inv.equip()
  154. if checkCount(slot.seeds,1) then
  155. return false
  156. end
  157. return true
  158. end
  159.  
  160. ----------------------------------------------------
  161. ----------------BASIC ROBOT COMMANDS----------------
  162. ----------------------------------------------------
  163.  
  164. function putInAnlzer()
  165. lastSl = r.select(slot.seeds)
  166. succes = r.dropDown()
  167. r.select(lastSl)
  168. return succes
  169. end
  170.  
  171. function takeFromAnlzer()
  172. lastSl = r.select(slot.seeds)
  173. succes = inv.suckFromSlot(side.bottom,1)
  174. r.select(lastSl)
  175. return succes
  176. end
  177. function analyze()
  178. move(cpos.anlzer)
  179. print("Analyzing")
  180. if putInAnlzer() then
  181. os.sleep(1.7)
  182. return takeFromAnlzer()
  183. end
  184. return false
  185. end
Add Comment
Please, Sign In to add comment