Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- SeedBreeder
- This is a AgriCraft seed breeder program for ComputerCraft/OpenComputers. Check Wiki for more information.
- Wiki: github.com/robokop92/SeedBreeder/wiki
- MADE BY: robokop92
- This is the OPENCOMPUTERS Version
- --]]
- component = require("component")
- shell = require("shell")
- side = require("sides")
- t = require("term")
- c = require("computer")
- r = require("robot")
- ser = require("serialization")
- fs = require("filesystem")
- inv = component.inventory_controller
- gen = component.generator
- version = "1.0.0"
- ----------------------------------------------------
- ------------------SOME VARIABLES--------------------
- ----------------------------------------------------
- numOfSubGenerations = 40
- sleepAmountBetweenGenerations = 10
- sleepAmountWhenWachingSeeds = 5
- local args, opt= shell.parse(...)
- if args[1] ~= nil then
- numOfSubGenerations = args[1]*4
- end
- if args[2] ~= nil then
- sleepAmountBetweenGenerations = args[2]
- end
- if args[3] ~= nil then
- sleepAmountWhenWachingSeeds = args[3]
- end
- startpos = {x = 0, y = -1, z = 2}
- pos = {x = 0, y = -1, z = 2}
- fl = {pos = {}}
- fl.pos[0] = {x = 0, y = 0, z = 1}
- fl.pos[1] = {x = -1, y = 0, z = 0}
- fl.pos[2] = {x = 0, y = 0, z = -1}
- fl.pos[3] = {x = 1, y = 0, z = 0}
- fl.pos[4] = {x = 0, y = 0, z = 0}
- fl.pos[5] = {x = 0, y = 1, z = 0}
- cpos = {}
- cpos.anlzer = {x = -1, y = 0, z = 1}
- cpos.bin = {x = -1, y = 0, z = -1}
- cpos.chest = {x = 1, y = 0, z = -1}
- slot = {sticks = {}, fuel = 1, rake = 4, seeds = 5, seedsExtra = 6}
- slot.sticks[1] = 2
- slot.sticks[2] = 3
- ----------------------------------------------------
- -----------------LANG VARIABLES---------------------
- ----------------------------------------------------
- lang_noFuel = "Please insert a valid fuel in slot "..slot.fuel.."!"
- lang_noSticks = "Please insert Crop Sticks in slot "..slot.sticks[1].." or "..slot.sticks[2].."!"
- lang_noRake = "Please insert a Hand Rake in slot "..slot.rake.."!"
- lang_noSeed = "Please insert ONLY 1 valid seeds in slot "..slot.seeds.."!"
- lang_timeBtwGen = "Waiting time between generations: "
- lang_curGen = "Current generation: "
- lang_line = "---------------------------------------"
- ----------------------------------------------------
- ----------------ERROR MESSAGES----------------------
- ----------------------------------------------------
- function noFuel()
- while not gen.insert(1) do
- t.clear()
- t.setCursor(1,1)
- t.write(lang_noFuel)
- os.sleep(1)
- end
- t.clear()
- return true
- end
- function noSticks()
- while not tidySticks() do
- t.clear()
- t.setCursor(1,1)
- t.write(lang_noSticks)
- os.sleep(1)
- end
- t.clear()
- return true
- end
- function noRake()
- while not compareItemInSlot("AgriCraft:handRake",slot.rake) do
- t.clear()
- t.setCursor(1,1)
- t.write(lang_noRake)
- os.sleep(1)
- end
- t.clear()
- return true
- end
- function noSeeds()
- while not checkCount(slot.seeds,1) do
- t.clear()
- t.setCursor(1,1)
- t.write(lang_noSeed)
- os.sleep(1)
- end
- if seeds() >= 1 then
- t.clear()
- return true
- else
- noSeeds()
- end
- end
- ----------------------------------------------------
- --------------INVENTORY CONTROLLLER-----------------
- ----------------------------------------------------
- function compareItemInSlot(item,slot) -- Compares $item with the item in $slot
- itemInfo = inv.getStackInInternalSlot(slot)
- if itemInfo ~= nil then --If $slot has item
- --print("Comparing: "..item.." AND: "..itemInfo.name)
- if item == itemInfo.name then -- If $item matches item name in $slot
- return true
- end
- end
- return false
- end
- function checkCount(slot,count)
- itemInfo = inv.getStackInInternalSlot(slot)
- if itemInfo ~= nil and itemInfo.size >= count then
- return true
- end
- return false
- end
- function count(slot)
- itemInfo = inv.getStackInInternalSlot(slot)
- if itemInfo ~= nil then
- return itemInfo.size
- end
- return 0
- end
- function transferItem(fromSlot,toSlot)
- lastSl = r.select(fromSlot)
- r.transferTo(toSlot,64)
- r.select(lastSl)
- end
- function isEquipEmpty()
- lastSl = r.select(slot.seeds)
- inv.equip()
- if checkCount(slot.seeds,1) then
- return false
- end
- return true
- end
- ----------------------------------------------------
- ----------------BASIC ROBOT COMMANDS----------------
- ----------------------------------------------------
- function putInAnlzer()
- lastSl = r.select(slot.seeds)
- succes = r.dropDown()
- r.select(lastSl)
- return succes
- end
- function takeFromAnlzer()
- lastSl = r.select(slot.seeds)
- succes = inv.suckFromSlot(side.bottom,1)
- r.select(lastSl)
- return succes
- end
- function analyze()
- move(cpos.anlzer)
- print("Analyzing")
- if putInAnlzer() then
- os.sleep(1.7)
- return takeFromAnlzer()
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement