ComputerCraft based crafting provider
ruifung opened this issue ยท 12 comments
The idea is like this:
- A computer registers a item it can craft with a crafting pipe, and its required materials.
- Computers can register multiple items it can craft.
- When a crafting request for one of the items is issued, fire a crafting event on the computer.
- Then wait for the result item to be in the attached inventory and extract it.
This would allow for programmable crafting lines, using CC based crafting to craft items.
Basically all it does is send the crafting event to the computer, and the computer handles requesting items from network and etc.
The biggest problem with CC is that all it's work is threaded. CC accessing LP isn't that difficult because you can let the CC thread wait for the Main MC thread. But letting the Main thread wait for an CC thread will only cause a lot of mess and of course lag. So the first difficult thing to figure out for this would be a general way of interaction in this direction.
Similar to how LP currently interacts with cc, let the computer do everything and notify the pipe with functions. And the pipe notifies the computer with a event. Would that work?
Like i sayed you would have to pause the main thread to wait for the computer and that is a no go.
I thought thats the CC's eventqueue for? that you dont have to wait on the computer?
Well you queue the event to the computer true but you would need to wait for an answer.
why? if its specified like the one above it only fires the crafting event to the computer, and waits in the (peripheral-)inventory for the result. the current crafting pipe does wait for the result in a similar way isnt it? you only have to specify a "timeout" of the crafting request until the pipe waits for its completion. (perhaps configurable)
this is what threads are for - we could easly create a "notify CC" task, and stick in in the list of things that the worker threads do (primarily rebuild routing tables atm); stalling one of the 4 threads for a tick or 2 won't matter.
Alternatively, have the computer notify the pipe that crafting is complete instead of checking for the crafting results.
Needs reevaluation. With the new ItemSink CC module and the crafting modules in general, there is a framework to make a CC crafting module.