diff --git a/src/BizHawk.Client.Common/lua/INamedLuaFunction.cs b/src/BizHawk.Client.Common/lua/INamedLuaFunction.cs index 1d38ee67f9..618af4adfd 100644 --- a/src/BizHawk.Client.Common/lua/INamedLuaFunction.cs +++ b/src/BizHawk.Client.Common/lua/INamedLuaFunction.cs @@ -6,7 +6,7 @@ namespace BizHawk.Client.Common { public interface INamedLuaFunction { - Action InputCallback { get; } + Action Callback { get; } Guid Guid { get; } diff --git a/src/BizHawk.Client.Common/lua/LuaFunctionList.cs b/src/BizHawk.Client.Common/lua/LuaFunctionList.cs index d5b9bc8a1c..e294182b31 100644 --- a/src/BizHawk.Client.Common/lua/LuaFunctionList.cs +++ b/src/BizHawk.Client.Common/lua/LuaFunctionList.cs @@ -28,7 +28,7 @@ namespace BizHawk.Client.Common { if (emulator.InputCallbacksAvailable()) { - emulator.AsInputPollable().InputCallbacks.Remove(function.InputCallback); + emulator.AsInputPollable().InputCallbacks.Remove(function.Callback); } if (emulator.MemoryCallbacksAvailable()) @@ -64,7 +64,7 @@ namespace BizHawk.Client.Common { if (emulator.InputCallbacksAvailable()) { - emulator.AsInputPollable().InputCallbacks.RemoveAll(_functions.Select(w => w.InputCallback)); + emulator.AsInputPollable().InputCallbacks.RemoveAll(_functions.Select(w => w.Callback)); } if (emulator.MemoryCallbacksAvailable()) diff --git a/src/BizHawk.Client.Common/lua/LuaHelperLibs/EventsLuaLibrary.cs b/src/BizHawk.Client.Common/lua/LuaHelperLibs/EventsLuaLibrary.cs index 148971d604..0e767d09d3 100644 --- a/src/BizHawk.Client.Common/lua/LuaHelperLibs/EventsLuaLibrary.cs +++ b/src/BizHawk.Client.Common/lua/LuaHelperLibs/EventsLuaLibrary.cs @@ -44,10 +44,6 @@ namespace BizHawk.Client.Common Log($"{scope} is not an available scope for {Emulator.Attributes().CoreName}"); } - [LuaMethod("can_use_callback_params", "Returns true. Check this function exists to decide whether to use hacks for older versions w/o parameter support.")] - [LuaMethodExample("local mem_callback = event.can_use_callback_params ~= nil and mem_callback or mem_callback_pre_28;")] - public bool CanUseCallbackParams() - => true; [LuaMethodExample("local steveonf = event.onframeend(\r\n\tfunction()\r\n\t\tconsole.log( \"Calls the given lua function at the end of each frame, after all emulation and drawing has completed. Note: this is the default behavior of lua scripts\" );\r\n\tend\r\n\t, \"Frame name\" );")] [LuaMethod("onframeend", "Calls the given lua function at the end of each frame, after all emulation and drawing has completed. Note: this is the default behavior of lua scripts")] @@ -72,7 +68,7 @@ namespace BizHawk.Client.Common { try { - InputPollableCore.InputCallbacks.Add(nlf.InputCallback); + InputPollableCore.InputCallbacks.Add(nlf.Callback); return nlf.Guid.ToString(); } catch (NotImplementedException) diff --git a/src/BizHawk.Client.Common/lua/NamedLuaFunction.cs b/src/BizHawk.Client.Common/lua/NamedLuaFunction.cs index 9ad566c7f4..2b676dfaaf 100644 --- a/src/BizHawk.Client.Common/lua/NamedLuaFunction.cs +++ b/src/BizHawk.Client.Common/lua/NamedLuaFunction.cs @@ -32,19 +32,19 @@ namespace BizHawk.Client.Common Guid = Guid.NewGuid(); - Callback = args => + Callback = () => { try { - _function.Call(args); + _function.Call(); } catch (Exception ex) { logCallback($"error running function attached by the event {Event}\nError message: {ex.Message}"); } }; - InputCallback = () => Callback(Array.Empty()); - MemCallback = (addr, val, flags) => Callback(new object[] { addr, val, flags }); + + MemCallback = (address, value, flags) => Callback(); } public void DetachFromScript() @@ -66,9 +66,7 @@ namespace BizHawk.Client.Common public string Event { get; } - private Action Callback { get; } - - public Action InputCallback { get; } + public Action Callback { get; } public MemoryCallbackDelegate MemCallback { get; }