public static void Run(string commandname, string[] args, bool fromGroup, string ChatterID, string ChatRoomID) { try { using (Lua lua = new Lua()) { GlobalSteamLuaFunctions steamFunc = new GlobalSteamLuaFunctions(); lua.RegisterFunction("kickPlayer", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("kickPlayer")); lua.RegisterFunction("notImplemented", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("notImplemented")); lua.RegisterFunction("getPermissions", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("getPermissions")); lua.RegisterFunction("sendRoomMessage", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("sendRoomMessage")); lua.RegisterFunction("sendFriendMessage", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("sendFriendMessage")); //lua.RegisterFunction("convertChatIDtoSteamKit", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("convertChatIDtoSteamKit")); lua.RegisterFunction("getPersonaName", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("getPersonaName")); lua.RegisterFunction("addRow", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("addRow")); lua.RegisterFunction("getRow", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("getRow")); lua.RegisterFunction("bindCommand", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("bindCommand")); lua.RegisterFunction("unbindCommand", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("unbindCommand")); lua.RegisterFunction("changePermissions", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("changePermissions")); lua.RegisterFunction("changeName", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("changeName")); lua.RegisterFunction("likeRow", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("likeRow")); lua.RegisterFunction("getCustomURL", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("getCustomURL")); lua.RegisterFunction("banPlayer", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("banPlayer")); lua.RegisterFunction("createTable", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("createTable")); lua.RegisterFunction("silentFail", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("silentFail")); lua["ChatterID"] = ChatterID; lua["fromGroup"] = fromGroup; lua["ChatRoomID"] = ChatRoomID; lua["args"] = args; for(int i = 1; i < args.Count(); i++) { if (i == 1) { argsJoined = args[i]; } else { argsJoined = argsJoined + " " + args[i]; } } lua["argsJoined"] = argsJoined; lua.DoFile("lua/commands/" + commandname.Substring(1) + ".lua"); } } catch (Exception e) { Log.addLog(Log.types.WARNING, "Lua", "You have an error in your command!", e.ToString()); } }
public static void Run(string scriptname, params string[] args) { try { using (Lua lua = new Lua()) { GlobalSteamLuaFunctions steamFunc = new GlobalSteamLuaFunctions(); lua.RegisterFunction("kickPlayer", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("kickPlayer")); lua.RegisterFunction("notImplemented", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("notImplemented")); lua.RegisterFunction("getPermissions", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("getPermissions")); lua.RegisterFunction("sendRoomMessage", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("sendRoomMessage")); lua.RegisterFunction("sendFriendMessage", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("sendFriendMessage")); lua.RegisterFunction("getPersonaName", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("getPersonaName")); lua.RegisterFunction("addRow", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("addRow")); lua.RegisterFunction("getRow", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("getRow")); lua.RegisterFunction("bindCommand", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("bindCommand")); lua.RegisterFunction("unbindCommand", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("unbindCommand")); lua.RegisterFunction("changePermissions", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("changePermissions")); lua.RegisterFunction("changeName", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("changeName")); lua.RegisterFunction("likeRow", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("likeRow")); lua.RegisterFunction("getCustomURL", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("getCustomURL")); lua.RegisterFunction("banPlayer", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("banPlayer")); lua.RegisterFunction("createTable", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("createTable")); lua.RegisterFunction("setLoginCredentials", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("setLoginCredentials")); lua.RegisterFunction("joinChat", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("joinChat")); lua.RegisterFunction("setAuthCode", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("setAuthCode")); lua.RegisterFunction("connect", steamFunc, typeof(GlobalSteamLuaFunctions).GetMethod("connect")); lua["args"] = args; for (int i = 1; i < args.Count(); i++) { if (i == 1) { argsJoined = args[i]; } else { argsJoined = argsJoined + " " + args[i]; } } lua["argsJoined"] = argsJoined; lua.DoFile("lua/scripts/" + scriptname + ".lua"); } } catch (Exception e) { Log.addLog(Log.types.WARNING, "Lua", "You have an error in your command!", e.ToString()); } }