ME Bridge getItem() does not trigger error upon disconnection
estafeit opened this issue · 7 comments
Describe
It's me again, sorry !
All is in title. If using getItem() with a missing cable, getItem() return is empty but it triggers no error. Same beahviour if item is absent in the network. We need to be able to figure the difference between the two !
ie. I'm tring to craft items only if network don't contains more than a given amount. If I cut the cable by mistake, my rig will keep crafting items without limit, thinking there is none in network.
For now one can do a listItems() first to check if inventory is empty, but that's not good, performance-wise
EDIT: On second thought, listItems() should return an error too ^^
Steps to reproduce
Use getItem() on a disconnected ME bridge
Multiplayer?
No
Version
1.19.2-0.7.27r (Latest 1.19.2)
Minecraft, Forge and maybe other related mods versions
mc 1.19.2, atm 8
Screenshots or Videos
No response
Crashlog/log
No response
bridge = peripheral.find("meBridge")
result, err = bridge.listItems()
if err then
print("oh no, something isn't right.", err)
end
OK I should have known about isConnected, but I'm positive this does return err == nil and result = {} in my case. Same goes for getItem().
You can check with isConnected
that the bridge is connected and the grid is available
And every method will return an error if it's not connected.
bridge = peripheral.find("meBridge")
result, err = bridge.listItems()
if err then
print("oh no, something isn't right.", err)
end
This would print the message with a NOT_CONNECTED
returned by the bridge
I assume isConnected
only returns false if nothing is connected
But I'll improve that!
I made a simple program to check this :
local bridge = peripheral.find("meBridge")
if (not bridge) then
print("Can't connect to ME Bridge !")
return
else
print("Connected to ME Bridge !")
end
local isConnected = bridge.isConnected()
print("isConnected ? : " .. textutils.serialize(isConnected))
local result, err = bridge.listItems()
print("result:" .. textutils.serialize(result) .. " error: " .. textutils.serialize(err))
. I ran it in two cases. Here are the setups :