Staging 2

This commit is contained in:
Lucas Nicodemus 2012-01-03 19:21:59 -07:00
parent 47cbe4fd33
commit 0e29b7a305

View file

@ -14,8 +14,8 @@ namespace TShockAPI.LuaSystem
public string LuaPath = "";
public string LuaAutorunPath = "";
public Dictionary<string, KeyValuePair<string, string>> Hooks = new Dictionary
<string, KeyValuePair<string, string>>();
public Dictionary<string, KeyValuePair<string, LuaFunction>> Hooks = new Dictionary
<string, KeyValuePair<string, LuaFunction>>();
public LuaLoader(string path)
{
Lua = new Lua();
@ -96,10 +96,10 @@ namespace TShockAPI.LuaSystem
Console.WriteLine("Running hook test.");
foreach (KeyValuePair<string, KeyValuePair<string, string>> kv in Hooks)
foreach (KeyValuePair<string, KeyValuePair<string, LuaFunction>> kv in Hooks)
{
KeyValuePair<string, string> hook = kv.Value;
LuaFunction lf = FindLuaFunction(hook.Value);
KeyValuePair<string, LuaFunction> 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<string, string> hhook = new KeyValuePair<string, string>(hook, callback);
TShock.LuaLoader.Hooks.Add(key, hhook);
KeyValuePair<string, LuaFunction> internalhook = new KeyValuePair<string, LuaFunction>(hook, callback);
TShock.LuaLoader.Hooks.Add(key, internalhook);
}
}
}