OpenComputers icon indicating copy to clipboard operation
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

Open Yarillo4 opened this issue 5 years ago • 4 comments

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

OC

It's being invoked fine on OC

But here's on ComputerCraft

CC

  • 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 ?

Relay

The whole setup is like so (yes it's powered)

Setup

Yarillo4 avatar Jan 12 '20 08:01 Yarillo4

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 avatar Jan 13 '20 12:01 SquidDev

@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 avatar Jan 13 '20 14:01 payonel

@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

SquidDev avatar Jan 13 '20 14:01 SquidDev

Any updates on this?

Yarillo4 avatar Oct 01 '20 09:10 Yarillo4