Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Palagius

Members
  • Content Count

    4
  • Joined

  • Last visited

Reputation Activity

  1. Upvote
    Palagius got a reaction from Adorable-Catgirl in AE2 Level / Auto-crafting   
    It is possible this was implemented elsewhere and I failed to notice it, but I did this as an exercise as exploring OpenComputers.  My son and I play The 1.7.10 Pack for our sandbox fun (in survival mode though), and I wanted to see if I could easily use OpenComputers to replace the typical-and-complex nest of level emitters and crafting cards to maintain minimum amounts of certain items in the AE2 ME network.
    This is not terribly sophisticated, and is just "fire-and-forget" with respects to requesting the crafting operations from the ME Network.  As I continue to dabble I may add in checking on the status of the requested jobs and bound the looping to when all requested jobs per loop-pass have been completed.
    Edited to include versions (Minecraft 1.7.10) and remove a couple of potentially confusing commented-out lines:
    OpenComputers 1.6.2.12 AE2 rv3 beta6 Lots of other stuff outside the scope of this program Here is what I wrote:
    local component = require("component") local meController = component.proxy(component.me_controller.address) local gpu = component.gpu -- Each element of the array is "item", "damage", "number wanted", "max craft size" -- Damage value should be zero for base items items = { { "minecraft:iron_ingot", 0, 512, 32 }, { "minecraft:gold_ingot", 0, 256, 32 }, { "IC2:itemIngot", 0, 512, 32 }, -- Copper { "IC2:itemIngot", 1, 256, 32 }, -- Tin { "IC2:itemIngot", 2, 512, 32 }, -- Bronze { "IC2:itemIngot", 3, 256, 64 }, -- Refined Iron { "appliedenergistics2:item.ItemMultiMaterial", 8, 128, 32 }, -- Fluix Dust { "appliedenergistics2:item.ItemMultiMaterial", 10, 128, 32 }, -- Pure Certus { "appliedenergistics2:item.ItemMultiMaterial", 11, 128, 32 }, -- Pure Nether { "appliedenergistics2:item.ItemMultiMaterial", 12, 128, 32 }, -- Pure Fluix { "appliedenergistics2:item.ItemMultiMaterial", 22, 128, 32 }, -- Logic Processor { "appliedenergistics2:item.ItemMultiMaterial", 23, 128, 32 }, -- Calculation Processor { "appliedenergistics2:item.ItemMultiMaterial", 24, 128, 32 }, -- Engineering Processor { "appliedenergistics2:item.ItemMultiMaterial", 52, 32, 32 }, -- Blank Pattern { "appliedenergistics2:item.ItemMultiPart", 16, 128, 32 }, -- Glass Cable - Fluix { "appliedenergistics2:item.ItemMultiPart", 21, 64, 32 }, -- ME Covered Cable - Orange { "appliedenergistics2:item.ItemMultiPart", 22, 64, 32 }, -- ME Covered Cable - Magenta { "appliedenergistics2:item.ItemMultiPart", 24, 64, 32 }, -- ME Covered Cable - Yellow { "appliedenergistics2:item.ItemMultiPart", 25, 64, 32 }, -- ME Covered Cable - Lime { "appliedenergistics2:item.ItemMultiPart", 29, 64, 32 }, -- ME Covered Cable - Cyan { "appliedenergistics2:item.ItemMultiPart", 30, 64, 32 }, -- ME Covered Cable - Purple { "appliedenergistics2:item.ItemMultiPart", 31, 64, 32 }, -- ME Covered Cable - Blue { "appliedenergistics2:item.ItemMultiPart", 34, 64, 32 }, -- ME Covered Cable - Red { "appliedenergistics2:item.ItemMultiPart", 36, 64, 32 }, -- ME Covered Cable - Fluix { "appliedenergistics2:item.ItemMultiPart", 140, 64, 32 }, -- Quartz Fiber { "appliedenergistics2:tile.BlockQuartzGlass", 0, 64, 32 }, -- Quartz Glass { "minecraft:glass", 0, 512, 256 }, { "minecraft:sand", 0, 512, 256 } } loopDelay = 60 -- Seconds between runs while true do for curIdx = 1, #items do curName = items[curIdx][1] curDamage = items[curIdx][2] curMinValue = items[curIdx][3] curMaxRequest = items[curIdx][4] -- io.write("Checking for " .. curMinValue .. " of " .. curName .. "\n") storedItem = meController.getItemsInNetwork({ name = curName, damage = curDamage }) io.write("Network contains ") gpu.setForeground(0xCC24C0) -- Purple-ish io.write(storedItem[1].size) gpu.setForeground(0xFFFFFF) -- White io.write(" items with label ") gpu.setForeground(0x00FF00) -- Green io.write(storedItem[1].label .. "\n") gpu.setForeground(0xFFFFFF) -- White if storedItem[1].size < curMinValue then delta = curMinValue - storedItem[1].size craftAmount = delta if delta > curMaxRequest then craftAmount = curMaxRequest end io.write(" Need to craft ") gpu.setForeground(0xFF0000) -- Red io.write(delta) gpu.setForeground(0xFFFFFF) -- White io.write(", requesting ") gpu.setForeground(0xCC24C0) -- Purple-ish io.write(craftAmount .. "... ") gpu.setForeground(0xFFFFFF) -- White craftables = meController.getCraftables({ name = curName, damage = curDamage }) if craftables.n >= 1 then cItem = craftables[1] retval = cItem.request(craftAmount) gpu.setForeground(0x00FF00) -- Green io.write("OK\n") gpu.setForeground(0xFFFFFF) -- White else gpu.setForeground(0xFF0000) -- Red io.write(" Unable to locate craftable for " .. storedItem[1].name .. "\n") gpu.setForeground(0xFFFFFF) -- White end end end io.write("Sleeping for " .. loopDelay .. " seconds...\n\n") os.sleep(loopDelay) end I have also attached a cropped screenshot of it running and the output.  Naturally one will want to turn knobs on the crafting amounts and frequency.  I find the 60 minute cycle to be more than enough for the crafting backlog to be cleared.
     

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.