Is there any possible to use more than three arguments in lua function?
Here is my piece of code:
LuaValue luaGlobals = JsePlatform.standardGlobals();
luaGlobals.get("dofile").call(LuaValue.valueOf("./data/Actions/" + a_itemScript));
LuaValue luaValLevel = CoerceJavaToLua.coerce(a_level);
LuaValue luaValPlayer = CoerceJavaToLua.coerce(a_player);
LuaValue luaValItem = CoerceJavaToLua.coerce(a_thing);
LuaValue luaValItemX = CoerceJavaToLua.coerce(a_fromX);
LuaValue luaValItemY = CoerceJavaToLua.coerce(a_fromY);
LuaValue luaOnUse = luaGlobals.get("onUse");
if(!luaOnUse.isnil())
{
luaOnUse.call(luaValLevel, luaValItemX, luaValItemY);
}
else
{
a_parent.WriteInConsole("\nx Cannot Run Script: " + a_itemScript);
}
Use LuaValue.invoke() instead of LuaValue.call(). It takes a Varargs which can contain any number of arguments, and returns a Varargs containing all the return values:
Varargs results = luaOnUse.invoke(
LuaValue.varargsOf(new LuaValue[] {
luaValLevel, luaValPlayer, luaValItem, luaValItemX, luaValItemY }));