Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require('component')
- local sides = require('sides')
- local serialize = require('serialization')
- local xnet = component.xnet
- local endpoints = {}
- local args = {...}
- print("Making " .. args[1] .. " rune")
- function addReq(rune, item, amount)
- table.insert(rune, {["item"] = item, ["amount"] = amount})
- return rune
- end
- function baseRune()
- local rune = {
- {["item"] = "botania:manaresource:23", ["amount"] = 1},
- {["item"] = "botania:manaresource", ["amount"] = 1},
- }
- return rune
- end
- local air = baseRune()
- air = addReq(air, "minecraft:string", 1)
- air = addReq(air, "minecraft:feather", 1)
- air = addReq(air, "minecraft:carpet", 1)
- local water = baseRune()
- water = addReq(water, "minecraft:fishing_rod", 1)
- water = addReq(water, "minecraft:reeds", 1)
- water = addReq(water, "minecraft:dye:15", 1)
- local earth = baseRune()
- earth = addReq(earth, "minecraft:brown_mushroom", 1)
- earth = addReq(earth, "minecraft:coal_block", 1)
- earth = addReq(earth, "minecraft:stone", 1)
- local fire = baseRune()
- fire = addReq(fire, "minecraft:nether_wart", 1)
- fire = addReq(fire, "minecraft:gunpowder", 1)
- fire = addReq(fire, "minecraft:netherbrick", 1)
- runes = {}
- runes["air"] = air
- runes["water"] = water
- runes["earth"] = earth
- runes["fire"] = fire
- for i,block in ipairs(xnet.getConnectedBlocks()) do
- endpoints[block.connector] = block
- end
- function parseItems(items)
- local assocTable = {}
- for i,item in ipairs(items) do
- if (item.name ~= "minecraft:air") then
- local name = item.name
- if item.damage ~= 0 then
- name = name .. ":" .. item.damage
- end
- assocTable[name] = item
- assocTable[name].slot = i
- end
- end
- return assocTable
- end
- function getItems(name)
- local items = parseItems(xnet.getItems(endpoints[name].pos))
- return items
- end
- function moveItem(from, to, item, amount)
- local fromPos = endpoints[from].pos
- local toPos = endpoints[to].pos
- local items = getItems(from)
- missing = true
- for key,v in pairs(items) do
- if (key == item) then
- missing = false
- end
- end
- if (missing) then
- error("Missing " .. item)
- end
- xnet.transferItem(fromPos, items[item].slot, amount, toPos)
- return
- end
- function checkReqs(from, reqs)
- local items = getItems(from)
- local missing = {}
- for rKey, rV in ipairs(reqs) do
- isMissing = true
- for key,v in pairs(items) do
- if (rV.item == key) then
- isMissing = false
- end
- end
- if (isMissing) then
- table.insert(missing, rV.item)
- end
- end
- return missing
- end
- local missingItems = checkReqs("Rune Materials", runes[args[1]])
- if (missingItems[1] ~= nil) then
- error("Missing items: " .. serialize.serialize(missingItems))
- end
- print("Inputting Items...")
- for i,requirement in ipairs(runes[args[1]]) do
- moveItem("Rune Materials", "Rune Input", requirement.item, requirement.amount)
- end
- print("Waiting for ritual to finish...")
- while (component.redstone.getInput(sides.left) ~= 2) do
- os.sleep(0.01)
- end
- print("Ritual charged. Dropping Rock")
- moveItem("Rune Materials", "Rune Input", "botania:livingrock", 1)
- os.sleep(1)
- print("Firing Wand")
- component.redstone.setOutput(sides.back, 15)
- os.sleep(0.2)
- component.redstone.setOutput(sides.back, 0)
- print("Finished.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement