You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe your idea (If you have more than one idea, please open the rest in other issues)
It would be helpful if functions could return some additional details.
Let the crafting event return a more useful status.
craft started
craft delayed/calculating
craft finished
any other useful details, like waiting on prerequisite crafts to complete
Similarly, craftItem() should return if the request failed, such as insufficient materials, no free CPUs, etc.
Alternatively, craftItem() can return a handle for the crafting job. You can then call specific functions, such as to cancel the job, check how long the job has been running, the progress and current status of the job like if it's waiting for materials to be crafted, etc.
An example....
localsuccess, chestJob=meBridge.craftItem({name="minecraft:chest", amount=100})
ifsuccessthenwhilechestJob.isComplete==falsedo--isComplete will be true if the job finished or was cancelled,--another property such as chestJob.status can show what the--exit condition was (cancelled, completed, failed, etc) or what--it's currently doing.write("Chests are crafting...")
write(("%d of %d completed."):format(chestJob.progress,chestJob.total)
--progress shows how many of the item has been crafted so far, total shows how many were requestedifchestJob.time>300thenmeBridge.craftCancel(chestJob)
write("Cancelled job - Took too long.")
endendelsewrite("Job failed to start")
write(chestJob.status) --status would be failed or some kind of error state that describes why it failedend--Obviously there may be errors in this code, like how write() is being used,--but this is just meant to show how I think it could be implemented.
If this is added, a function to find the job later might be useful, like getCraftingJobs() that returns a table with all of the jobs created with craftItem() or craftFluid(), and you can access each job with functions like craftCancel(), getCraftJob() or others.
isItemCrafting() should not just return true/false, but also details about the craft, like what's in the current crafting job (how many were requested, how many are done, is it currently waiting for prerequisite materials to be crafted, what CPU is the job running on?)
isItemCraftable() should be false if it doesn't have enough materials, or another function should be available to check if the recipe has enough materials. If this function would return false, it should have a second return with a reason it's not craftable (no crafting pattern available, insufficient materials, etc.)
getCraftingCPUs() should also return the CPU's name in the table, so it can be mapped and used later. If a number or name is in the arguments like getCraftingCPUs('cpu1'), then it should just return the details for that Crafting CPU.
It could be useful for listCraftableItems() to return the pattern as part of the table it returns, like a field with another table listing the components of the pattern. This way the program can check those items and make sure there's enough available before requesting the craft. Also the IsCraftable field is kinda pointless since if it's in the list then it's craftable. If IsCraftable would be false, then it wouldn't be in the list in the first place. Either remove IsCraftable or make it true/false based on if the item could actually be crafted with the current materials available.
Describe alternatives you've considered if any
As it is right now, one would have to know the recipe of the item they're going to request, then check getItem() to see if all the materials are available, and if needed run down a nested loop of any materials that can themselves be crafted, until it can decide if the request can be done. Then check isItemCraftable(), which honestly doesn't tell you anything besides if the item has a crafting pattern in a pattern provider somewhere in the network, not whether it can actually be requested successfully. Finally check isItemCrafting() to determine if the job was already called previously and hasn't finished yet. If all is good, you can finally call craftItem(), but then you basically have to guess what your crafting CPU is called, or let the ME Bridge pick one for you. craftItem() will return true regardless if the job actually successfully started, only failing if the AE2 system is not capable of accepting the job (offline, no crafting pattern, etc). The event crafting also only shows that the request was sent to AE2, but not whether the job actually started. At best you can call isItemCrafting() after you use craftItem() to hopefully see if the item is now in a crafting status and just keep checking isItemCrafting() until it returns false and then you can hope it completed successfully, or maybe check getItem() to see if the amount has changed.
Additional context
No response
Linked Issues
No response
The text was updated successfully, but these errors were encountered:
Describe your idea (If you have more than one idea, please open the rest in other issues)
It would be helpful if functions could return some additional details.
Let the
crafting
event return a more useful status.Similarly,
craftItem()
should return if the request failed, such as insufficient materials, no free CPUs, etc.Alternatively,
craftItem()
can return a handle for the crafting job. You can then call specific functions, such as to cancel the job, check how long the job has been running, the progress and current status of the job like if it's waiting for materials to be crafted, etc.An example....
If this is added, a function to find the job later might be useful, like
getCraftingJobs()
that returns a table with all of the jobs created withcraftItem()
orcraftFluid()
, and you can access each job with functions likecraftCancel()
,getCraftJob()
or others.isItemCrafting()
should not just return true/false, but also details about the craft, like what's in the current crafting job (how many were requested, how many are done, is it currently waiting for prerequisite materials to be crafted, what CPU is the job running on?)isItemCraftable()
should be false if it doesn't have enough materials, or another function should be available to check if the recipe has enough materials. If this function would return false, it should have a second return with a reason it's not craftable (no crafting pattern available, insufficient materials, etc.)getCraftingCPUs()
should also return the CPU's name in the table, so it can be mapped and used later. If a number or name is in the arguments likegetCraftingCPUs('cpu1')
, then it should just return the details for that Crafting CPU.It could be useful for
listCraftableItems()
to return the pattern as part of the table it returns, like a field with another table listing the components of the pattern. This way the program can check those items and make sure there's enough available before requesting the craft. Also theIsCraftable
field is kinda pointless since if it's in the list then it's craftable. IfIsCraftable
would be false, then it wouldn't be in the list in the first place. Either removeIsCraftable
or make it true/false based on if the item could actually be crafted with the current materials available.Describe alternatives you've considered if any
As it is right now, one would have to know the recipe of the item they're going to request, then check
getItem()
to see if all the materials are available, and if needed run down a nested loop of any materials that can themselves be crafted, until it can decide if the request can be done. Then checkisItemCraftable()
, which honestly doesn't tell you anything besides if the item has a crafting pattern in a pattern provider somewhere in the network, not whether it can actually be requested successfully. Finally checkisItemCrafting()
to determine if the job was already called previously and hasn't finished yet. If all is good, you can finally callcraftItem()
, but then you basically have to guess what your crafting CPU is called, or let the ME Bridge pick one for you.craftItem()
will returntrue
regardless if the job actually successfully started, only failing if the AE2 system is not capable of accepting the job (offline, no crafting pattern, etc). The eventcrafting
also only shows that the request was sent to AE2, but not whether the job actually started. At best you can callisItemCrafting()
after you usecraftItem()
to hopefully see if the item is now in a crafting status and just keep checkingisItemCrafting()
until it returnsfalse
and then you can hope it completed successfully, or maybe checkgetItem()
to see if the amount has changed.Additional context
No response
Linked Issues
No response
The text was updated successfully, but these errors were encountered: