This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
steven6282's profile picture

ComputerCraft with OpenPeripherals and Applied Energistics for auto crafting

Started by steven6282, 17 May 2014 - 01:51 AM
steven6282 #1
Posted 17 May 2014 - 03:51 AM
So, I've been working the past few days on coming up with a new sorting room for all my items to come into when running quarries or just out and about sending items back. I set up a nice room with all the basic crafting machines I need for such purposes and thought to myself, I should be able to handle this with a ComputerCraft program instead of a bunch of BC pipes intermingled with TE pipes and some ME interfaces like my old sorting room.

However I've ran into a problem…

FIrst off a little explanation on how I do my current BC / TE sorting system. Lets take Ores for example. I like to keep some pulverized ores around for blending into other metals, like Invar. So my sorting system is currently set up in a way that it auto pulverizes all ores, and then auto smelts 2/3rds of each specific kind of ore that comes in. I'd like to be able to maintain this type of setup.

Now the approach I was taking, I figured I could write a program that would let me input values of what item I wanted to craft based on how many of something was in the system. Storing the items I want to craft based on what items and such is easy enough to do. The problem comes in when I went to start writing the routine that would actually request the crafting be done from the ME system (in this case the "crafting" is turning pulverized ore into ingots, which I have a interface set up to send those into a chest that is piped to a line of smelters). I cannot figure out anyway to reliably tell when the crafting job has been completed. So I have know way to know, when it's ok to send off a crafting request for the same item again.

Imagine a situation with a quarry, lets say it hits a good Iron Ore vein and I have 20 iron ore come in back to back. If I tried to tell the program to request crafting pulverized iron ore when there is more than 0 iron ore, it's going to attempt that request everytime it goes through the loop and see iron ore in the ME network. I was thinking, well maybe I could watch the count of the resulting item and know when it's done with the last request based on that. Well that would work, as long as the resulting item isn't being used for anything else. If I had say a 2nd request to autocraft iron ingots anytime there was more than 500 pulverized iron ore, then the count would be inaccurate as it would pull pulverized out for crafting into iron ingots as soon as they are crafted.

I know I could set up a ridiculous number of level emitters and export buses to accomplish this, but I'm trying to avoid that. Even if I used computers in place of the level emitters, I'd still need 1 export bus for every item I wanted to do something with like this.

So, I'm at a sticking point and looking to see if anyone else has any other ideas / alternatives to what I'm attempting to do.


EDIT: Oh, yeah guess I should mention I'm using ComputerCraft 1.58 and the currently available OpenPeripherals for it. Using a pack called The Crack Pack through ATLauncher.com, and that is what it has in it. I tried upgrading to CC 1.63 with this pack, but couldn't get any of the Open* stuff to work with it, so having to wait until the release official support for CC 1.6 and the pack updates.
Edited on 17 May 2014 - 02:05 AM
flaghacker #2
Posted 17 May 2014 - 06:21 AM
I have been trying to make a program like this a couple of weeks ago…

ae = peripheral.wrap(<side>)
jobs = ae.getJobList()
That function returns a table with all the current crafting jobs, with the same layout as ae.getStoredItems(). It's only available when your computer is next to the controller. I have found out that this function (as well as requestCrafting()) is very buggy and not reliable to use. So I never finished my autocrafting system…
Edited on 17 May 2014 - 04:23 AM
steven6282 #3
Posted 17 May 2014 - 10:22 AM
Well that is awesome. Didn't know that function was available next to the controller. Definitely solves my problem.

What are you referring to as being "very buggy" though? I modified my code to use this (put another computer with a wireless modem at my controller and set up a basic packet exchange between the two to get the information to the crafting control computer), and it seems to be working fairly reliably for me in my initial tests.

Granted, I've got a long ways to go for where I want this program to be, but I've got a basic workable config done now so that I can take my old sorting room offline hehe.
theoriginalbit #4
Posted 17 May 2014 - 10:35 AM
I believe flaghacker would be referring to this issue with the AE integration.
steven6282 #5
Posted 17 May 2014 - 07:57 PM
I believe flaghacker would be referring to this issue with the AE integration.

Ah… I see that is a pretty big problem. I didn't see it last night in my initial tests because I've got the program set up so that it only checks every 60 seconds for crafting jobs, and the ones I was testing with were finishing pretty fast, so didn't cause any issues.

I'd have the same problems I described before with it as it is if anything takes longer than 60 seconds to craft :(/>

Trying to figure out how to recompile the openp with the modification suggested in that post but I haven't done much java coding and it's complaining about symbols misisng lol. Guessing I'm going to have to decompile the entire package in order to compile the change into it.
flaghacker #6
Posted 17 May 2014 - 09:55 PM
I believe flaghacker would be referring to this issue with the AE integration.
Indeed. Also, ae.requestCrafting() doesn't always shows up in the crafting terminal. And if not all resources are available the crafting request stays hidden… It was a pain trying to debug my program…
theoriginalbit #7
Posted 18 May 2014 - 02:01 AM
Indeed. Also, ae.requestCrafting() doesn't always shows up in the crafting terminal.
it should never show up, with the way we have it currently coded there is no sometimes show up, it never shows up… this is due to an API change with AE, it not really a bug, as the crafting still happens, you just cannot see it happening.
steven6282 #8
Posted 18 May 2014 - 05:18 AM
You may see my post in the other thread here, but I'm working around this by using a modified version of AE Peripheral. http://www.computercraft.info/forums2/index.php?/topic/12663-mc-162-cc-156-applied-energistics-peripheral/page__st__40__gopid__179184#entry179184

Was able to get a copy of the source for that mod from Github so that I could modify it and fix the crafting request. Sucks to have to depend on yet another mod, but it's better than not being able to get my CC program working correctly :)/> If you are interested in how to apply that fix send me a message, I'll give you details on what I did to implement the fix, but not going to distribute the modified AEPeripheral mod without the authors permission.
theoriginalbit #9
Posted 18 May 2014 - 05:21 AM
Thank you but we know how to do the fix.
steven6282 #10
Posted 18 May 2014 - 06:47 AM
Thank you but we know how to do the fix.

Sorry, didn't mean to imply that you didn't. That was meant for other people like flaghacker possibly, that might not know how. And just to be clear, I'm not saying for sure he doesn't know how either, I'm just putting it out there for anyone that runs into the same problem as me and doesn't know how and wants some advice on it :)/>
flaghacker #11
Posted 18 May 2014 - 12:35 PM
Thank you but we know how to do the fix.

Sorry, didn't mean to imply that you didn't. That was meant for other people like flaghacker possibly, that might not know how. And just to be clear, I'm not saying for sure he doesn't know how either, I'm just putting it out there for anyone that runs into the same problem as me and doesn't know how and wants some advice on it :)/>/>

If you are allowed to post the modified version that would be very nice. If it's not allowed maybe you can pm me?

I also read the suggested fix, but I don't have a compiler/ decompiler setup…