public static T CacheInvokeFunc <T>(string Script, params ScriptArg[] Args) { LuaFuncRef Func = CacheCompile(Script); // TODO: Single environment using (LuaReference Env = Lua.CreateNewEnvironment(Lua.GUIEnvironment)) { Lua.SetEnvironment(Func, Env); foreach (var Arg in Args) { Lua.Set(Env, Arg.Name, Arg.Value); } return(Lua.Run <T>(Func)); } }