public void onTabComlete(LuaValue f) { tabComleteFunction = f.checkfunction(); } }
/** Return argument i as a function, or throw an error if an incompatible type. * @param i the index of the argument to test, 1 is the first argument * @return LuaValue that can be called if argument i is lua function or closure * @exception LuaError if the argument is not a lua function or closure * */ public LuaFunction checkfunction(int i) { return arg(i).checkfunction(); }
public LuaValue call(LuaValue f) { return new LuaThread(globals, f.checkfunction()); } }
/** Return argument i as a function, or throw an error if an incompatible type. * @param i the index of the argument to test, 1 is the first argument * @return LuaValue that can be called if argument i is lua function or closure * @exception LuaError if the argument is not a lua function or closure * */ public LuaFunction checkfunction(int i) { return arg(i).checkfunction(); }
public LuaValue call(LuaValue f) { return new LuaThread(globals, f.checkfunction()); } }
/** Return argument i as a function, or throw an error if an incompatible type. * @param i the index of the argument to test, 1 is the first argument * @return LuaValue that can be called if argument i is lua function or closure * @exception LuaError if the argument is not a lua function or closure * */ public LuaFunction checkfunction(int i) { return arg(i).checkfunction(); }
@Override public LuaValue call(LuaValue function, LuaValue delay) { Thread thread = new Thread(() -> { try { if (delay != LuaValue.NIL) Thread.sleep(delay.checklong()); function.checkfunction().call(); } catch (InterruptedException ignored) { } }); thread.start(); return LuaValue.NIL; } });
public LuaValue call(LuaValue arg) { LuaValue f = arg.checkfunction(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { DumpState.dump( ((LuaClosure)f).p, baos, true ); return LuaString.valueUsing(baos.toByteArray()); } catch (IOException e) { return error( e.getMessage() ); } } }
public LuaValue call(LuaValue arg) { LuaValue f = arg.checkfunction(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { DumpState.dump( ((LuaClosure)f).p, baos, true ); return LuaString.valueUsing(baos.toByteArray()); } catch (IOException e) { return error( e.getMessage() ); } } }
public LuaValue call(LuaValue f) { final LuaValue func = f.checkfunction(); final LuaThread thread = new LuaThread(globals, func); return new wrapper(thread); } }
public LuaValue call(LuaValue f) { final LuaValue func = f.checkfunction(); final LuaThread thread = new LuaThread(globals, func); return new wrapper(thread); } }
@Override public LuaValue call(LuaValue table, LuaValue compare) { table.checktable().sort(compare.isnil()? NIL: compare.checkfunction()); return NONE; } }
@Override public LuaValue call(LuaValue callback) { if (callback.isfunction()) { plugin.setLoadCB(callback.checkfunction()); } else { throw new LukkitPluginException("There was an issue registering the onLoad callback - was provided a " + callback.typename() + " instead of a function."); } return LuaValue.NIL; } });
@Override public LuaValue call(LuaValue callback) { if (callback.isfunction()) { plugin.setEnableCB(callback.checkfunction()); } else { throw new LukkitPluginException("There was an issue registering the onEnable callback - was provided a " + callback.typename() + " instead of a function."); } return LuaValue.NIL; } });
@Override public LuaValue call(LuaValue callback) { if (callback.isfunction()) { plugin.setDisableCB(callback.checkfunction()); } else { throw new LukkitPluginException("There was an issue registering the onDisable callback - was provided a " + callback.typename() + " instead of a function."); } return LuaValue.NIL; } });
public Varargs invoke(Varargs args) { args.arg1().checktable().sort( args.arg(2).isnil()? NIL: args.arg(2).checkfunction()); return NONE; } }
public Varargs invoke(Varargs args) { args.arg1().checktable().sort( args.arg(2).isnil()? NIL: args.arg(2).checkfunction()); return NONE; } }
public Varargs invoke(Varargs args) { LuaValue ld = args.arg1(); args.argcheck(ld.isstring() || ld.isfunction(), 1, "ld must be string or function"); String source = args.optjstring(2, ld.isstring()? ld.tojstring(): "=(load)"); String mode = args.optjstring(3, "bt"); LuaValue env = args.optvalue(4, globals); return loadStream(ld.isstring()? ld.strvalue().toInputStream(): new StringInputStream(ld.checkfunction()), source, mode, env); } }
@Override public Varargs invoke(Varargs args) { LuaFunction chunk = args.arg(1).checkfunction(); LuaValue name = args.arg(2); final LuaValue res = chunk.call(); if (name.isnil()) { return LuaValue.varargsOf(new LuaValue[]{LuaValue.TRUE, res}); } else { if (!res.istable()) { return LuaValue.varargsOf(new LuaValue[]{FALSE, toLuaString(res.typename())}); } else { return LuaValue.varargsOf(new LuaValue[]{LuaValue.TRUE, res.checktable().get(name)}); } } } });
public Varargs invoke(Varargs args) { LuaValue ld = args.arg1(); args.argcheck(ld.isstring() || ld.isfunction(), 1, "ld must be string or function"); String source = args.optjstring(2, ld.isstring() ? ld.tojstring() : "=(load)"); String mode = args.optjstring(3, "bt"); LuaValue env = args.optvalue(4, globals); return loadStream(ld.isstring() ? ld.strvalue().toInputStream() : new StringInputStream(ld.checkfunction()), source, mode, env); } }