[1.189.0] [In-game scripts] IMyInventory.IsConnectedTo caches responses.
Solved
It looks like the method VRage.Game.ModAPI.Ingame.IMyInventory.IsConnectedTo is caching its responses per block and in consequence returns wrong results after first use.
I've made a setup with three basic refineries: "Refinery A", "Refinery B" and "Refinery C".
"Refinery A" is connected to "Refinery B" by conveyor tube.
"Refinery C" stands alone.
Then I've executed the following code in a programmable block:
public void Main(string argument, UpdateType updateSource) { const string nameA = "Refinery A", nameB = "Refinery B", nameC = "Refinery C"; var a = (IMyRefinery)GridTerminalSystem.GetBlockWithName(nameA); var b = (IMyRefinery)GridTerminalSystem.GetBlockWithName(nameB); var c = (IMyRefinery)GridTerminalSystem.GetBlockWithName(nameC); var aInv = a.InputInventory; var bInv = b.InputInventory; var cInv = c.InputInventory; Echo(a.CustomName + (aInv == null ? " ERR" : " OK")); Echo(b.CustomName + (bInv == null ? " ERR" : " OK")); Echo(c.CustomName + (cInv == null ? " ERR" : " OK")); Echo(aInv.IsConnectedTo(bInv) ? "a to b connected" : "a to b not conn."); Echo(aInv.IsConnectedTo(cInv) ? "a to c connected" : "a to c not conn."); Echo(bInv.IsConnectedTo(aInv) ? "b to a connected" : "b to a not conn."); Echo(bInv.IsConnectedTo(cInv) ? "b to c connected" : "b to c not conn."); Echo(cInv.IsConnectedTo(aInv) ? "c to a connected" : "c to a not conn."); Echo(cInv.IsConnectedTo(bInv) ? "c to b connected" : "c to b not conn."); }
The output was:
Refinery A OK Refinery B OK Refinery C OK a to b connected a to c connected b to a connected b to c connected c to a not conn. c to b not conn.
The output tells that "Refinery A" is connected to "Refinery C" and "Refinery B" is also connected to "Refinery C" which is wrong.Changing order in which the IsConnectedTo is called gives different results.
Space Engineers version: 1.189.040 default
Here is a world that demonstrates the bug:
https://steamcommunity.com/sharedfiles/filedetails/?id=1674393303
Run the PB script and check the echo. ExpectedResult: ActualResult
Here is a world that demonstrates the bug:
https://steamcommunity.com/sharedfiles/filedetails/?id=1674393303
Run the PB script and check the echo. ExpectedResult: ActualResult
I had this also. My transfer function checks this before attempting transfers, building something like a refinery that's not connected to anything stops all transfers and my script returns that nothing is connected.
I had this also. My transfer function checks this before attempting transfers, building something like a refinery that's not connected to anything stops all transfers and my script returns that nothing is connected.
Hello, Engineers!
Thank you for reporting this issue. We have been able to reproduce it and it is forwarded to programmers team.
Kind Regards
Keen Software House: QA Department
Hello, Engineers!
Thank you for reporting this issue. We have been able to reproduce it and it is forwarded to programmers team.
Kind Regards
Keen Software House: QA Department
IMyInventory.CanTransferItemTo() also dosn't work. I hope this will be fixed soon.
IMyInventory.CanTransferItemTo() also dosn't work. I hope this will be fixed soon.
I just got a report that this is happening to someone that uses my script. I went to test it and found the same result for the first time in my test that I've ran hundreds of times. I've probably only ran the test with the IsConnectedTo function about 100 times.
I pasted in my test grid. It has 10k of every ore and ingot in a Cargo Container. The container is connected to the rest of the conveyor network via a blacklist sorter that is kept off with nothing blacklisted. I use the sorter as a valve and press a button that turns it on. Normally when I paste in my test grid I will get a list of responses from my script saying the container is not connected to anything, but this time I got no responses. I assume it either cached 'True' that everything is connected (when it is not) or something else changed and it didn't do what it was supposed to do.
I just got a report that this is happening to someone that uses my script. I went to test it and found the same result for the first time in my test that I've ran hundreds of times. I've probably only ran the test with the IsConnectedTo function about 100 times.
I pasted in my test grid. It has 10k of every ore and ingot in a Cargo Container. The container is connected to the rest of the conveyor network via a blacklist sorter that is kept off with nothing blacklisted. I use the sorter as a valve and press a button that turns it on. Normally when I paste in my test grid I will get a list of responses from my script saying the container is not connected to anything, but this time I got no responses. I assume it either cached 'True' that everything is connected (when it is not) or something else changed and it didn't do what it was supposed to do.
Replies have been locked on this page!