Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ME Bridge enhancements #100

Open
chuman72486 opened this issue Dec 2, 2024 · 1 comment
Open

ME Bridge enhancements #100

chuman72486 opened this issue Dec 2, 2024 · 1 comment
Labels
area-Bridges ME/RS Bridge or other heavy networks

Comments

@chuman72486
Copy link

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....

local success, chestJob = meBridge.craftItem({name="minecraft:chest", amount= 100})
if success then
while chestJob.isComplete == false do
                   --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 requested
if chestJob.time > 300 then
meBridge.craftCancel(chestJob)
write("Cancelled job - Took too long.")
end
end
else
write("Job failed to start")
write(chestJob.status)  --status would be failed or some kind of error state that describes why it failed
end
                  --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

@zyxkad zyxkad added the area-Bridges ME/RS Bridge or other heavy networks label Dec 2, 2024
@SirEndii SirEndii added this to the 0.8r milestone Dec 2, 2024
@SirEndii
Copy link
Member

SirEndii commented Dec 2, 2024

fits perfectly to the current changes to the ME and RS bridge in 0.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Bridges ME/RS Bridge or other heavy networks
Projects
Status: No status
Development

No branches or pull requests

3 participants