ME Bridge - API issues
RelicFades opened this issue ยท 4 comments
Describe
Disclaimer:
Coding is just a hobby that I have. I am not particularly good at it, but I enjoy it.
Anyways...
While using the ME Bridge block from Advanced Peripherals with an advanced computer from CC:Tweaked-1.101.1 in the ATM8 Modpack in singleplayer and multiplayer both, I noticed a couple of things which I would consider a bug.
Consider the following code:
-- PERIPHERALS --
local meBridge = peripheral.wrap("meBridge_0")
-- VARS --
craftable = meBridge.listCraftableItems()
--[[
Let's assume that the ae2 system only has one item in it, which is a garden cloche
from IE. Let's also assume that we taught the ae2 system how to craft a garden
cloche from IE. Then, we can expect that the value of the variable "craftable" is the following:
{
1.0 = {
nbt = {id=immersiveengineering:cloche},
amount = 1.0,
isCraftable=true,
displayName=Garden Cloche,
name=immersiveengineering:cloche,
fingerprint=C08F101B9E015F8DE1EBC1E4A10D62E0
}
}
--]]
-- MAIN --
print(
textutils.serialise(meBridge.getItem(craftable[1]))
)
This code will execute perfectly if and only if one or more cloches currently exist in the system. If you take the only garden cloche/all of the garden cloches out of the system, or if none exist in the system in the first place (even if it is craftable), then following error will be produced:
bad argument #1 (table expected, got nil)
This behavior may be expected since "getItem()" was called on an item not in the system.
However, this item is craftable, and this behavior of "at least one item of that type must exist in this system" is also the same with the "craftItem" & "isItemCrafting()" functions (and others). If the specific item is checked, it needs to exist in the system first, or else an error is produced.
This is a huge issue because if you have no garden cloches but want to craft some using the ME Bridge, well you won't be able to. You will need at least one to exist within the system first... as explained above, you also won't be able to get the item data, or if the item is craftable, etc....
So, this issue is making it difficult for me to create useful programs with the ME Bridge.
Also, I wanted to request a feature for the ME Bridge:
As far as I can tell, if you request to craft an item with an ae2 system, the ME Bridge has no way of knowing how many of that item you requested to craft.
It would be nice if there was a way to tell, for example, maybe if the "getCraftingCPUs()" function also included that information (name and amount, and maybe some more info too). That would be nice. Currently, it only provides three pieces of information:
{
{
coProcessors = [int value],
isBusy = [bool],
storage = [int value]
}
}
I apologize if this post comes across as rude or a burden (which I did not intend for it to). Thank you for your time!
Steps to reproduce
Download the latest version of ATM8 as of 2/28/23 on CurseForge and launch it,
launch singleplayer or multiplayer once the pack is done booting,
then test out the ME Bridge block API on a CC:Tweaked computer.
Multiplayer?
Yes
Version
AdvancedPeripherals-0.7.22b
Minecraft, Forge and maybe other related mods versions
Forge 43.2.3 Minecraft 1.19.2 CC:Tweaked-1.101.1 AE2-forge-12.9.2 ATM8-1.0.10
Screenshots or Videos
No response
Crashlog/log
No response
Also, I wanted to request a feature for the ME Bridge:
As far as I can tell, if you request to craft an item with an ae2 system, the ME Bridge has no way of knowing how many of that item you requested to craft.
I assume you mean how much actually was requested/calculated after you run craftItem
- yeah that wouldn't be a problem to add
Not sure why getItem
returns nil if the item is craftable but not in the system, I'll investigate that more later the day
Coding is just a hobby that I have. I am not particularly good at it, but I enjoy it.
Relatable, no problem ๐
I apologize if this post comes across as rude or a burden (which I did not intend for it to). Thank you for your time!
Nah it didn't, don't worry ๐
Just one thing - it would be better for me if you could request a feature in another post, this is easier for me to manage. Otherwise I might forget that you had a feature request in here
So the thing is, the stacks returned from listCraftableItems
can't be parsed by the filter.
The nbt
tag is not formerly formatted for that
What you could do is setting the nbt
value to nil like stated here โ
I was able to fix that by trying to parse a table if parsing a string does not work.
However, I would still recommend setting the nbt value to nil in case something is off with the nbt values.