ComputerCraft

ComputerCraft

21M Downloads

[1.79] executeMainThreadTask strips ILuaObject

SquidDev opened this issue ยท 0 comments

commented

Returning instances of ILuaObject from ILuaContext.executeMainThreadTask strips instances of ILuaObject. This is because the object is converted to a table of functions, which are converted then converted to null. I'm not sure this is easily fixable, I'm just documenting this issue in case others hit it.

To get around this I've been creating a "pointer" class, storing to it, and then returning its result in the parent method.

Example

public class Foo implements ILuaObject {
  public Object[] callMethod(ILuaContext context, int method, Object[] args) 
    throws LuaException, InterruptedException {
    // Returns an empty table instead.
    return context.executeMainThreadTask(new ILuaTask() {
      public Object[] execute() throws LuaException { return Foo.this; }
    });
  }
}