diff --git a/TShockAPI/LuaSystem/LuaLoader.cs b/TShockAPI/LuaSystem/LuaLoader.cs index 4eaf2f49..78f41f20 100644 --- a/TShockAPI/LuaSystem/LuaLoader.cs +++ b/TShockAPI/LuaSystem/LuaLoader.cs @@ -17,7 +17,7 @@ namespace TShockAPI.LuaSystem public LuaHookBackend HookBackend = new LuaHookBackend(); public LuaHooks HookCalls = new LuaHooks(); public Dictionary> Hooks = new Dictionary - >(); + >(); public LuaLoader(string path) { _lua = new Lua(); @@ -89,11 +89,33 @@ namespace TShockAPI.LuaSystem public void RegisterLuaFunctions() { - LuaFunctions LuaFuncs = new LuaFunctions(this); - _lua.RegisterFunction("Print", LuaFuncs, LuaFuncs.GetType().GetMethod("Print")); - _lua.RegisterFunction("HookAdd", LuaFuncs, LuaFuncs.GetType().GetMethod("HookAdd")); - _lua.RegisterFunction("HookRemove", LuaFuncs, LuaFuncs.GetType().GetMethod("HookRemove")); + //I just added all the managers for Plugin Development. :) + //Feel free to remove any if you dont feel they are necessay + _lua["Players"] = TShock.Players; + _lua["Bans"] = TShock.Bans; + _lua["Warps"] = TShock.Warps; + _lua["Regions"] = TShock.Regions; + _lua["Backups"] = TShock.Backups; + _lua["Groups"] = TShock.Groups; + _lua["Users"] = TShock.Users; + _lua["Itembans"] = TShock.Users; + + + LuaFunctions LuaFuncs = new LuaFunctions(this); + var LuaFuncMethods = LuaFuncs.GetType().GetMethods(); + foreach (System.Reflection.MethodInfo method in LuaFuncMethods) + { + _lua.RegisterFunction(method.Name, LuaFuncs, method); + } + + //Utils + Utils LuaUtils = new Utils(this); + var LuaUtilMethods = LuaUtils.GetType().GetMethods(); + foreach (System.Reflection.MethodInfo method in LuaUtilMethods) + { + _lua.RegisterFunction(method.Name, LuaUtils, method); + } } } diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 95338ba3..7dc0a04a 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -24,11 +24,22 @@ using System.Net.Sockets; using System.Security.Cryptography; using System.Text; using Terraria; +using TShockAPI.LuaSystem; namespace TShockAPI { public class Utils { + LuaLoader Parent; //For Lua Functions that require the LuaLoader + public Utils() + { + } + + public Utils(LuaLoader parent) + { + Parent = parent; + } + public Random Random = new Random(); //private static List groups = new List();