MightyPirates / OpenComputers

Home of the OpenComputers mod for Minecraft.
https://oc.cil.li
Other
1.59k stars 431 forks source link

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 #3212

Open Yarillo4 opened 4 years ago

Yarillo4 commented 4 years ago

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

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

SquidDev commented 4 years ago

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.

payonel commented 4 years ago

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

SquidDev commented 4 years ago

@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

Yarillo4 commented 4 years ago

Any updates on this?