diff --git a/TShockAPI/LuaSystem/LuaLoader.cs b/TShockAPI/LuaSystem/LuaLoader.cs index 3d1e4c02..ef458050 100644 --- a/TShockAPI/LuaSystem/LuaLoader.cs +++ b/TShockAPI/LuaSystem/LuaLoader.cs @@ -14,8 +14,8 @@ namespace TShockAPI.LuaSystem public string LuaPath = ""; public string LuaAutorunPath = ""; - public Dictionary> Hooks = new Dictionary - >(); + public Dictionary> Hooks = new Dictionary + >(); public LuaLoader(string path) { Lua = new Lua(); @@ -96,10 +96,10 @@ namespace TShockAPI.LuaSystem Console.WriteLine("Running hook test."); - foreach (KeyValuePair> kv in Hooks) + foreach (KeyValuePair> kv in Hooks) { - KeyValuePair hook = kv.Value; - LuaFunction lf = FindLuaFunction(hook.Value); + KeyValuePair hook = kv.Value; + LuaFunction lf = hook.Value; if (lf != null) { @@ -107,17 +107,6 @@ namespace TShockAPI.LuaSystem } } } - - public LuaFunction FindLuaFunction(string name) - { - try - { - return Lua.GetFunction(name); - } catch (Exception) - { - return null; - } - } } public class LuaFunctions @@ -130,10 +119,10 @@ namespace TShockAPI.LuaSystem Console.ForegroundColor = previousColor; } - public void Hook(string hook, string key, string callback) + public void Hook(string hook, string key, LuaFunction callback) { - KeyValuePair hhook = new KeyValuePair(hook, callback); - TShock.LuaLoader.Hooks.Add(key, hhook); + KeyValuePair internalhook = new KeyValuePair(hook, callback); + TShock.LuaLoader.Hooks.Add(key, internalhook); } } }