OpenComputers
OpenComputers copied to clipboard
Calling certain external component functions works on OpenComputer through the 'component' variable, but the same functions return "nil" if called through a relay with a ComputerCraft computer
OpenComputers 1.7.5.192 CC-Tweaked 1.85.2 AppliedEnergistics2 rv6-stable-7
Here's a ME Controller with a single item in its drives
It's being invoked fine on OC
But here's on ComputerCraft
- canExtract():bool => works
- canReceive():bool => works
- getAvgPowerInjection():float => works
- getAvgPowerInjection():float => works
- getCpus():table => always nil
- getCraftables():table => always nil
- getEnergyStored():float => works
- getItemsInNetwork():table => always nil
It seems like tables do not make it through the relay.
For what it's worth, the relay is fully upgraded with a tier 3 disk, tier 3 CPU and a tier 3.5 ram stick so the serialized data should have room ?
The whole setup is like so (yes it's powered)
Obvious disclaimer that I'm not super well-versed in OC internals, so may be misreading things...
Looking at RelayPeripheral, it appears that the result of Component.invoke
is returned immediately without any intermediate conversion:
https://github.com/MightyPirates/OpenComputers/blob/310db04d3379d884293c741f251cfc4343d27eae/src/main/scala/li/cil/oc/integration/computercraft/RelayPeripheral.scala#L60
However, some methods like getItemsInNetwork
return an array of values, rather than a map. CC does not support this, and so it is skipped and null
/nil
is returned.
I'll have a look at expanding the conversion logic on CC:T's side - it's something I've been meaning to do for a while. That said, it's probably worth adding further conversions on the OC side, so that all versions of MC/CC are supported.
@SquidDev you mean you'd like to see us convert an array response from that invoke and convert it to a map before returning from callRemote?
@payonel I'm afraid yes. I suspect you'll need to handle all of the cases in ScalaClosure.toLuaValue
, as you'll also have arrays inside maps. Sorry!
https://github.com/MightyPirates/OpenComputers/blob/e452b1fb5ef8bd13e845b0fe18d3752b9c0a59be/src/main/scala/li/cil/oc/util/ScalaClosure.scala#L48-L54
Any updates on this?