Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tempSlot = 4
- local targetRuneCount = 16
- local getRuneWait = 4
- local dropEachWait = 1
- local wandTapWait = 4
- local runicAltarWait = 18
- local loopWait = 1
- local quit = false
- --materials chest
- local materialsSide = "right"
- local dirMatTurtle = "east"
- local dirTurtleMat = "west"
- --runes chest
- local runeChestSide = "left"
- local dirRuneTurtle = "west"
- local dirTurtleRune = "east"
- --redstone config
- local sigSide = "bottom"
- local wandCol = colors.green
- local blockNodeCol = colors.blue
- local nodeState = false
- local runeChest = peripheral.wrap(runeChestSide)
- local materials = peripheral.wrap(materialsSide)
- local recipes = {}
- recipes["Rune of Water"]={
- {name="Manasteel Ingot" ,qty=3},
- {name="Fishing Rod" ,qty=1},
- {name="Sugar Canes" ,qty=1},
- {name="Bone Meal" ,qty=1}
- }
- recipes["Rune of Fire"]={
- {name="Manasteel Ingot" ,qty=3},
- {name="Nether Wart" ,qty=1},
- {name="Nether Brick" ,qty=1},
- {name="Gunpowder" ,qty=1}
- }
- recipes["Rune of Earth"]={
- {name="Manasteel Ingot" ,qty=3},
- {name="Stone" ,qty=1},
- {name="Block of Coal" ,qty=1},
- {name="Mushroom" ,qty=1}
- }
- recipes["Rune of Air"]={
- {name="Manasteel Ingot" ,qty=3},
- {name="String" ,qty=1},
- {name="Feather" ,qty=1},
- {name="Carpet" ,qty=1}
- }
- local advRecipes = {}
- advRecipes["Rune of Spring"]={
- {name="Rune of Water" ,qty=1},
- {name="Rune of Fire" ,qty=1},
- {name="Wheat" ,qty=1},
- {name="Spruce Sapling" ,qty=3}
- }
- advRecipes["Rune of Summer"]={
- {name="Rune of Earth" ,qty=1},
- {name="Rune of Air" ,qty=1},
- {name="Melon" ,qty=1},
- {name="Slimeball" ,qty=1},
- {name="Sand" ,qty=2}
- }
- advRecipes["Rune of Autumn"]={
- {name="Rune of Fire" ,qty=1},
- {name="Rune of Air" ,qty=1},
- {name="Spider Eye" ,qty=1},
- {name="Oak Leaves" ,qty=3}
- }
- advRecipes["Rune of Winter"]={
- {name="Rune of Water" ,qty=1},
- {name="Rune of Earth" ,qty=1},
- {name="Cake" ,qty=1},
- {name="Wool" ,qty=1},
- {name="Snow" ,qty=2}
- }
- advRecipes["Rune of Mana"]={
- {name="Manasteel Ingot" ,qty=5},
- {name="Mana Pearl" ,qty=1}
- }
- local adv2Recipes = {}
- adv2Recipes["Rune of Lust"]={
- {name="Rune of Summer" ,qty=1},
- {name="Rune of Air" ,qty=1},
- {name="Mana Diamond" ,qty=2}
- }
- adv2Recipes["Rune of Gluttony"]={
- {name="Rune of Fire" ,qty=1},
- {name="Rune of Winter" ,qty=1},
- {name="Mana Diamond" ,qty=2}
- }
- adv2Recipes["Rune of Greed"]={
- {name="Rune of Water" ,qty=1},
- {name="Rune of Spring" ,qty=1},
- {name="Mana Diamond" ,qty=2}
- }
- adv2Recipes["Rune of Sloth"]={
- {name="Rune of Autumn" ,qty=1},
- {name="Rune of Air" ,qty=1},
- {name="Mana Diamond" ,qty=2}
- }
- adv2Recipes["Rune of Wrath"]={
- {name="Rune of Earth" ,qty=1},
- {name="Rune of Winter" ,qty=1},
- {name="Mana Diamond" ,qty=2}
- }
- adv2Recipes["Rune of Envy"]={
- {name="Rune of Water" ,qty=1},
- {name="Rune of Winter" ,qty=1},
- {name="Mana Diamond" ,qty=2}
- }
- adv2Recipes["Rune of Pride"]={
- {name="Rune of Fire" ,qty=1},
- {name="Rune of Summer" ,qty=1},
- {name="Mana Diamond" ,qty=2}
- }
- function debugSignal()
- local sig = rs.getBundledOutput(sigSide)
- if colors.test(sig, colors.blue) then
- print("DEBUG : rs signal blocking node!")
- else
- print("DEBUG : node free!")
- end
- if colors.test(sig, colors.green) then
- print("DEBUG : rs signal activating wand!")
- else
- print("DEBUG : wand inactive!")
- end
- end
- function blockTransferNode()
- rs.setBundledOutput(sigSide, blockNodeCol)
- nodeState=false
- end
- function releaseTransferNode()
- rs.setBundledOutput(sigSide, 0)
- nodeState=true
- end
- function printItemSlot(slot)
- if slot.display_name ~= nil then print("display_name : "..slot.display_name) end
- if slot.qty ~= nil then print("qty : "..slot.qty) end
- if slot.max_size ~= nil then print("max_size : "..slot.max_size) end
- if slot.max_dmg ~= nil then print("max_dmg : "..slot.max_dmg) end
- if slot.raw_name ~= nil then print("raw_name : "..slot.raw_name) end
- if slot.dmg ~= nil then print("dmg : "..slot.dmg) end
- if slot.id ~= nil then print("id : "..slot.id) end
- if slot.name ~= nil then print("name : "..slot.name) end
- if slot.mod_id ~= nil then print("mod_id : "..slot.mod_id) end
- end
- function isRecipeComplete(ing)
- for i,j in pairs(ing) do
- if j~=nil then
- if j.qty > 0 then
- return false
- end
- end
- end
- return true
- end
- function dropTempSlot()
- turtle.select(tempSlot)
- while turtle.getItemCount(tempSlot) > 0 do
- turtle.dropUp(1)
- sleep(dropEachWait)
- end
- end
- function collectChest(chest,dirChestTur,todo)
- if not isRecipeComplete(todo) then
- chest.condenseItems()
- local as = chest.getAllStacks()
- for s=1,#as do
- if as[s]~=nil then
- local slot = as[s]
- --printItemSlot(as[s])
- for i=1,#todo do
- if todo[i].qty > 0 and todo[i].name == slot.display_name then
- --print("| | "..slot.display_name.." found.")
- local pushed = chest.pushItemIntoSlot(dirChestTur,s,todo[i].qty,tempSlot)
- todo[i].qty = todo[i].qty - pushed
- dropTempSlot()
- print("| | "..pushed.." "..slot.display_name.." dropped in altar.")
- end
- end
- end
- end
- end
- return todo
- end
- function copy3(obj, seen)
- -- Handle non-tables and previously-seen tables.
- if type(obj) ~= 'table' then return obj end
- if seen and seen[obj] then return seen[obj] end
- -- New table; mark it as seen an copy recursively.
- local s = seen or {}
- local res = setmetatable({}, getmetatable(obj))
- s[obj] = res
- for k, v in pairs(obj) do res[copy3(k, s)] = copy3(v, s) end
- return res
- end
- function dropInAltar(ingredients)
- local todo = copy3(ingredients,nil)
- print("| collecting input materials...")
- todo = collectChest(materials,dirMatTurtle,todo)
- print("| collecting input runes...")
- todo = collectChest(runeChest,dirRuneTurtle,todo)
- return isRecipeComplete(todo)
- end
- function runeCount(name)
- local as = runeChest.getAllStacks()
- local count=0
- for s=1,#as do
- if as[s]~=nil then
- if string.lower(as[s].display_name) == string.lower(name) then
- count = count + as[s].qty
- end
- end
- end
- return count
- end
- function wandTap()
- rs.setBundledOutput(sigSide, colors.combine(rs.getBundledOutput(sigSide), wandCol))
- print("| WandTap!")
- sleep(wandTapWait)
- rs.setBundledOutput(sigSide, colors.subtract(rs.getBundledOutput(sigSide), wandCol))
- end
- function runeInSlot(slot)
- if slot == nil then
- return false
- else
- return turtle.getItemDetail().name=="Botania:rune"
- end
- end
- function getRune()
- releaseTransferNode()
- wandTap()
- sleep(getRuneWait)
- blockTransferNode()
- end
- function dropLivingRock()
- return isRecipeComplete(collectChest(materials,dirMatTurtle,{{name="Livingrock",qty=1}}))
- end
- function processRecipes(listRecipes)
- local hadWorked = false
- for i,j in pairs(listRecipes) do
- local nbRune = runeCount(i)
- print("\n"..i.." : "..nbRune.."/"..targetRuneCount)
- if nbRune < targetRuneCount then
- hadWorked=true
- if dropInAltar(j) then
- print("| all ingredients dropped in altar.")
- wandTap()
- print("| Waiting runic altar...")
- sleep(runicAltarWait)
- if dropLivingRock() then
- print("| livingrock dropped.")
- end
- getRune()
- else
- quit = true
- break
- end
- end
- end
- return hadWorked
- end
- rs.setBundledOutput(sigSide, blockNodeCol)
- sleep(1)
- blockTransferNode()
- while true do
- if not processRecipes(recipes) then
- if not processRecipes(advRecipes) then
- processRecipes(adv2Recipes)
- end
- end
- if quit then
- print("Quitting....")
- break
- end
- sleep(loopWait)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement