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

AE Item Management Puzzle: What's the best way to do this?

Question

Bit of Background:  I'm working on an adventure/building/design map that focuses on creating a balanced network of automated systems, with a few twists to spice up the challenge.  One of these twists makes accumulating too much of a resource a problem the player has to address in their automation (long story short: voiding mechanics and high-capacity storage options are disabled and/or against the rules).  So, if you want to automate a MFR Biofuel Generator using nine different types of crops, you'd better make sure you're generating each crop at the same rate... or you'll get a surplus, and FUNishments will ensue (component.debug(WorldEdit commands go here)).

 

The Puzzle: There is, fortunately, one way to get rid of excess items: certain "pairs" of items can be voided together (usually, one item that requires a bit of automation must be "spent" to void something you're likely going to have too much of).  For example, you can sacrifice 1 stack of Jack o' Lanterns to also sacrifice between 1 to 3 stacks of Rotten Flesh (... making automated Jack o' Lanterns an essential part of a mob farm! Fun times).  I intend this to be very fluid---players can continuously pump both Jack o' Lanterns and Rotten Flesh into the voiding "system", and as long as they're sending 1 (or more) Jack o' Lanterns for every 3 Rotten Flesh, all will be well.

 

I'm thinking the best way to do this is with AE:  Players dump/pump/pipe/whatever their surplus items into an inaccessible (to them) AE system.  A computer periodically scans the drives looking for valid pairs.  If it finds a valid pair---say, 64x Jack o' Lanterns and 123x Rotten Flesh---it configures an Export Bus to send those items into a Trash Can.

 

So far, I have Adapters with Database Upgrades ready to configure the trades, and another Adapter with an Inventory Controller Upgrade adjacent to an Export Bus to (hopefully) program it with the correct items to purge.  Thing is, I've never worked with OC databases or AE integration before, so I want to make sure I'm not starting off on the wrong foot before I spend hours learning how it all works ;)

 

Is this the best set-up?  Will it work at all?  Do you see any issues I'll run into, or things to watch out for? 

 

One thing I noticed, is I can't figure out how to export a specific number of a certain item---according to the method documentation, it seems I can only run a "single cycle" of the export bus, and I'm not quite sure what that means.  Should I be using the Inventory Controller on the me_controller component instead... or ... something?

 

Bah, sorry for the wordiness---I can't help it, it's a real problem.  Tons of thanks in advance, and even a little afterwards, for any advice or insights you can provide!

Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0
  • Solution

Hello there

 

I use OpenComputers to extract items from me AE2 network. I'm using an Adapter with a Database Upgrade in it, and this Adapter is adjacent to an ME Export bus and an ME Controller. I also suggest putting a Redstone Card in your ME Export Bus, so that it's only triggered by your Computer.

 

Here are some bits of code that could help you:

 

 

First, I load components:

local database = component.proxy(component.list("database")())
local meController = component.proxy(component.list("me_controller")())
local meExportBus = component.proxy(component.list("me_exportbus")()) 

Then I define some variables that are needed for the ME Controller and ME Export Bus drivers:

local exportBusSide
for i = 0, 5 do
  if select(2, meExportBus.getConfiguration(i)) ~= "no export bus" then
    exportBusSide = i
    break
  end
end 

getConfiguration returns two variables, the second is "no export bus" or nil.

local databaseAddress
for k,_ in component.list("database") do databaseAddress = k break end
local entryNum = {}
for i = 1, 81 do
  local item = database.get(i)
  if item then entryNum[item.name] = i end
end

Here 81 needs to be changed to your Database size.

 

So now I get the list of items in the network:

local itemList = meController.getItemsInNetwork()

and loop through this table until I find the item I want using

for k, v in pairs(itemList) do
  if v.name == "minecraft:dirt" then

Now you can use this function:

meExportBus.setConfiguration(exportBusSide, 1, databaseAddress, entryNum[v.name])

and this will have the same effect as you right clicking the ME Export Bus and dropping and item in it to configure it.

meExportBus.exportIntoSlot(exportBusSide, 1) 

That will export exactly one item from your network, or more if you have Acceleration Cards in your ME Export Bus. If you want to export several items and want a precise output, a simple loop can do the work.

 

 

I also coudn't find much documentation on using AE2 with OC, and this is what I have came to after experimenting several hours. So if anyone has a way to optimize my code and setup, feel free to share what you have found :)

 

Have fun

Link to post
Share on other sites
  • 0

Thank you!  That's exactly what I was envisioning, I was just missing a few of the pieces to get it to work.

 

Unfortunately, you confirmed my main concern---that I have to trigger meExportBus.exportIntoSlot() once per item.  I'm fairly sure iterating on each individual item will begin to cause problems as players hook up extremely high-quantity/high-speed item inflows.

 

 

One idea I'm tinkering with is to use a long-period timer that, upon firing, records a count of every item in the network, then voids the items by yanking the storage drives themselves and dumping them into a Trash Can (replacing them with blank storage drives pulled from an infinite repository).  Then it's just a matter of processing and tracking the data, and reacting with warnings or the like if any of the "rules" are broken.  That should be more resilient to scaling, I think.

 

Thanks again for your detailed post---I know there are a few other AE-related questions in this forum that would benefit from reviewing your examples, so you've helped a lot of us!

Link to post
Share on other sites
  • 0

You're welcome :)

 

How fast is the item input in your system?

This is from the Export Bus driver code:

var count = export.getInstalledUpgrades(Upgrades.SPEED) match {
  case 1 => 8
  case 2 => 32
  case 3 => 64
  case 4 => 96
  case _ => 1
}

so you could export multiples of 96 for each call of exportIntoSlot() with four Acceleration Cards

 

There should be no problem when players add items when exporting since you need to run getItemInNetwork() again to update the item count in your script. Feel free to tell me if I'm missing something :P

 

You can also use several Adapters/Export Buses if you're brave enough :P

Link to post
Share on other sites
  • 0

Hello there

 

After a long break from Minecraft I have updated my script to export items from an AE2 network. You can check it out on my github: https://github.com/Sam-Soul/SamSoul-Programs

 

I still use the ME Controller and ME Export Bus combo, though I haven't tested my script with the ME Interface.

Basically, instead of looping through all items in the network, I loop through the database entries and use the new filter option for component.me_controller.getItemsInNetwork()

 

Hope my script will be useful for some people. Also feel free to improve it and share your findings to the community :)

 

Which Informations needs to get add to the Database and how is the fastest/best/easiest way to add that?

I would say right-clicking the Database Upgrade and putting the items you want to export in it. The complicated way would be through component.inventory_controller.store() or component.geolyzer.store()

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

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