Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sides = require("sides")
- local component = require("component")
- local event = require("event")
- local currentCraft = ""
- -- This will be filled automatically by the code, no need to modify it
- local transposerList = {
- items = {
- id = "",
- side = ""
- },
- fluids = {
- output = {
- id = "",
- side = ""
- },
- liquiddna = {
- id = "",
- side = ""
- },
- water = {
- id = "",
- side = ""
- },
- coal = {
- id = "",
- side = ""
- },
- redstone = {
- id = "",
- side = ""
- },
- mana = {
- id = "",
- side = ""
- },
- seedoil = {
- id = "",
- side = ""
- },
- ic2coolant = {
- id = "",
- side = ""
- },
- sewage = {
- id = "",
- side = ""
- }
- }
- }
- -- add the recipe here, take in account that the name of the fluid needs to be the one opencomputer sees, not the JEI name
- local RECIPES = {
- ludacrite = {
- items = {
- "biomesoplenty:gem.0",
- "bigreactors:blockmetals.3",
- "plustic:alumiteingot.0",
- "botania:blazeblock.0",
- "botania:storage.2",
- "thermalfoundation:storage_alloy.7"
- },
- fluid = {
- name = "liquiddna",
- amount = 500
- }
- },
- wyvernCore = {
- items = {
- "minecraft:shulker_shell.0",
- "bigreactors:ingotmetals.4",
- "environmentaltech:pladium.0",
- "minecraft:nether_star.0",
- "draconicevolution:draconic_core.0"
- },
- fluid = {
- name = "mana",
- amount = 500
- }
- },
- intricateChipset = {
- items = {
- "forestry:chipsets.0",
- "forestry:chipsets.1",
- "forestry:chipsets.2",
- "appliedenergistics2:material.17",
- "mekanism:controlcircuit.3"
- },
- fluid = {
- name = "water",
- amount = 5000
- }
- },
- draconicEnergyCore = {
- items = {
- "draconicevolution:draconic_ingot.0",
- "draconicevolution:wyvern_energy_core.0",
- "draconicevolution:wyvern_core.0"
- },
- fluid = {
- name = "mana",
- amount = 500
- }
- },
- craftingCore = {
- items = {
- "extendedcrafting:material.18",
- "extendedcrafting:pedestal.0",
- "plustic:osmiridiumingot.0"
- },
- fluid = {
- name = "coal",
- amount = 2500
- }
- },
- pedestal = {
- items = {
- "extendedcrafting:material.2",
- "extendedcrafting:storage.0",
- "extendedcrafting:material.0"
- },
- fluid = {
- name = "coal",
- amount = 500
- }
- },
- overclocker = {
- items = {
- "mekanism:controlcircuit.0",
- "thermalfoundation:material.321",
- "ic2:cable.0"
- },
- fluid = {
- name = "ic2coolant",
- amount = 1500
- }
- },
- tier6Seed = {
- items = {
- "minecraft:wheat_seeds.0",
- "mysticalagradditions:insanium.0",
- "mysticalagriculture:crafting.21"
- },
- fluid = {
- name = "sewage",
- amount = 500
- }
- },
- basicChipset = {
- items = {
- "thermalfoundation:material.129",
- "minecraft:redstone.0"
- },
- fluid = {
- name = "water",
- amount = 5000
- }
- },
- enhancedChipset = {
- items = {
- "thermalfoundation:material.163",
- "minecraft:redstone.0"
- },
- fluid = {
- name = "water",
- amount = 5000
- }
- },
- refinedChipset = {
- items = {
- "minecraft:iron_ingot.0",
- "minecraft:redstone.0"
- },
- fluid = {
- name = "water",
- amount = 5000
- }
- },
- hardenedCasing = {
- items = {
- "forestry:sturdy_machine.0",
- "minecraft:diamond.0"
- },
- fluid = {
- name = "water",
- amount = 5000
- }
- },
- impregnatedCasing = {
- items = {
- "log"
- },
- fluid = {
- name = "seedoil",
- amount = 125
- }
- },
- impregnatedStick = {
- items = {
- "planks"
- },
- fluid = {
- name = "seedoil",
- amount = 50
- }
- --},
- --wyvernEnergyCore = {
- -- items = {
- -- "draconicevolution:draconic_core"
- -- },
- -- fluid = {
- -- name = "redstone",
- -- amount = 10000
- -- }
- }
- }
- function getCurrentRecipeName(items) -- items from inventory
- local isRecipeFound = true
- for recipeName, recipeData in pairs(RECIPES) do
- for recipeItemName, recipeItemData in pairs(recipeData.items) do
- for itemName, itemData in pairs(items) do
- local damage = "0"
- if itemData["damage"] ~= nil then
- damage = itemData["damage"]
- end
- if string.match(itemData["name"] .. "." .. math.floor(damage), recipeItemData) then
- isRecipeFound = true
- break
- else
- isRecipeFound = false
- end
- end
- if isRecipeFound == false then
- break
- end
- end
- if isRecipeFound then
- return recipeName
- end
- end
- return nil
- end
- function getInventoryItems()
- local items = component.proxy(transposerList["items"]["id"]).getAllStacks(sides[transposerList["items"]["side"]]).getAll()
- local realItems ={}
- local increment = 1
- for k,v in pairs(items) do
- if v["name"] ~= "minecraft:air" then
- realItems[increment] = v
- increment = increment + 1
- end
- end
- return realItems
- end
- function getTransposersInfo()
- local transposers = component.list("transposer");
- for id, data in pairs(transposers) do
- getTransposerSides(id)
- end
- end
- function getTransposerSides(transposerId)
- local possibleSides = {"bottom", "top", "back", "front", "right", "left"}
- local transposer = component.proxy(transposerId)
- local sides = {}
- for i=1, 6 do
- if transposer.getInventoryName(i-1) ~= nil and transposer.getFluidInTank(i-1)["n"] < 1 then
- transposerList["items"]["id"] = transposerId
- transposerList["items"]["side"] = possibleSides[i]
- elseif transposer.getFluidInTank(i-1)["n"] > 0 then
- local fluid = transposer.getFluidInTank(i-1)[1]
- if fluid["name"] ~= nil then
- fluid["name"] = string.gsub(fluid["name"], "%.", "")
- print(fluid["name"])
- transposerList["fluids"][fluid["name"]]["id"] = transposerId
- transposerList["fluids"][fluid["name"]]["side"] = possibleSides[i]
- end
- end
- end
- end
- function getOutputLocation(transposer)
- if transposer.getInventoryName(sides.up) == "actuallyadditions:block_phantom_liquiface" then
- return sides.up
- elseif transposer.getInventoryName(sides.down) == "actuallyadditions:block_phantom_liquiface" then
- return sides.down
- end
- return nil
- end
- function moveFluidToMachine(recipeName)
- local fluidName = RECIPES[recipeName]["fluid"]["name"]
- local fluidAmount = RECIPES[recipeName]["fluid"]["amount"]
- local transposer = component.proxy(transposerList["fluids"][fluidName]["id"])
- local inputSide = transposerList["fluids"][fluidName]["side"]
- local outputSide = getOutputLocation(transposer)
- if transposer.getTankLevel(outputSide) == 0 then
- transposer.transferFluid(sides[inputSide], outputSide, fluidAmount)
- end
- end
- function init()
- getTransposersInfo()
- end
- function loopDeLoop()
- while event.pull(1, "interrupted") == nil do
- if getInventoryItems()[1] ~= nil then
- local currentRecipe = getCurrentRecipeName(getInventoryItems())
- if currentRecipe == nil then
- print("that's not a recipe you dum dum, check your items")
- else
- print("crafting : " .. currentRecipe)
- moveFluidToMachine(currentRecipe)
- end
- end
- local event, address, arg1, arg2, arg3 = event.pull(1)
- if type(address) == "string" and component.isPrimary(address) then
- if event == "key_down" and arg2 == keyboard.keys.q then
- os.exit()
- end
- end
- end
- end
- init()
- loopDeLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement