Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --openComputers autoBrew program
- --brew [transposerAddress]
- component = require("component")
- args = {...}
- if #args < 5 then
- print("brew [address] [chestSide] [bottlerSide] [waterSide] [ingredientsSide]")
- return
- end
- tranposer = component.proxy(component.get(args[1]))
- chestSide = sides[args[2]]
- waterSide = sides[args[4]]
- bottlerSide = sides[args[3]]
- ingredientsSide = sides[args[5]]
- fuel = 0
- function listItems(side)
- for i in transposer.getAllStacks(side) do
- for k,v in pairs(i) do
- if k == "label" then
- print(string.lower(v))
- end
- end
- end
- end
- function findItems(side,itemName)
- itemName = string.lower(itemName)
- local invSize = transposer.getInventorySize(side)
- local tab = transposer.getAllStacks(side)
- --going through all the slots in the chest
- for slot = 1,invSize do
- print(tab[slot]["label"])
- if string.lower(tab[slot]["label"]) == itemName then
- -- if the slot has the item we're looking for
- return slot, tab[slot]["size"]
- end
- end
- return false
- end
- function bottleWater()
- local count = count or 3
- local slot, cnt = findItems(chestSide,"glass bottle")
- if cnt < count then
- return "not enough bottles"
- end
- transposer.transferItem(chestSide,bottlerSide,count,slot)
- for i = 1,3 do
- os.sleep(3)
- transposer.transferItem(bottlerSide,waterSide)
- end
- end
- function brewPotion(...)
- --get some water bottles or fill up some water bottles
- local queue = {...}
- bottleWater()
- if fuel <= 0 then
- local slot = findItems(chestSide,"blaze powder")
- if transposer.transferItem(chestSide,waterSide,1,slot) then
- fuel = 20
- end
- end
- while #queue > 0 do
- local ingredient = table.remove(queue,1)
- local slot = findItems(chestSide,ingredient)
- transposer.transferItem(chestSide,ingredientsSide,1,slot)
- os.sleep(21)
- fuel = fuel - 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement