Lua - start an Event library and implement event.onloadstate(), event.onsavestate(), event.onframestart(), event.onframeend, event.oninputpoll(), All of these are aliases of other functions

This commit is contained in:
adelikat 2012-10-12 20:19:26 +00:00
parent 37a916f779
commit b65064eb13
1 changed files with 43 additions and 0 deletions

View File

@ -212,6 +212,13 @@ namespace BizHawk.MultiClient
docs.Add("nes", NESFunctions[i], this.GetType().GetMethod("nes_" + NESFunctions[i]));
}
lua.NewTable("event");
for (int i = 0; i < EventFunctions.Length; i++)
{
lua.RegisterFunction("event." + EventFunctions[i], this, this.GetType().GetMethod("event_" + EventFunctions[i]));
docs.Add("event", EventFunctions[i], this.GetType().GetMethod("event_" + EventFunctions[i]));
}
docs.Sort();
}
@ -556,6 +563,17 @@ namespace BizHawk.MultiClient
"addgamegenie",
"removegamegenie",
};
public static string[] EventFunctions = new string[]
{
"onloadstate",
"onsavestate",
"onframestart",
"onframeend",
//"onmemoryread",
//"onmemorywrite",
"oninputpoll",
};
/****************************************************/
/*************function definitions********************/
/****************************************************/
@ -2652,5 +2670,30 @@ namespace BizHawk.MultiClient
}
}
}
public void event_onsavestate(LuaFunction luaf)
{
savestate_registersave(luaf);
}
public void event_onloadstate(LuaFunction luaf)
{
savestate_registerload(luaf);
}
public void event_onframestart(LuaFunction luaf)
{
emu_registerbefore(luaf);
}
public void event_onframeend(LuaFunction luaf)
{
emu_registerafter(luaf);
}
public void event_oninputpoll(LuaFunction luaf)
{
emu_on_snoop(luaf);
}
}
}