private void registerWoWApiFunctions() { lua.RegisterFunction("UnitClass", api, api.GetType().GetMethod("UnitClass")); lua.RegisterFunction("UnitName", api, api.GetType().GetMethod("UnitName")); lua.RegisterFunction("UnitAffectingCombat", api, api.GetType().GetMethod("UnitAffectingCombat")); lua.RegisterFunction("GetTime", api, api.GetType().GetMethod("GetTime")); lua.RegisterFunction("max", api, api.GetType().GetMethod("max")); lua.RegisterFunction("floor", api, api.GetType().GetMethod("floor")); lua.RegisterFunction("GetWoWEventsObject", events, events.GetType().GetMethod("Instance")); lua.RegisterFunction("GetDefaultChatFrame", this, this.GetType().GetMethod("GetDefaultChatFrame")); // it seems like NLua doesn't support passing parameters by-reference unlike the WoW api, so we're returning the new values instead lua.DoString( "function wipe(arr)\n" + " arr = {};\n" + " return arr;\n" + "end\n" ); lua.DoString( "function tinsert(arr, element)\n" + " table.insert(arr, element);\n" + " return arr;\n" + "end\n" ); lua.DoString( "function tremove(arr, index)\n" + " table.remove(arr, index);\n" + " return arr;\n" + "end\n" ); lua.DoString("DEFAULT_CHAT_FRAME = GetDefaultChatFrame();"); }