Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- Energizer = peripheral.find("powah:energizing_orb")
- if not Energizer then print("Cannot find energizer.") return false end
- Recipes = {}
- Recipes["powah:blazing_crystal_block"] = { input = {
- ["botania:blaze_mesh"] = 1
- } }
- Recipes["powah:niotic_crystal_block"] = { input = {
- ["minecraft:diamond_block"] = 1
- } }
- Recipes["powah:spirited_crystal_block"] = { input = {
- ["minecraft:emerald_block"] = 1
- } }
- Recipes["powah:dry_ice"] = { input = {
- ["minecraft:blue_ice"] = 2
- } }
- Recipes["powah:energized_steel_block"] = { input = {
- ["minecraft:gold_block"] = 1,
- ["minecraft:iron_block"] = 1
- } }
- Recipes["powah:nitro_crystal"] = { input = {
- ["minecraft:nether_star"] = 1,
- ["minecraft:redstone_block"] = 2,
- ["powah:blazing_crystal_block"] = 1
- } }
- Recipes["allthemodium:unobtanium_vibranium_alloy_ingot"] = { input = {
- ["allthemodium:piglich_heart"] = 1,
- ["allthemodium:unobtanium_ingot"] = 1,
- ["allthemodium:vibranium_ingot"] = 1
- } }
- Recipes["allthemodium:unobtanium_allthemodium_alloy_ingot"] = { input = {
- ["allthemodium:piglich_heart"] = 1,
- ["allthemodium:unobtanium_ingot"] = 1,
- ["allthemodium:allthemodium_ingot"] = 1
- } }
- Recipes["allthemodium:vibranium_allthemodium_alloy_ingot"] = { input = {
- ["allthemodium:piglich_heart"] = 1,
- ["allthemodium:vibranium_ingot"] = 1,
- ["allthemodium:allthemodium_ingot"] = 1
- } }
- function CheckAvailCraft()
- print("CHECK_AVAILABILITY: Checking inventory...")
- for i = 1, 16 do
- turtle.select(i)
- local info = turtle.getItemDetail(i)
- if info then
- print("CHECK_AVAILABILITY: Selected " .. info.count .. " of " .. info.name .. ". ")
- for k, v in pairs(Recipes) do
- print("CHECK_AVAILABILITY: Searching recipe for " .. k)
- for ik, iv in pairs(v.input) do
- if tostring(ik) == info.name and tonumber(iv) <= info.count then
- print("CHECK_AVAILABILITY: Craft for " .. k .. " found.")
- return k
- elseif tostring(ik) == info.name and tonumber(iv) > info.count then
- print("CHECK_AVAILABILITY: Not enough " .. info.name .. " to craft " .. k)
- return false
- end
- end
- end
- print("CHECK_AVAILABILITY: Item not found in recipe database. Please remove " .. info.name .. " from inventory, or add a recipe to handle it.")
- end
- end
- print("CHECK_AVAILABILITY: No craft available.")
- return false
- end
- function CraftItem(rOutput)
- print("CRAFT_ITEM: Checking slots containing items required in recipe for " .. rOutput .. ". ")
- local recipeInputTable = Recipes[rOutput].input
- for k, v in pairs(recipeInputTable) do
- for i = 1, 16 do
- turtle.select(i)
- local info = turtle.getItemDetail()
- if info then
- if info.name == k then
- for j = 1, v do
- turtle.drop(1)
- end
- end
- end
- end
- end
- print("CRAFT_ITEM: Craft performed!")
- local eInv = true
- repeat
- eInv = Energizer.list()
- os.sleep(0.5)
- print("CRAFT_ITEM: Waiting for craft to complete...")
- until next(eInv) == nil
- return true
- end
- function Main()
- print("MAIN: Checking inventory...")
- local craftAvailable = CheckAvailCraft()
- if craftAvailable then
- print("MAIN: Craft found. Initiating craft for " .. craftAvailable .. ". ")
- CraftItem(craftAvailable)
- else
- print("MAIN: Waiting to craft...")
- os.pullEvent("turtle_inventory")
- print("MAIN: Inventory changed. Initiating...")
- Main()
- end
- Main()
- end
- Main()
Add Comment
Please, Sign In to add comment