本文整理汇总了Java中dan200.computercraft.api.lua.ILuaContext.executeMainThreadTask方法的典型用法代码示例。如果您正苦于以下问题:Java ILuaContext.executeMainThreadTask方法的具体用法?Java ILuaContext.executeMainThreadTask怎么用?Java ILuaContext.executeMainThreadTask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dan200.computercraft.api.lua.ILuaContext
的用法示例。
在下文中一共展示了ILuaContext.executeMainThreadTask方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import dan200.computercraft.api.lua.ILuaContext; //导入方法依赖的package包/类
public Object[] execute(IComputerAccess computer, ILuaContext context) throws LuaException, InterruptedException {
Object[] result = context.executeMainThreadTask(this);
if (delay > 0) LuaEnvironment.instance.sleep(computer, context, delay);
return result;
}
示例2: callMethod
import dan200.computercraft.api.lua.ILuaContext; //导入方法依赖的package包/类
@Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException {
System.out.println("Arguements: ");
for(Object t : arguments)
System.out.println(" - " + t);
if(method == 0){
if (arguments.length < 1 || arguments.length > 3) {
throw new LuaException("command usage: createPacket(<DataType>, [DataContents], [timeOut])");
} else {
Object dataTypeObject = arguments[0];
if (dataTypeObject instanceof String) {
String dataType = (String) dataTypeObject;
ByteValues byt = null;
int timeOut = -1;
Object contents = null;
if (arguments.length >= 2)
contents = arguments[1];
if (arguments.length == 3)
timeOut = Integer.parseInt((String) arguments[2]);
for (ByteValues bu : ByteValues.values()) {
if (bu.Id.equalsIgnoreCase(dataType)) {
byt = bu;
}
}
EventPacket packet = null;
if (byt == ByteValues.DataSignal) {
packet = new DataPacket(timeOut);
((DataPacket) packet).SaveData("data", new DataStringValue("test"));
}
final EventPacket packetUse = packet;
if (packetUse != null) {
SendPacketToAround(packet);
context.executeMainThreadTask(new ILuaTask() {
@Override
public Object[] execute() throws LuaException {
return new Object[0];
}
});
}
} else {
throw new LuaException("DataType is required to be a string");
}
}
}
return null;
}