Lua - implement joypad.setfrommnemonicstr()

This commit is contained in:
adelikat 2014-05-18 22:54:41 +00:00
parent d2bc1b89a3
commit b2feb39c11
1 changed files with 20 additions and 0 deletions

View File

@ -67,6 +67,26 @@ namespace BizHawk.Client.Common
return buttons;
}
[LuaMethodAttributes(
"setfrommnemonicstr",
"sets the given buttons to their provided values for the current frame, string will be interpretted the same way an entry from a movie input log would be"
)]
public void SetFromMnemonicStr(string inputLogEntry)
{
var m = new MovieControllerAdapter { Type = Global.MovieSession.MovieControllerAdapter.Type };
m.SetControllersAsMnemonic(inputLogEntry);
foreach (var button in m.Type.BoolButtons)
{
Global.LuaAndAdaptor.SetButton(button, m.IsPressed(button));
}
foreach (var floatButton in m.Type.FloatControls)
{
Global.StickyXORAdapter.SetFloat(floatButton, m.GetFloat(floatButton));
}
}
[LuaMethodAttributes(
"set",
"sets the given buttons to their provided values for the current frame"