BizHawk icon indicating copy to clipboard operation
BizHawk copied to clipboard

Lua Functions: On Copy of a Row Remove C Style Comment / Maybe Change Parameter Name in Ex

Open ShinobiWannabe opened this issue 5 years ago • 1 comments

In the Lua Functions grid if you right-click and copy the row to get a quick example it is copied in a format that is not completely compatible with Lua. "//" should be replaced with "--" otherwise a user gets NLua.Exceptions.LuaScriptException: [string "main"]:51: unexpected symbol near '/'.

A couple other things I have to question. The "Frame name" is the event name if you want to use that function name to remove, but the name should most likely be "Event Name" in these examples. local "steveonm" seems an odd variable name as well to me for something would contain a GUID for an event in case you wanted to identify it later such as for removal later with the event unregisterbyid.

image

//event.onmemoryexecute(nluafunc luaf, uint  address, [string name = null], [string scope = null])
local steveonm = event.onmemoryexecute(
	function()
		console.log( "Fires after the given address is executed by the core" );
	end
	, 0x200, "Frame name", "System Bus" );

--another example of a copy below

//event.onsavestate(nluafunc luaf, [string name = null])
local steveons = event.onsavestate(
	function()
		console.log( "Fires after a state is saved" );
	end
	, "Frame name" );

ShinobiWannabe avatar Dec 12 '20 19:12 ShinobiWannabe

:shrug:

https://github.com/TASEmulators/BizHawk/blob/93ebbc60d66b4f6540160a007cf1ba57aa2f5bd8/src/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs#L131

nattthebear avatar Dec 12 '20 20:12 nattthebear