View Page Source

Revision (current)
Last Updated by nymx on 1/1/2024 6:59 PM
Back to Page


__This is an autogenerated page, do not edit.__ (To update, open the function list dialog on a Debug build and click the wiki button.)

This page documents the the behavior and parameters of Lua functions available for the [BizHawk] emulator. The function list is also available from within EmuHawk. From the Lua Console, click Help > Lua Functions List or press F1.

As you might expect, Lua scripts execute top to bottom once, so to run something every frame you'll need to end the script with an infinite loop (or you could set a callback on one of the events instead). Make sure to call {{emu.frameadvance}} or {{emu.yield}} in the loop or your script will hang EmuHawk and then crash!

Lua supports integer arithmetic starting with BizHawk 2.9. Note {{~}} is both bitwise NOT and XOR. Some of the {{bit}} helper functions remain, but you should try to avoid them if you need performance (or [https://github.com/TASEmulators/BizHawk-ExternalTools/wiki|switch to .NET]). If you're getting overwhelmed with deprecation warnings while trying to migrate a script, add this one-liner at the top: {{bit = (require "migration_helpers").EmuHawk_pre_2_9_bit();}}

FCEUX users: While this API surface may look similar, even functions with the same name may take different arguments, or behave differently in a way that isn't immediately obvious. (TODO: create a migration helper function for FCEUX)

__Types and notation__
* [[]] (brackets)
** Brackets around a parameter indicate that the parameter is optional. Optional parameters have an equals sign followed by the value that will be used if no value is supplied.
** Brackets after a parameter type indicate it is an array
* ? (question mark)
** A question mark next to a value indicates that it is nullable i.e. null/nil may be passed instead of a real value. (Confusingly, many .NET types are nullable but omit the '?'. These aren't common in our Lua APIs.)
* null/nil
** null is equivalent to Lua's nil.
** Omitting the last parameter is equivalent to passing nil, same with the second-last parameter and so on. However, if you want to pass the last parameter but not one in the middle, you will need to explicitly pass nil.
* object
** A System.Object; any table or value may be passed, including nil.
** Usually you can infer what kinds of values would be useful to pass from the descriptions and examples.
* luacolor
** Any of:
** a 32-bit number in the format 0xAARRGGBB;
** a string in the format "#RRGGBB" or "#AARRGGBB";
** a string containing a CSS3/X11 color name e.g. "blue", "palegoldenrod"; or
** a Color created with forms.createcolor.
** As noted above, luacolor? indicates nil may also be passed.
* nluafunc
** A Lua function. Note that these are always parameters, and never return values of a call.
** Some callbacks will be called with arguments, if the function you register has the right number of parameters. This will be noted in the registration function's docs.
* table
** A standard Lua table
* something else
** check the .NET documentation on MSDN

__Common parameter meanings__
* {{ulong addr}}/{{long addr}}/{{uint addr}}/{{int addr}} in memory functions
** Relative to the specified domain (or the "current" domain, see below).
** Some memory events allow {{nil}} for the address. That will hook on all addresses.
* {{string domain}} in memory functions
** The name of a memory domain. The list of valid domains is returned by {{memory.getmemorydomainlist}}, or can be seen in various tools such as the Hex Editor.
** If {{domain}} is optional (i.e. the function has {{nil}} as the default argument) and you pass {{nil}} or omit the argument, the "current" domain is used. This can be set/gotten with {{memory.usememorydomain}}/{{memory.getcurrentmemorydomain}}.
* {{string scope}} in memory functions
** The name of a scope. The list of valid scopes is returned by {{event.availableScopes}}.
* {{int frame}} in {{movie}}/{{tastudio}} functions and others
** Frame index i.e. the number of VBlanks that have been seen. While many EmuHawk features use this concept, note that most take effect ''after'' a certain frame, but some, such as memory freezes and polling/inputs, take effect ''during'' a frame.
* {{int? controller}}/{{int? player}} in (virtual) input functions
** Player index, as seen in {{Config}} > {{Controllers...}} (starts at 1).
** If you pass {{nil}} or omit the argument, this will either indicate all players, or "no player" i.e. buttons on the Console. See the relevant function's documentation.
* {{luacolor line}}/{{luacolor background}} in drawing functions
** {{line}} is the "stroke" or "outline" color, {{background}} is the "fill" color. Both can have transparency.
* {{string surfacename}} in {{gui}} drawing functions
** Either {{"emucore"}} or {{"client"}}.
** If you pass {{nil}} or omit the argument, the "current" surface is used. This can be set with {{gui.use_surface}}.
* other {{string}} parameters in drawing functions
** See the relevant function's documentation.
* {{long handle}} in forms functions
** These handles are returned by {{forms.newform}} and the various control creation functions such as {{forms.checkbox}}. Do not attempt to re-use them across script restarts or do arithmetic with them.
* {{string guid}}/{{string name}} in event functions
** The ''name'' of a callback is an optional parameter in all the event subscription functions. The ''ID'' of a callback is what's returned by the subscription function. Multiple callbacks can share the same name, but IDs are unique.

%%TAB bit%%

A library for performing standard bitwise operations.

__bit.arshift__%%%

* int bit.arshift(uint  val, int amt)

* Arithmetic shift right of 'val' by 'amt' bits

__bit.band__%%%

* __[[deprecated]]__ uint bit.band(uint  val, uint  amt)

* Bitwise AND of 'val' against 'amt'

__bit.bnot__%%%

* __[[deprecated]]__ uint bit.bnot(uint  val)

* Bitwise NOT of 'val'

__bit.bor__%%%

* __[[deprecated]]__ uint bit.bor(uint  val, uint  amt)

* Bitwise OR of 'val' against 'amt'

__bit.bxor__%%%

* __[[deprecated]]__ uint bit.bxor(uint  val, uint  amt)

* Bitwise XOR of 'val' against 'amt'

__bit.byteswap_16__%%%

* ushort bit.byteswap_16(ushort  val)

* Byte swaps 'short', i.e. bit.byteswap_16(0xFF00) would return 0x00FF

__bit.byteswap_32__%%%

* uint bit.byteswap_32(uint  val)

* Byte swaps 'dword'

__bit.byteswap_64__%%%

* ulong bit.byteswap_64(ulong  val)

* Byte swaps 'long'

__bit.check__%%%

* bool bit.check(long num, int pos)

* Returns result of bit 'pos' being set in 'num'

__bit.clear__%%%

* long bit.clear(uint  num, int pos)

* Clears the bit 'pos' in 'num'

__bit.lshift__%%%

* __[[deprecated]]__ uint bit.lshift(uint  val, int amt)

* Logical shift left of 'val' by 'amt' bits

__bit.rol__%%%

* uint bit.rol(uint  val, int amt)

* Left rotate 'val' by 'amt' bits

__bit.ror__%%%

* uint bit.ror(uint  val, int amt)

* Right rotate 'val' by 'amt' bits

__bit.rshift__%%%

* __[[deprecated]]__ uint bit.rshift(uint  val, int amt)

* Logical shift right of 'val' by 'amt' bits

__bit.set__%%%

* uint bit.set(uint  num, int pos)

* Sets the bit 'pos' in 'num'

%%TAB bizstring%%

A library exposing standard .NET string methods

__bizstring.binary__%%%

* string bizstring.binary(long num)

* Converts the number to a string representation of the binary value of the given number

__bizstring.contains__%%%

* bool bizstring.contains(string str, string str2)

* Returns whether or not str contains str2

__bizstring.endswith__%%%

* bool bizstring.endswith(string str, string str2)

* Returns whether str ends wth str2

__bizstring.hex__%%%

* string bizstring.hex(long num)

* Converts the number to a string representation of the hexadecimal value of the given number

__bizstring.octal__%%%

* string bizstring.octal(long num)

* Converts the number to a string representation of the octal value of the given number

__bizstring.pad_end__%%%

* string bizstring.pad_end(string str, int length, string pad_char)

* Appends zero or more of pad_char to the end (right) of str until it's at least length chars long. If pad_char is not a string exactly one char long, its first char will be used, or ' ' if it's empty.

__bizstring.pad_start__%%%

* string bizstring.pad_start(string str, int length, string pad_char)

* Prepends zero or more of pad_char to the start (left) of str until it's at least length chars long. If pad_char is not a string exactly one char long, its first char will be used, or ' ' if it's empty.

__bizstring.remove__%%%

* string bizstring.remove(string str, int position, int count)

* Returns a string that represents str with the given position and count removed

__bizstring.replace__%%%

* string bizstring.replace(string str, string str2, string replace)

* Returns a string that replaces all occurrences of str2 in str1 with the value of replace

__bizstring.split__%%%

* nluatable bizstring.split(string str, string separator)

* Splits str into a Lua-style array using the given separator (consecutive separators in str will NOT create empty entries in the array). If the separator is not a string exactly one char long, ',' will be used.

__bizstring.startswith__%%%

* bool bizstring.startswith(string str, string str2)

* Returns whether str starts with str2

__bizstring.substring__%%%

* string bizstring.substring(string str, int position, int length)

* Returns a string that represents a substring of str starting at position for the specified length

__bizstring.tolower__%%%

* string bizstring.tolower(string str)

* Returns an lowercase version of the given string

__bizstring.toupper__%%%

* string bizstring.toupper(string str)

* Returns an uppercase version of the given string

__bizstring.trim__%%%

* string bizstring.trim(string str)

* returns a string that trims whitespace on the left and right ends of the string

%%TAB client%%

A library for manipulating the EmuHawk client UI

__client.addcheat__%%%

* void client.addcheat(string code)

* adds a cheat code, if supported

__client.borderheight__%%%

* int client.borderheight()

* Gets the current height in pixels of the letter/pillarbox area (top side only) around the emu display surface, excluding the gameExtraPadding you've set. This function (the whole lot of them) should be renamed or refactored since the padding areas have got more complex.

__client.borderwidth__%%%

* int client.borderwidth()

* Gets the current width in pixels of the letter/pillarbox area (left side only) around the emu display surface, excluding the gameExtraPadding you've set. This function (the whole lot of them) should be renamed or refactored since the padding areas have got more complex.

__client.bufferheight__%%%

* int client.bufferheight()

* Gets the visible height of the emu display surface (the core video output). This excludes the gameExtraPadding you've set.

__client.bufferwidth__%%%

* int client.bufferwidth()

* Gets the visible width of the emu display surface (the core video output). This excludes the gameExtraPadding you've set.

__client.clearautohold__%%%

* void client.clearautohold()

* Clears all autohold keys

__client.closerom__%%%

* void client.closerom()

* Closes the loaded Rom

__client.createinstance__%%%

* nluatable client.createinstance(string name)

* returns a default instance of the given type of object if it exists (not case sensitive). Note: This will only work on objects which have a parameterless constructor.  If no suitable type is found, or the type does not have a parameterless constructor, then nil is returned

__client.displaymessages__%%%

* void client.displaymessages(bool value)

* sets whether or not on screen messages will display

__client.enablerewind__%%%

* void client.enablerewind(bool enabled)

* Sets whether or not the rewind feature is enabled

__client.exactsleep__%%%

* void client.exactsleep(int millis)

* sleeps exactly for n milliseconds

__client.exit__%%%

* void client.exit()

* Closes the emulator

__client.exitCode__%%%

* void client.exitCode(int exitcode)

* Closes the emulator and returns the provided code

__client.frameskip__%%%

* void client.frameskip(int numframes)

* Sets the frame skip value of the client UI (use 0 to disable)

__client.get_approx_framerate__%%%

* int client.get_approx_framerate()

* Gets the (host) framerate, approximated from frame durations.

__client.get_lua_engine__%%%

* string client.get_lua_engine()

* returns the name of the Lua engine currently in use

__client.getavailabletools__%%%

* nluatable client.getavailabletools()

* Returns a list of the tools currently open

__client.getconfig__%%%

* object client.getconfig()

* gets the current config settings object

__client.GetSoundOn__%%%

* bool client.GetSoundOn()

* Gets the state of the Sound On toggle

__client.gettargetscanlineintensity__%%%

* int client.gettargetscanlineintensity()

* Gets the current scanline intensity setting, used for the scanline display filter

__client.gettool__%%%

* nluatable client.gettool(string name)

* Returns an object that represents a tool of the given name (not case sensitive). If the tool is not open, it will be loaded if available. Use getavailabletools to get a list of names

__client.getversion__%%%

* string client.getversion()

* Returns the current stable BizHawk version

__client.getwindowsize__%%%

* int client.getwindowsize()

* Gets the main window's size Possible values are 1, 2, 3, 4, 5, and 10

__client.invisibleemulation__%%%

* void client.invisibleemulation(bool invisible)

* Disables and enables emulator updates

__client.ispaused__%%%

* bool client.ispaused()

* Returns true if emulator is paused, otherwise, false

__client.isseeking__%%%

* bool client.isseeking()

* Returns true if emulator is seeking, otherwise, false

__client.isturbo__%%%

* bool client.isturbo()

* Returns true if emulator is in turbo mode, otherwise, false

__client.opencheats__%%%

* void client.opencheats()

* opens the Cheats dialog

__client.openhexeditor__%%%

* void client.openhexeditor()

* opens the Hex Editor dialog

__client.openramsearch__%%%

* void client.openramsearch()

* opens the RAM Search dialog

__client.openramwatch__%%%

* void client.openramwatch()

* opens the RAM Watch dialog

__client.openrom__%%%

* bool client.openrom(string path)

* Loads a ROM from the given path. Returns true if the ROM was successfully loaded, otherwise false.

__client.opentasstudio__%%%

* void client.opentasstudio()

* opens the TAStudio dialog

__client.opentoolbox__%%%

* void client.opentoolbox()

* opens the Toolbox Dialog

__client.opentracelogger__%%%

* void client.opentracelogger()

* opens the tracelogger if it is available for the given core

__client.pause__%%%

* void client.pause()

* Pauses the emulator

__client.pause_av__%%%

* void client.pause_av()

* If currently capturing Audio/Video, this will suspend the record. Frames will not be captured into the AV until client.unpause_av() is called

__client.reboot_core__%%%

* void client.reboot_core()

* Reboots the currently loaded core

__client.removecheat__%%%

* void client.removecheat(string code)

* removes a cheat, if it already exists

__client.saveram__%%%

* void client.saveram()

* flushes save ram to disk

__client.screenheight__%%%

* int client.screenheight()

* Gets the current height in pixels of the emulator's drawing area

__client.screenshot__%%%

* void client.screenshot([[string path = nil]])

* if a parameter is passed it will function as the Screenshot As menu item of EmuHawk, else it will function as the Screenshot menu item

__client.screenshottoclipboard__%%%

* void client.screenshottoclipboard()

* Performs the same function as EmuHawk's Screenshot To Clipboard menu item

__client.screenwidth__%%%

* int client.screenwidth()

* Gets the current width in pixels of the emulator's drawing area

__client.seekframe__%%%

* void client.seekframe(int frame)

* Makes the emulator seek to the frame specified

__client.SetClientExtraPadding__%%%

* void client.SetClientExtraPadding(int left, int top, int right, int bottom)

* Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements

__client.SetGameExtraPadding__%%%

* void client.SetGameExtraPadding(int left, int top, int right, int bottom)

* Sets the extra padding added to the 'emu' surface so that you can draw HUD elements in predictable placements

__client.setscreenshotosd__%%%

* void client.setscreenshotosd(bool value)

* Sets the screenshot Capture OSD property of the client

__client.SetSoundOn__%%%

* void client.SetSoundOn(bool enable)

* Sets the state of the Sound On toggle

__client.settargetscanlineintensity__%%%

* void client.settargetscanlineintensity(int val)

* Sets the current scanline intensity setting, used for the scanline display filter

__client.setwindowsize__%%%

* void client.setwindowsize(int size)

* Sets the main window's size to the give value. Accepted values are 1, 2, 3, 4, 5, and 10

__client.sleep__%%%

* void client.sleep(int millis)

* sleeps for n milliseconds

__client.speedmode__%%%

* void client.speedmode(int percent)

* Sets the speed of the emulator (in terms of percent)

__client.togglepause__%%%

* void client.togglepause()

* Toggles the current pause state

__client.transformPoint__%%%

* nluatable client.transformPoint(int x, int y)

* Transforms a point (x, y) in emulator space to a point in client space

__client.unpause__%%%

* void client.unpause()

* Unpauses the emulator

__client.unpause_av__%%%

* void client.unpause_av()

* If currently capturing Audio/Video this resumes capturing

__client.xpos__%%%

* int client.xpos()

* Returns the x value of the screen position where the client currently sits

__client.ypos__%%%

* int client.ypos()

* Returns the y value of the screen position where the client currently sits

%%TAB comm%%

A library for communicating with other programs

__comm.getluafunctionslist__%%%

* string comm.getluafunctionslist()

* returns a list of implemented functions

__comm.httpGet__%%%

* string comm.httpGet(string url)

* makes a HTTP GET request

__comm.httpGetGetUrl__%%%

* string comm.httpGetGetUrl()

* Gets HTTP GET URL

__comm.httpGetPostUrl__%%%

* string comm.httpGetPostUrl()

* Gets HTTP POST URL

__comm.httpPost__%%%

* string comm.httpPost(string url, string payload)

* makes a HTTP POST request

__comm.httpPostScreenshot__%%%

* string comm.httpPostScreenshot()

* HTTP POST screenshot

__comm.httpSetGetUrl__%%%

* void comm.httpSetGetUrl(string url)

* Sets HTTP GET URL

__comm.httpSetPostUrl__%%%

* void comm.httpSetPostUrl(string url)

* Sets HTTP POST URL

__comm.httpSetTimeout__%%%

* void comm.httpSetTimeout(int timeout)

* Sets HTTP timeout in milliseconds

__comm.httpTest__%%%

* string comm.httpTest()

* tests HTTP connections

__comm.httpTestGet__%%%

* string comm.httpTestGet()

* tests the HTTP GET connection

__comm.mmfCopyFromMemory__%%%

* int comm.mmfCopyFromMemory(string mmf_filename, long addr, int length, string domain)

* Copy a section of the memory to a memory mapped file

__comm.mmfCopyToMemory__%%%

* void comm.mmfCopyToMemory(string mmf_filename, long addr, int length, string domain)

* Copy a memory mapped file to a section of the memory

__comm.mmfGetFilename__%%%

* string comm.mmfGetFilename()

* Gets the filename for the screenshots

__comm.mmfRead__%%%

* string comm.mmfRead(string mmf_filename, int expectedsize)

* Reads a string from a memory mapped file

__comm.mmfReadBytes__%%%

* nluatable comm.mmfReadBytes(string mmf_filename, int expectedsize)

* Reads bytes from a memory mapped file

__comm.mmfScreenshot__%%%

* int comm.mmfScreenshot()

* Saves screenshot to memory mapped file

__comm.mmfSetFilename__%%%

* void comm.mmfSetFilename(string filename)

* Sets the filename for the screenshots

__comm.mmfWrite__%%%

* int comm.mmfWrite(string mmf_filename, string outputstring )

* Writes a string to a memory mapped file

__comm.mmfWriteBytes__%%%

* int comm.mmfWriteBytes(string mmf_filename, nluatable bytearray)

* Write bytes to a memory mapped file

__comm.socketServerGetInfo__%%%

* string comm.socketServerGetInfo()

* returns the IP and port of the Lua socket server

__comm.socketServerGetIp__%%%

* string comm.socketServerGetIp()

* returns the IP address of the Lua socket server

__comm.socketServerGetPort__%%%

* int? comm.socketServerGetPort()

* returns the port of the Lua socket server

__comm.socketServerIsConnected__%%%

* bool comm.socketServerIsConnected()

* socketServerIsConnected

__comm.socketServerResponse__%%%

* string comm.socketServerResponse()

* Receives a message from the Socket server. Since BizHawk 2.6.2, all responses must be of the form $"{msg.Length:D} {msg}" i.e. prefixed with the length in base-10 and a space.

__comm.socketServerScreenShot__%%%

* string comm.socketServerScreenShot()

* sends a screenshot to the Socket server

__comm.socketServerScreenShotResponse__%%%

* string comm.socketServerScreenShotResponse()

* sends a screenshot to the Socket server and retrieves the response

__comm.socketServerSend__%%%

* int comm.socketServerSend(string sendstring )

* sends a string to the Socket server

__comm.socketServerSendBytes__%%%

* int comm.socketServerSendBytes(nluatable bytearray)

* sends bytes to the Socket server

__comm.socketServerSetIp__%%%

* void comm.socketServerSetIp(string ip)

* sets the IP address of the Lua socket server

__comm.socketServerSetPort__%%%

* void comm.socketServerSetPort(int port)

* sets the port of the Lua socket server

__comm.socketServerSetTimeout__%%%

* void comm.socketServerSetTimeout(int timeout)

* sets the timeout in milliseconds for receiving messages

__comm.socketServerSuccessful__%%%

* bool comm.socketServerSuccessful()

* returns the status of the last Socket server action

%%TAB console%%

__console.clear__%%%

* void console.clear()

* clears the output box of the Lua Console window

__console.getluafunctionslist__%%%

* string console.getluafunctionslist()

* returns a list of implemented functions

__console.log__%%%

* void console.log(object[[]] outputs)

* Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable

__console.write__%%%

* void console.write(object[[]] outputs)

* Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable

__console.writeline__%%%

* void console.writeline(object[[]] outputs)

* Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable

%%TAB emu%%

A library for interacting with the currently loaded emulator core

__emu.disassemble__%%%

* nluatable emu.disassemble(uint  pc, [[string name = ]])

* Returns the disassembly object (disasm string and length int) for the given PC address. Uses System Bus domain if no domain name provided

__emu.displayvsync__%%%

* void emu.displayvsync(bool enabled)

* Sets the display vsync property of the emulator

__emu.frameadvance__%%%

* void emu.frameadvance()

* Signals to the emulator to resume emulation. Necessary for any lua script while loop or else the emulator will freeze!

__emu.framecount__%%%

* int emu.framecount()

* Returns the current frame count

__emu.getboardname__%%%

* string emu.getboardname()

* returns (if available) the board name of the loaded ROM

__emu.getdisplaytype__%%%

* string emu.getdisplaytype()

* returns the display type (PAL vs NTSC) that the emulator is currently running in

__emu.getluacore__%%%

* __[[deprecated]]__ string emu.getluacore()

* returns the name of the Lua core currently in use

__emu.getregister__%%%

* int emu.getregister(string name)

* returns the value of a cpu register or flag specified by name. For a complete list of possible registers or flags for a given core, use getregisters

__emu.getregisters__%%%

* nluatable emu.getregisters()

* returns the complete set of available flags and registers for a given core

__emu.getsystemid__%%%

* string emu.getsystemid()

* Returns the ID string of the current core loaded. Note: No ROM loaded will return the string NULL

__emu.islagged__%%%

* bool emu.islagged()

* Returns whether or not the current frame is a lag frame

__emu.lagcount__%%%

* int emu.lagcount()

* Returns the current lag count

__emu.limitframerate__%%%

* void emu.limitframerate(bool enabled)

* sets the limit framerate property of the emulator

__emu.minimizeframeskip__%%%

* void emu.minimizeframeskip(bool enabled)

* Sets the autominimizeframeskip value of the emulator

__emu.setislagged__%%%

* void emu.setislagged([[bool value = True]])

* Sets the lag flag for the current frame. If no value is provided, it will default to true

__emu.setlagcount__%%%

* void emu.setlagcount(int count)

* Sets the current lag count

__emu.setregister__%%%

* void emu.setregister(string register, int value)

* sets the given register name to the given value

__emu.setrenderplanes__%%%

* void emu.setrenderplanes(bool[[]] luaparam)

* Toggles the drawing of sprites and background planes. Set to false or nil to disable a pane, anything else will draw them

__emu.totalexecutedcycles__%%%

* long emu.totalexecutedcycles()

* gets the total number of executed cpu cycles

__emu.yield__%%%

* void emu.yield()

* allows a script to run while emulation is paused and interact with the gui/main window in realtime 

%%TAB event%%

A library for registering lua functions to emulator events.
 All events support multiple registered methods.
All registered event methods can be named and return a Guid when registered

__event.availableScopes__%%%

* nluatable event.availableScopes()

* Lists the available scopes that can be specified for on_bus_* events

__event.can_use_callback_params__%%%

* bool event.can_use_callback_params([[string subset = nil]])

* Returns whether EmuHawk will pass arguments to callbacks. The current version passes arguments to "memory" callbacks (RAM/ROM/bus R/W), so this function will return true for that input. (It returns false for any other input.) This tells you whether it's necessary to enable workarounds/hacks because a script is running in a version without parameter support.

__event.on_bus_exec__%%%

* string event.on_bus_exec(nluafunc luaf, uint  address, [[string name = nil]], [[string scope = nil]])

* Fires immediately before the given address is executed by the core. Your callback can have 3 parameters {{(addr, val, flags)}}. {{val}} is the value to be executed (or {{0}} always, if this feature is only partially implemented).

__event.on_bus_exec_any__%%%

* string event.on_bus_exec_any(nluafunc luaf, [[string name = nil]], [[string scope = nil]])

* Fires immediately before every instruction executed (in the specified scope) by the core (CPU-intensive). Your callback can have 3 parameters {{(addr, val, flags)}}. {{val}} is the value to be executed (or {{0}} always, if this feature is only partially implemented).

__event.on_bus_read__%%%

* string event.on_bus_read(nluafunc luaf, [[uint? address = nil]], [[string name = nil]], [[string scope = nil]])

* Fires immediately before the given address is read by the core. Your callback can have 3 parameters {{(addr, val, flags)}}. {{val}} is the value read. If no address is given, it will fire on every memory read.

__event.on_bus_write__%%%

* string event.on_bus_write(nluafunc luaf, [[uint? address = nil]], [[string name = nil]], [[string scope = nil]])

* Fires immediately before the given address is written by the core. Your callback can have 3 parameters {{(addr, val, flags)}}. {{val}} is the value to be written (or {{0}} always, if this feature is only partially implemented). If no address is given, it will fire on every memory write.

__event.onconsoleclose__%%%

* string event.onconsoleclose(nluafunc luaf, [[string name = nil]])

* Fires when the emulator console closes

__event.onexit__%%%

* string event.onexit(nluafunc luaf, [[string name = nil]])

* Fires after the calling script has stopped

__event.onframeend__%%%

* string event.onframeend(nluafunc luaf, [[string name = nil]])

* 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

__event.onframestart__%%%

* string event.onframestart(nluafunc luaf, [[string name = nil]])

* Calls the given lua function at the beginning of each frame before any emulation and drawing occurs

__event.oninputpoll__%%%

* string event.oninputpoll(nluafunc luaf, [[string name = nil]])

* Calls the given lua function after each time the emulator core polls for input

__event.onloadstate__%%%

* string event.onloadstate(nluafunc luaf, [[string name = nil]])

* Fires after a state is loaded. Your callback can have 1 parameter, which will be the name of the loaded state.

__event.onmemoryexecute__%%%

* __[[deprecated]]__ string event.onmemoryexecute(nluafunc luaf, uint  address, [[string name = nil]], [[string scope = nil]])

* Fires immediately before the given address is executed by the core. Your callback can have 3 parameters {{(addr, val, flags)}}. {{val}} is the value to be executed (or {{0}} always, if this feature is only partially implemented).

__event.onmemoryexecuteany__%%%

* __[[deprecated]]__ string event.onmemoryexecuteany(nluafunc luaf, [[string name = nil]], [[string scope = nil]])

* Fires immediately before every instruction executed (in the specified scope) by the core (CPU-intensive). Your callback can have 3 parameters {{(addr, val, flags)}}. {{val}} is the value to be executed (or {{0}} always, if this feature is only partially implemented).

__event.onmemoryread__%%%

* __[[deprecated]]__ string event.onmemoryread(nluafunc luaf, [[uint? address = nil]], [[string name = nil]], [[string scope = nil]])

* Fires immediately before the given address is read by the core. Your callback can have 3 parameters {{(addr, val, flags)}}. {{val}} is the value read. If no address is given, it will fire on every memory read.

__event.onmemorywrite__%%%

* __[[deprecated]]__ string event.onmemorywrite(nluafunc luaf, [[uint? address = nil]], [[string name = nil]], [[string scope = nil]])

* Fires immediately before the given address is written by the core. Your callback can have 3 parameters {{(addr, val, flags)}}. {{val}} is the value to be written (or {{0}} always, if this feature is only partially implemented). If no address is given, it will fire on every memory write.

__event.onsavestate__%%%

* string event.onsavestate(nluafunc luaf, [[string name = nil]])

* Fires after a state is saved. Your callback can have 1 parameter, which will be the name of the saved state.

__event.unregisterbyid__%%%

* bool event.unregisterbyid(string guid)

* Removes the registered function that matches the guid. If a function is found and remove the function will return true. If unable to find a match, the function will return false.

__event.unregisterbyname__%%%

* bool event.unregisterbyname(string name)

* Removes the first registered function that matches Name. If a function is found and remove the function will return true. If unable to find a match, the function will return false.

%%TAB forms%%

A library for creating and managing custom dialogs

__forms.addclick__%%%

* void forms.addclick(long handle, nluafunc clickevent)

* adds the given lua function as a click event to the given control

__forms.button__%%%

* long forms.button(long formhandle, string caption, nluafunc clickevent, [[int? x = nil]], [[int? y = nil]], [[int? width = nil]], [[int? height = nil]])

* Creates a button control on the given form. The caption property will be the text value on the button. clickEvent is the name of a Lua function that will be invoked when the button is clicked. x, and y are the optional location parameters for the position of the button within the given form. The function returns the handle of the created button. Width and Height are optional, if not specified they will be a default size

__forms.checkbox__%%%

* long forms.checkbox(long formhandle, string caption, [[int? x = nil]], [[int? y = nil]])

* Creates a checkbox control on the given form. The caption property will be the text of the checkbox. x and y are the optional location parameters for the position of the checkbox within the form

__forms.clear__%%%

* void forms.clear(long componenthandle, luacolor color)

* Clears the canvas

__forms.clearclicks__%%%

* void forms.clearclicks(long handle)

* Removes all click events from the given widget at the specified handle

__forms.clearImageCache__%%%

* void forms.clearImageCache(long componenthandle)

* clears the image cache that is built up by using gui.drawImage, also releases the file handle for cached images

__forms.createcolor__%%%

* color forms.createcolor(int r, int g, int b, int a)

* Creates a color object useful with setproperty

__forms.destroy__%%%

* bool forms.destroy(long handle)

* Closes and removes a Lua created form with the specified handle. If a dialog was found and removed true is returned, else false

__forms.destroyall__%%%

* void forms.destroyall()

* Closes and removes all Lua created dialogs

__forms.drawArc__%%%

* void forms.drawArc(long componenthandle, int x, int y, int width, int height, int startangle, int sweepangle, [[luacolor line = nil]])

* draws a Arc shape at the given coordinates and the given width and height

__forms.drawAxis__%%%

* void forms.drawAxis(long componenthandle, int x, int y, int size, [[luacolor color = nil]])

* Draws an axis of the specified size at the coordinate pair.)

__forms.drawBezier__%%%

* void forms.drawBezier(long componenthandle, nluatable points, luacolor color)

* Draws a Bezier curve using the table of coordinates provided in the given color

__forms.drawBox__%%%

* void forms.drawBox(long componenthandle, int x, int y, int x2, int y2, [[luacolor line = nil]], [[luacolor background = nil]])

* Draws a rectangle on screen from x1/y1 to x2/y2. Same as drawRectangle except it receives two points intead of a point and width/height

__forms.drawEllipse__%%%

* void forms.drawEllipse(long componenthandle, int x, int y, int width, int height, [[luacolor line = nil]], [[luacolor background = nil]])

* Draws an ellipse at the given coordinates and the given width and height. Line is the color of the ellipse. Background is the optional fill color

__forms.drawIcon__%%%

* void forms.drawIcon(long componenthandle, string path, int x, int y, [[int? width = nil]], [[int? height = nil]])

* draws an Icon (.ico) file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly

__forms.drawImage__%%%

* void forms.drawImage(long componenthandle, string path, int x, int y, [[int? width = nil]], [[int? height = nil]], [[bool cache = True]])

* draws an image file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly

__forms.drawImageRegion__%%%

* void forms.drawImageRegion(long componenthandle, string path, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, [[int? dest_width = nil]], [[int? dest_height = nil]])

* Draws a region of the given image file at the given location on the canvas, and optionally resizes it before drawing. Consult this diagram to see its usage (renders embedded on the TASVideos Wiki): [https://user-images.githubusercontent.com/13409956/198868522-55dc1e5f-ae67-4ebb-a75f-558656cb4468.png|alt=Diagram showing how to use forms.drawImageRegion]

__forms.drawLine__%%%

* void forms.drawLine(long componenthandle, int x1, int y1, int x2, int y2, [[luacolor color = nil]])

* Draws a line from the first coordinate pair to the 2nd. Color is optional (if not specified it will be drawn black)

__forms.drawPie__%%%

* void forms.drawPie(long componenthandle, int x, int y, int width, int height, int startangle, int sweepangle, [[luacolor line = nil]], [[luacolor background = nil]])

* draws a Pie shape at the given coordinates and the given width and height

__forms.drawPixel__%%%

* void forms.drawPixel(long componenthandle, int x, int y, [[luacolor color = nil]])

* Draws a single pixel at the given coordinates in the given color. Color is optional (if not specified it will be drawn black)

__forms.drawPolygon__%%%

* void forms.drawPolygon(long componenthandle, nluatable points, [[int? x = nil]], [[int? y = nil]], [[luacolor line = nil]], [[luacolor background = nil]])

* Draws a polygon using the table of coordinates specified in points. This should be a table of tables(each of size 2). If x or y is passed, the polygon will be translated by the passed coordinate pair. Line is the color of the polygon. Background is the optional fill color

__forms.drawRectangle__%%%

* void forms.drawRectangle(long componenthandle, int x, int y, int width, int height, [[luacolor line = nil]], [[luacolor background = nil]])

* Draws a rectangle at the given coordinate and the given width and height. Line is the color of the box. Background is the optional fill color

__forms.drawString__%%%

* void forms.drawString(long componenthandle, int x, int y, string message, [[luacolor forecolor = nil]], [[luacolor backcolor = nil]], [[int? fontsize = nil]], [[string fontfamily = nil]], [[string fontstyle = nil]], [[string horizalign = nil]], [[string vertalign = nil]])

* Alias of DrawText()

__forms.drawText__%%%

* void forms.drawText(long componenthandle, int x, int y, string message, [[luacolor forecolor = nil]], [[luacolor backcolor = nil]], [[int? fontsize = nil]], [[string fontfamily = nil]], [[string fontstyle = nil]], [[string horizalign = nil]], [[string vertalign = nil]])

* Draws the given message at the given x,y coordinates and the given color. The default color is white. A fontfamily can be specified and is monospace generic if none is specified (font family options are the same as the .NET FontFamily class). The fontsize default is 12. The default font style is regular. Font style options are regular, bold, italic, strikethrough, underline. Horizontal alignment options are left (default), center, or right. Vertical alignment options are bottom (default), middle, or top. Alignment options specify which ends of the text will be drawn at the x and y coordinates.

__forms.dropdown__%%%

* long forms.dropdown(long formhandle, nluatable items, [[int? x = nil]], [[int? y = nil]], [[int? width = nil]], [[int? height = nil]])

* Creates a dropdown (with a ComboBoxStyle of DropDownList) control on the given form. Dropdown items are passed via a lua table. Only the values will be pulled for the dropdown items, the keys are irrelevant. Items will be sorted alphabetically. x and y are the optional location parameters, and width and height are the optional size parameters.

__forms.getMouseX__%%%

* int forms.getMouseX(long componenthandle)

* Returns an integer representation of the mouse X coordinate relative to the PictureBox.

__forms.getMouseY__%%%

* int forms.getMouseY(long componenthandle)

* Returns an integer representation of the mouse Y coordinate relative to the PictureBox.

__forms.getproperty__%%%

* string forms.getproperty(long handle, string property)

* returns a string representation of the value of a property of the widget at the given handle

__forms.gettext__%%%

* string forms.gettext(long handle)

* Returns the text property of a given form or control

__forms.ischecked__%%%

* bool forms.ischecked(long handle)

* Returns the given checkbox's checked property

__forms.label__%%%

* long forms.label(long formhandle, string caption, [[int? x = nil]], [[int? y = nil]], [[int? width = nil]], [[int? height = nil]], [[bool fixedwidth = False]])

* Creates a label control on the given form. The caption property is the text of the label. x, and y are the optional location parameters for the position of the label within the given form. The function returns the handle of the created label. Width and Height are optional, if not specified they will be a default size.

__forms.newform__%%%

* long forms.newform([[int? width = nil]], [[int? height = nil]], [[string title = nil]], [[nluafunc onclose = nil]])

* creates a new default dialog, if both width and height are specified it will create a dialog of the specified size. If title is specified it will be the caption of the dialog, else the dialog caption will be 'Lua Dialog'. The function will return an int representing the handle of the dialog created.

__forms.openfile__%%%

* string forms.openfile([[string filename = nil]], [[string initialdirectory = nil]], [[string filter = nil]])

* Creates a standard openfile dialog with optional parameters for the filename, directory, and filter. The return value is the directory that the user picked. If they chose to cancel, it will return an empty string

__forms.pictureBox__%%%

* long forms.pictureBox(long formhandle, [[int? x = nil]], [[int? y = nil]], [[int? width = nil]], [[int? height = nil]])

* Creates a new drawing area in the form. Optionally the location in the form as well as the size of the drawing area can be specified. Returns the handle the component can be refered to with.

__forms.refresh__%%%

* void forms.refresh(long componenthandle)

* Redraws the canvas

__forms.setDefaultBackgroundColor__%%%

* void forms.setDefaultBackgroundColor(long componenthandle, luacolor color)

* Sets the default background color to use in drawing methods, transparent by default

__forms.setDefaultForegroundColor__%%%

* void forms.setDefaultForegroundColor(long componenthandle, luacolor color)

* Sets the default foreground color to use in drawing methods, white by default

__forms.setDefaultTextBackground__%%%

* void forms.setDefaultTextBackground(long componenthandle, luacolor color)

* Sets the default backgroiund color to use in text drawing methods, half-transparent black by default

__forms.setdropdownitems__%%%

* void forms.setdropdownitems(long handle, nluatable items, [[bool alphabetize = True]])

* Updates the item list of a dropdown menu. The optional third parameter toggles alphabetical sorting of items, pass false to skip sorting.

__forms.setlocation__%%%

* void forms.setlocation(long handle, int x, int y)

* Sets the location of a control or form by passing in the handle of the created object

__forms.setproperty__%%%

* void forms.setproperty(long handle, string property, object value)

* Attempts to set the given property of the widget with the given value.  Note: not all properties will be able to be represented for the control to accept

__forms.setsize__%%%

* void forms.setsize(long handle, int width, int height)

* TODO

__forms.settext__%%%

* void forms.settext(long handle, string caption)

* Sets the text property of a control or form by passing in the handle of the created object

__forms.textbox__%%%

* long forms.textbox(long formhandle, [[string caption = nil]], [[int? width = nil]], [[int? height = nil]], [[string boxtype = nil]], [[int? x = nil]], [[int? y = nil]], [[bool multiline = False]], [[bool fixedwidth = False]], [[string scrollbars = nil]])

* Creates a textbox control on the given form. The caption property will be the initial value of the textbox (default is empty). Width and Height are option, if not specified they will be a default size of 100, 20. Type is an optional property to restrict the textbox input. The available options are HEX, SIGNED, and UNSIGNED. Passing it null or any other value will set it to no restriction. x, and y are the optional location parameters for the position of the textbox within the given form. The function returns the handle of the created textbox. If true, the multiline will enable the standard winform multi-line property. If true, the fixedWidth options will create a fixed width font. Scrollbars is an optional property to specify which scrollbars to display. The available options are Vertical, Horizontal, Both, and None. Scrollbars are only shown on a multiline textbox

%%TAB gameinfo%%

__gameinfo.getboardtype__%%%

* string gameinfo.getboardtype()

* returns identifying information about the 'mapper' or similar capability used for this game.  empty if no such useful distinction can be drawn

__gameinfo.getoptions__%%%

* nluatable gameinfo.getoptions()

* returns the game options for the currently loaded rom. Options vary per platform

__gameinfo.getromhash__%%%

* string gameinfo.getromhash()

* returns the hash of the currently loaded rom, if a rom is loaded

__gameinfo.getromname__%%%

* string gameinfo.getromname()

* returns the name of the currently loaded rom, if a rom is loaded

__gameinfo.getstatus__%%%

* string gameinfo.getstatus()

* returns the game database status of the currently loaded rom. Statuses are for example: GoodDump, BadDump, Hack, Unknown, NotInDatabase

__gameinfo.indatabase__%%%

* bool gameinfo.indatabase()

* returns whether or not the currently loaded rom is in the game database

__gameinfo.isstatusbad__%%%

* bool gameinfo.isstatusbad()

* returns the currently loaded rom's game database status is considered 'bad'

%%TAB genesis%%

Functions specific to GenesisHawk (functions may not run when an Genesis game is not loaded)

__genesis.getlayer_bga__%%%

* bool genesis.getlayer_bga()

* Returns whether the bg layer A is displayed

__genesis.getlayer_bgb__%%%

* bool genesis.getlayer_bgb()

* Returns whether the bg layer B is displayed

__genesis.getlayer_bgw__%%%

* bool genesis.getlayer_bgw()

* Returns whether the bg layer W is displayed

__genesis.setlayer_bga__%%%

* void genesis.setlayer_bga(bool value)

* Sets whether the bg layer A is displayed

__genesis.setlayer_bgb__%%%

* void genesis.setlayer_bgb(bool value)

* Sets whether the bg layer B is displayed

__genesis.setlayer_bgw__%%%

* void genesis.setlayer_bgw(bool value)

* Sets whether the bg layer W is displayed

%%TAB gui%%

__gui.addmessage__%%%

* void gui.addmessage(string message)

* Adds a message to the OSD's message area

__gui.clearGraphics__%%%

* void gui.clearGraphics([[string surfacename = nil]])

* clears all lua drawn graphics from the screen

__gui.clearImageCache__%%%

* void gui.clearImageCache()

* clears the image cache that is built up by using gui.drawImage, also releases the file handle for cached images

__gui.cleartext__%%%

* void gui.cleartext()

* clears all text created by gui.text()

__gui.createcanvas__%%%

* nluatable gui.createcanvas(int width, int height, [[int? x = nil]], [[int? y = nil]])

* Creates a canvas of the given size and, if specified, the given coordinates.

__gui.defaultBackground__%%%

* void gui.defaultBackground(luacolor color)

* Sets the default background color to use in drawing methods, transparent by default

__gui.defaultForeground__%%%

* void gui.defaultForeground(luacolor color)

* Sets the default foreground color to use in drawing methods, white by default

__gui.defaultPixelFont__%%%

* void gui.defaultPixelFont(string fontfamily)

* Sets the default font to use in gui.pixelText(). Two font families are available, "fceux" and "gens" (or  "0" and "1" respectively), "gens" is used by default

__gui.defaultTextBackground__%%%

* void gui.defaultTextBackground(luacolor color)

* Sets the default background color to use in text drawing methods, half-transparent black by default

__gui.drawAxis__%%%

* void gui.drawAxis(int x, int y, int size, [[luacolor color = nil]], [[string surfacename = nil]])

* Draws an axis of the specified size at the coordinate pair.)

__gui.drawBezier__%%%

* void gui.drawBezier(nluatable points, luacolor color, [[string surfacename = nil]])

* Draws a Bezier curve using the table of coordinates provided in the given color

__gui.drawBox__%%%

* void gui.drawBox(int x, int y, int x2, int y2, [[luacolor line = nil]], [[luacolor background = nil]], [[string surfacename = nil]])

* Draws a rectangle on screen from x1/y1 to x2/y2. Same as drawRectangle except it receives two points intead of a point and width/height

__gui.drawEllipse__%%%

* void gui.drawEllipse(int x, int y, int width, int height, [[luacolor line = nil]], [[luacolor background = nil]], [[string surfacename = nil]])

* Draws an ellipse at the given coordinates and the given width and height. Line is the color of the ellipse. Background is the optional fill color

__gui.DrawFinish__%%%

* __[[deprecated]]__ void gui.DrawFinish()

* Finishes drawing to the current lua surface and causes it to get displayed.

__gui.drawIcon__%%%

* void gui.drawIcon(string path, int x, int y, [[int? width = nil]], [[int? height = nil]], [[string surfacename = nil]])

* draws an Icon (.ico) file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly

__gui.drawImage__%%%

* void gui.drawImage(string path, int x, int y, [[int? width = nil]], [[int? height = nil]], [[bool cache = True]], [[string surfacename = nil]])

* draws an image file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly

__gui.drawImageRegion__%%%

* void gui.drawImageRegion(string path, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, [[int? dest_width = nil]], [[int? dest_height = nil]], [[string surfacename = nil]])

* draws a given region of an image file from the given path at the given coordinate, and optionally with the given size

__gui.drawLine__%%%

* void gui.drawLine(int x1, int y1, int x2, int y2, [[luacolor color = nil]], [[string surfacename = nil]])

* Draws a line from the first coordinate pair to the 2nd. Color is optional (if not specified it will be drawn black)

__gui.DrawNew__%%%

* __[[deprecated]]__ void gui.DrawNew(string name, [[bool? clear = True]])

* Changes drawing target to the specified lua surface name. This may clobber any previous drawing to this surface (pass false if you don't want it to)

__gui.drawPie__%%%

* void gui.drawPie(int x, int y, int width, int height, int startangle, int sweepangle, [[luacolor line = nil]], [[luacolor background = nil]], [[string surfacename = nil]])

* draws a Pie shape at the given coordinates and the given width and height

__gui.drawPixel__%%%

* void gui.drawPixel(int x, int y, [[luacolor color = nil]], [[string surfacename = nil]])

* Draws a single pixel at the given coordinates in the given color. Color is optional (if not specified it will be drawn black)

__gui.drawPolygon__%%%

* void gui.drawPolygon(nluatable points, [[int? offsetx = nil]], [[int? offsety = nil]], [[luacolor line = nil]], [[luacolor background = nil]], [[string surfacename = nil]])

* Draws a polygon using the table of coordinates specified in points. This should be a table of tables(each of size 2). If x or y is passed, the polygon will be translated by the passed coordinate pair. Line is the color of the polygon. Background is the optional fill color

__gui.drawRectangle__%%%

* void gui.drawRectangle(int x, int y, int width, int height, [[luacolor line = nil]], [[luacolor background = nil]], [[string surfacename = nil]])

* Draws a rectangle at the given coordinate and the given width and height. Line is the color of the box. Background is the optional fill color

__gui.drawString__%%%

* void gui.drawString(int x, int y, string message, [[luacolor forecolor = nil]], [[luacolor backcolor = nil]], [[int? fontsize = nil]], [[string fontfamily = nil]], [[string fontstyle = nil]], [[string horizalign = nil]], [[string vertalign = nil]], [[string surfacename = nil]])

* Draws the given message in the emulator screen space (like all draw functions) at the given x,y coordinates and the given color. The default color is white. A fontfamily can be specified and is monospace generic if none is specified (font family options are the same as the .NET FontFamily class). The fontsize default is 12. The default font style is regular. Font style options are regular, bold, italic, strikethrough, underline. Horizontal alignment options are left (default), center, or right. Vertical alignment options are bottom (default), middle, or top. Alignment options specify which ends of the text will be drawn at the x and y coordinates. For pixel-perfect font look, make sure to disable aspect ratio correction.

__gui.drawText__%%%

* void gui.drawText(int x, int y, string message, [[luacolor forecolor = nil]], [[luacolor backcolor = nil]], [[int? fontsize = nil]], [[string fontfamily = nil]], [[string fontstyle = nil]], [[string horizalign = nil]], [[string vertalign = nil]], [[string surfacename = nil]])

* alias for gui.drawString

__gui.pixelText__%%%

* void gui.pixelText(int x, int y, string message, [[luacolor forecolor = nil]], [[luacolor backcolor = nil]], [[string fontfamily = nil]], [[string surfacename = nil]])

* Draws the given message in the emulator screen space (like all draw functions) at the given x,y coordinates and the given color. The default color is white. Two font families are available, "fceux" and "gens" (or  "0" and "1" respectively), both are monospace and have the same size as in the emulators they've been taken from. If no font family is specified, it uses "gens" font, unless that's overridden via gui.defaultPixelFont()

__gui.text__%%%

* void gui.text(int x, int y, string message, [[luacolor forecolor = nil]], [[string anchor = nil]])

* Displays the given text on the screen at the given coordinates. Optional Foreground color. The optional anchor flag anchors the text to one of the four corners. Anchor flag parameters: topleft, topright, bottomleft, bottomright

__gui.use_surface__%%%

* void gui.use_surface(string surfacename)

* Stores the name of a surface to draw on, so you don't need to pass it to every draw function. The default is "emucore", and the other valid value is "client".

%%TAB input%%

__input.get__%%%

* nluatable input.get()

* Returns a lua table of all the buttons the user is currently pressing on their keyboard and gamepads
All buttons that are pressed have their key values set to true; all others remain nil.

__input.getmouse__%%%

* nluatable input.getmouse()

* Returns a lua table of the mouse X/Y coordinates and button states. Table keys are X, Y, Left, Middle, Right, XButton1, XButton2, Wheel.

%%TAB joypad%%

__joypad.get__%%%

* nluatable joypad.get([[int? controller = nil]])

* returns a lua table of the controller buttons pressed. If supplied, it will only return a table of buttons for the given controller

__joypad.getimmediate__%%%

* nluatable joypad.getimmediate([[int? controller = nil]])

* returns a lua table of any controller buttons currently pressed by the user

__joypad.getwithmovie__%%%

* nluatable joypad.getwithmovie([[int? controller = nil]])

* returns a lua table of the controller buttons pressed, including ones pressed by the current movie. If supplied, it will only return a table of buttons for the given controller

__joypad.set__%%%

* void joypad.set(nluatable buttons, [[int? controller = nil]])

* sets the given buttons to their provided values for the current frame

__joypad.setanalog__%%%

* void joypad.setanalog(nluatable controls, [[int? controller = nil]])

* sets the given analog controls to their provided values for the current frame. Note that unlike set() there is only the logic of overriding with the given value.

__joypad.setfrommnemonicstr__%%%

* void joypad.setfrommnemonicstr(string inputlogentry)

* sets the given buttons to their provided values for the current frame, string will be interpreted the same way an entry from a movie input log would be

%%TAB LuaCanvas%%

Represents a canvas object returned by the gui.createcanvas() method

__LuaCanvas.Clear__%%%

* void LuaCanvas.Clear(luacolor color)

* Clears the canvas

__LuaCanvas.ClearImageCache__%%%

* void LuaCanvas.ClearImageCache()

* clears the image cache that is built up by using gui.drawImage, also releases the file handle for cached images

__LuaCanvas.DrawArc__%%%

* void LuaCanvas.DrawArc(int x, int y, int width, int height, int startangle, int sweepangle, [[luacolor line = nil]])

* draws a Arc shape at the given coordinates and the given width and height

__LuaCanvas.DrawAxis__%%%

* void LuaCanvas.DrawAxis(int x, int y, int size, [[luacolor color = nil]])

* Draws an axis of the specified size at the coordinate pair.)

__LuaCanvas.DrawBezier__%%%

* void LuaCanvas.DrawBezier(nluatable points, luacolor color)

* Draws a Bezier curve using the table of coordinates provided in the given color

__LuaCanvas.DrawBox__%%%

* void LuaCanvas.DrawBox(int x, int y, int x2, int y2, [[luacolor line = nil]], [[luacolor background = nil]])

* Draws a rectangle on screen from x1/y1 to x2/y2. Same as drawRectangle except it receives two points intead of a point and width/height

__LuaCanvas.DrawEllipse__%%%

* void LuaCanvas.DrawEllipse(int x, int y, int width, int height, [[luacolor line = nil]], [[luacolor background = nil]])

* Draws an ellipse at the given coordinates and the given width and height. Line is the color of the ellipse. Background is the optional fill color

__LuaCanvas.DrawIcon__%%%

* void LuaCanvas.DrawIcon(string path, int x, int y, [[int? width = nil]], [[int? height = nil]])

* draws an Icon (.ico) file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly

__LuaCanvas.DrawImage__%%%

* void LuaCanvas.DrawImage(string path, int x, int y, [[int? width = nil]], [[int? height = nil]], [[bool cache = True]])

* draws an image file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly

__LuaCanvas.DrawImageRegion__%%%

* void LuaCanvas.DrawImageRegion(string path, int sourcex, int sourcey, int sourcewidth, int sourceheight, int destx, int desty, [[int? destwidth = nil]], [[int? destheight = nil]])

* draws a given region of an image file from the given path at the given coordinate, and optionally with the given size

__LuaCanvas.DrawLine__%%%

* void LuaCanvas.DrawLine(int x1, int y1, int x2, int y2, [[luacolor color = nil]])

* Draws a line from the first coordinate pair to the 2nd. Color is optional (if not specified it will be drawn black)

__LuaCanvas.DrawPie__%%%

* void LuaCanvas.DrawPie(int x, int y, int width, int height, int startangle, int sweepangle, [[luacolor line = nil]], [[luacolor background = nil]])

* draws a Pie shape at the given coordinates and the given width and height

__LuaCanvas.DrawPixel__%%%

* void LuaCanvas.DrawPixel(int x, int y, [[luacolor color = nil]])

* Draws a single pixel at the given coordinates in the given color. Color is optional (if not specified it will be drawn black)

__LuaCanvas.DrawPolygon__%%%

* void LuaCanvas.DrawPolygon(nluatable points, [[int? x = nil]], [[int? y = nil]], [[luacolor line = nil]], [[luacolor background = nil]])

* Draws a polygon using the table of coordinates specified in points. This should be a table of tables(each of size 2). Line is the color of the polygon. Background is the optional fill color

__LuaCanvas.DrawRectangle__%%%

* void LuaCanvas.DrawRectangle(int x, int y, int width, int height, [[luacolor line = nil]], [[luacolor background = nil]])

* Draws a rectangle at the given coordinate and the given width and height. Line is the color of the box. Background is the optional fill color

__LuaCanvas.DrawString__%%%

* void LuaCanvas.DrawString(int x, int y, string message, [[luacolor forecolor = nil]], [[luacolor backcolor = nil]], [[int? fontsize = nil]], [[string fontfamily = nil]], [[string fontstyle = nil]], [[string horizontalalign = nil]], [[string verticalalign = nil]])

* Alias of DrawText()

__LuaCanvas.DrawText__%%%

* void LuaCanvas.DrawText(int x, int y, string message, [[luacolor forecolor = nil]], [[luacolor backcolor = nil]], [[int? fontsize = nil]], [[string fontfamily = nil]], [[string fontstyle = nil]], [[string horizontalalign = nil]], [[string verticalalign = nil]])

* Draws the given message at the given x,y coordinates and the given color. The default color is white. A fontfamily can be specified and is monospace generic if none is specified (font family options are the same as the .NET FontFamily class). The fontsize default is 12. The default font style is regular. Font style options are regular, bold, italic, strikethrough, underline. Horizontal alignment options are left (default), center, or right. Vertical alignment options are bottom (default), middle, or top. Alignment options specify which ends of the text will be drawn at the x and y coordinates.

__LuaCanvas.GetMouseX__%%%

* int LuaCanvas.GetMouseX()

* Returns an integer representation of the mouse X coordinate relative to the canvas window.

__LuaCanvas.GetMouseY__%%%

* int LuaCanvas.GetMouseY()

* Returns an integer representation of the mouse Y coordinate relative to the canvas window.

__LuaCanvas.Refresh__%%%

* void LuaCanvas.Refresh()

* Redraws the canvas

__LuaCanvas.save_image_to_disk__%%%

* void LuaCanvas.save_image_to_disk(string path)

* Saves everything that's been drawn to a .png file at the given path. Relative paths are relative to the path set for "Screenshots" for the current system.

__LuaCanvas.SetDefaultBackgroundColor__%%%

* void LuaCanvas.SetDefaultBackgroundColor(luacolor color)

* Sets the default background color to use in drawing methods, transparent by default

__LuaCanvas.SetDefaultForegroundColor__%%%

* void LuaCanvas.SetDefaultForegroundColor(luacolor color)

* Sets the default foreground color to use in drawing methods, white by default

__LuaCanvas.SetDefaultTextBackground__%%%

* void LuaCanvas.SetDefaultTextBackground(luacolor color)

* Sets the default background color to use in text drawing methods, half-transparent black by default

__LuaCanvas.SetLocation__%%%

* void LuaCanvas.SetLocation(int x, int y)

* Sets the location of the canvas window

__LuaCanvas.SetTitle__%%%

* void LuaCanvas.SetTitle(string title)

* Sets the canvas window title

%%TAB mainmemory%%

Main memory library reads and writes from the Main memory domain (the default memory domain set by any given core)

__mainmemory.getcurrentmemorydomainsize__%%%

* uint mainmemory.getcurrentmemorydomainsize()

* Returns the number of bytes of the domain defined as main memory

__mainmemory.getname__%%%

* string mainmemory.getname()

* returns the name of the domain defined as main memory for the given core

__mainmemory.read_bytes_as_array__%%%

* nluatable mainmemory.read_bytes_as_array(long addr, int length)

* Reads length bytes starting at addr into an array-like table (1-indexed).

__mainmemory.read_bytes_as_dict__%%%

* nluatable mainmemory.read_bytes_as_dict(long addr, int length)

* Reads length bytes starting at addr into a dict-like table (where the keys are the addresses, relative to the start of the main memory).

__mainmemory.read_s16_be__%%%

* int mainmemory.read_s16_be(long addr)

* read signed 2 byte value, big endian

__mainmemory.read_s16_le__%%%

* int mainmemory.read_s16_le(long addr)

* read signed 2 byte value, little endian

__mainmemory.read_s24_be__%%%

* int mainmemory.read_s24_be(long addr)

* read signed 24 bit value, big endian

__mainmemory.read_s24_le__%%%

* int mainmemory.read_s24_le(long addr)

* read signed 24 bit value, little endian

__mainmemory.read_s32_be__%%%

* int mainmemory.read_s32_be(long addr)

* read signed 4 byte value, big endian

__mainmemory.read_s32_le__%%%

* int mainmemory.read_s32_le(long addr)

* read signed 4 byte value, little endian

__mainmemory.read_s8__%%%

* int mainmemory.read_s8(long addr)

* read signed byte

__mainmemory.read_u16_be__%%%

* uint mainmemory.read_u16_be(long addr)

* read unsigned 2 byte value, big endian

__mainmemory.read_u16_le__%%%

* uint mainmemory.read_u16_le(long addr)

* read unsigned 2 byte value, little endian

__mainmemory.read_u24_be__%%%

* uint mainmemory.read_u24_be(long addr)

* read unsigned 24 bit value, big endian

__mainmemory.read_u24_le__%%%

* uint mainmemory.read_u24_le(long addr)

* read unsigned 24 bit value, little endian

__mainmemory.read_u32_be__%%%

* uint mainmemory.read_u32_be(long addr)

* read unsigned 4 byte value, big endian

__mainmemory.read_u32_le__%%%

* uint mainmemory.read_u32_le(long addr)

* read unsigned 4 byte value, little endian

__mainmemory.read_u8__%%%

* uint mainmemory.read_u8(long addr)

* read unsigned byte

__mainmemory.readbyte__%%%

* uint mainmemory.readbyte(long addr)

* gets the value from the given address as an unsigned byte

__mainmemory.readbyterange__%%%

* __[[deprecated]]__ nluatable mainmemory.readbyterange(long addr, int length)

* Reads the address range that starts from address, and is length long. Returns a zero-indexed table containing the read values (an array of bytes.)

__mainmemory.readfloat__%%%

* single mainmemory.readfloat(long addr, bool bigendian)

* Reads the given address as a 32-bit float value from the main memory domain with th e given endian

__mainmemory.write_bytes_as_array__%%%

* void mainmemory.write_bytes_as_array(long addr, nluatable bytes)

* Writes sequential bytes starting at addr.

__mainmemory.write_bytes_as_dict__%%%

* void mainmemory.write_bytes_as_dict(nluatable addrmap)

* Writes bytes at arbitrary addresses (the keys of the given table are the addresses, relative to the start of the main memory).

__mainmemory.write_s16_be__%%%

* void mainmemory.write_s16_be(long addr, int value)

* write signed 2 byte value, big endian

__mainmemory.write_s16_le__%%%

* void mainmemory.write_s16_le(long addr, int value)

* write signed 2 byte value, little endian

__mainmemory.write_s24_be__%%%

* void mainmemory.write_s24_be(long addr, int value)

* write signed 24 bit value, big endian

__mainmemory.write_s24_le__%%%

* void mainmemory.write_s24_le(long addr, int value)

* write signed 24 bit value, little endian

__mainmemory.write_s32_be__%%%

* void mainmemory.write_s32_be(long addr, int value)

* write signed 4 byte value, big endian

__mainmemory.write_s32_le__%%%

* void mainmemory.write_s32_le(long addr, int value)

* write signed 4 byte value, little endian

__mainmemory.write_s8__%%%

* void mainmemory.write_s8(long addr, uint  value)

* write signed byte

__mainmemory.write_u16_be__%%%

* void mainmemory.write_u16_be(long addr, uint  value)

* write unsigned 2 byte value, big endian

__mainmemory.write_u16_le__%%%

* void mainmemory.write_u16_le(long addr, uint  value)

* write unsigned 2 byte value, little endian

__mainmemory.write_u24_be__%%%

* void mainmemory.write_u24_be(long addr, uint  value)

* write unsigned 24 bit value, big endian

__mainmemory.write_u24_le__%%%

* void mainmemory.write_u24_le(long addr, uint  value)

* write unsigned 24 bit value, little endian

__mainmemory.write_u32_be__%%%

* void mainmemory.write_u32_be(long addr, uint  value)

* write unsigned 4 byte value, big endian

__mainmemory.write_u32_le__%%%

* void mainmemory.write_u32_le(long addr, uint  value)

* write unsigned 4 byte value, little endian

__mainmemory.write_u8__%%%

* void mainmemory.write_u8(long addr, uint  value)

* write unsigned byte

__mainmemory.writebyte__%%%

* void mainmemory.writebyte(long addr, uint  value)

* Writes the given value to the given address as an unsigned byte

__mainmemory.writebyterange__%%%

* __[[deprecated]]__ void mainmemory.writebyterange(nluatable memoryblock)

* Writes the given values to the given addresses as unsigned bytes

__mainmemory.writefloat__%%%

* void mainmemory.writefloat(long addr, double value, bool bigendian)

* Writes the given 32-bit float value to the given address and endian

%%TAB memory%%

These functions behavior identically to the mainmemory functions but the user can set the memory domain to read and write from. The default domain is the system bus. Use getcurrentmemorydomain(), and usememorydomain() to control which domain is used. Each core has its own set of valid memory domains. Use getmemorydomainlist() to get a list of memory domains for the current core loaded.

__memory.getcurrentmemorydomain__%%%

* string memory.getcurrentmemorydomain()

* Returns a string name of the current memory domain selected by Lua. The default is Main memory

__memory.getcurrentmemorydomainsize__%%%

* uint memory.getcurrentmemorydomainsize()

* Returns the number of bytes of the current memory domain selected by Lua. The default is Main memory

__memory.getmemorydomainlist__%%%

* nluatable memory.getmemorydomainlist()

* Returns a string of the memory domains for the loaded platform core. List will be a single string delimited by line feeds

__memory.getmemorydomainsize__%%%

* uint memory.getmemorydomainsize([[string name = ]])

* Returns the number of bytes of the specified memory domain. If no domain is specified, or the specified domain doesn't exist, returns the current domain size

__memory.hash_region__%%%

* string memory.hash_region(long addr, int count, [[string domain = nil]])

* Returns a hash as a string of a region of memory, starting from addr, through count bytes. If the domain is unspecified, it uses the current region.

__memory.read_bytes_as_array__%%%

* nluatable memory.read_bytes_as_array(long addr, int length, [[string domain = nil]])

* Reads length bytes starting at addr into an array-like table (1-indexed).

__memory.read_bytes_as_dict__%%%

* nluatable memory.read_bytes_as_dict(long addr, int length, [[string domain = nil]])

* Reads length bytes starting at addr into a dict-like table (where the keys are the addresses, relative to the start of the domain).

__memory.read_s16_be__%%%

* int memory.read_s16_be(long addr, [[string domain = nil]])

* read signed 2 byte value, big endian

__memory.read_s16_le__%%%

* int memory.read_s16_le(long addr, [[string domain = nil]])

* read signed 2 byte value, little endian

__memory.read_s24_be__%%%

* int memory.read_s24_be(long addr, [[string domain = nil]])

* read signed 24 bit value, big endian

__memory.read_s24_le__%%%

* int memory.read_s24_le(long addr, [[string domain = nil]])

* read signed 24 bit value, little endian

__memory.read_s32_be__%%%

* int memory.read_s32_be(long addr, [[string domain = nil]])

* read signed 4 byte value, big endian

__memory.read_s32_le__%%%

* int memory.read_s32_le(long addr, [[string domain = nil]])

* read signed 4 byte value, little endian

__memory.read_s8__%%%

* int memory.read_s8(long addr, [[string domain = nil]])

* read signed byte

__memory.read_u16_be__%%%

* uint memory.read_u16_be(long addr, [[string domain = nil]])

* read unsigned 2 byte value, big endian

__memory.read_u16_le__%%%

* uint memory.read_u16_le(long addr, [[string domain = nil]])

* read unsigned 2 byte value, little endian

__memory.read_u24_be__%%%

* uint memory.read_u24_be(long addr, [[string domain = nil]])

* read unsigned 24 bit value, big endian

__memory.read_u24_le__%%%

* uint memory.read_u24_le(long addr, [[string domain = nil]])

* read unsigned 24 bit value, little endian

__memory.read_u32_be__%%%

* uint memory.read_u32_be(long addr, [[string domain = nil]])

* read unsigned 4 byte value, big endian

__memory.read_u32_le__%%%

* uint memory.read_u32_le(long addr, [[string domain = nil]])

* read unsigned 4 byte value, little endian

__memory.read_u8__%%%

* uint memory.read_u8(long addr, [[string domain = nil]])

* read unsigned byte

__memory.readbyte__%%%

* uint memory.readbyte(long addr, [[string domain = nil]])

* gets the value from the given address as an unsigned byte

__memory.readbyterange__%%%

* __[[deprecated]]__ nluatable memory.readbyterange(long addr, int length, [[string domain = nil]])

* Reads the address range that starts from address, and is length long. Returns a zero-indexed table containing the read values (an array of bytes.)

__memory.readfloat__%%%

* single memory.readfloat(long addr, bool bigendian, [[string domain = nil]])

* Reads the given address as a 32-bit float value from the main memory domain with th e given endian

__memory.usememorydomain__%%%

* bool memory.usememorydomain(string domain)

* Attempts to set the current memory domain to the given domain. If the name does not match a valid memory domain, the function returns false, else it returns true

__memory.write_bytes_as_array__%%%

* void memory.write_bytes_as_array(long addr, nluatable bytes, [[string domain = nil]])

* Writes sequential bytes starting at addr.

__memory.write_bytes_as_dict__%%%

* void memory.write_bytes_as_dict(nluatable addrmap, [[string domain = nil]])

* Writes bytes at arbitrary addresses (the keys of the given table are the addresses, relative to the start of the domain).

__memory.write_s16_be__%%%

* void memory.write_s16_be(long addr, int value, [[string domain = nil]])

* write signed 2 byte value, big endian

__memory.write_s16_le__%%%

* void memory.write_s16_le(long addr, int value, [[string domain = nil]])

* write signed 2 byte value, little endian

__memory.write_s24_be__%%%

* void memory.write_s24_be(long addr, int value, [[string domain = nil]])

* write signed 24 bit value, big endian

__memory.write_s24_le__%%%

* void memory.write_s24_le(long addr, int value, [[string domain = nil]])

* write signed 24 bit value, little endian

__memory.write_s32_be__%%%

* void memory.write_s32_be(long addr, int value, [[string domain = nil]])

* write signed 4 byte value, big endian

__memory.write_s32_le__%%%

* void memory.write_s32_le(long addr, int value, [[string domain = nil]])

* write signed 4 byte value, little endian

__memory.write_s8__%%%

* void memory.write_s8(long addr, uint  value, [[string domain = nil]])

* write signed byte

__memory.write_u16_be__%%%

* void memory.write_u16_be(long addr, uint  value, [[string domain = nil]])

* write unsigned 2 byte value, big endian

__memory.write_u16_le__%%%

* void memory.write_u16_le(long addr, uint  value, [[string domain = nil]])

* write unsigned 2 byte value, little endian

__memory.write_u24_be__%%%

* void memory.write_u24_be(long addr, uint  value, [[string domain = nil]])

* write unsigned 24 bit value, big endian

__memory.write_u24_le__%%%

* void memory.write_u24_le(long addr, uint  value, [[string domain = nil]])

* write unsigned 24 bit value, little endian

__memory.write_u32_be__%%%

* void memory.write_u32_be(long addr, uint  value, [[string domain = nil]])

* write unsigned 4 byte value, big endian

__memory.write_u32_le__%%%

* void memory.write_u32_le(long addr, uint  value, [[string domain = nil]])

* write unsigned 4 byte value, little endian

__memory.write_u8__%%%

* void memory.write_u8(long addr, uint  value, [[string domain = nil]])

* write unsigned byte

__memory.writebyte__%%%

* void memory.writebyte(long addr, uint  value, [[string domain = nil]])

* Writes the given value to the given address as an unsigned byte

__memory.writebyterange__%%%

* __[[deprecated]]__ void memory.writebyterange(nluatable memoryblock, [[string domain = nil]])

* Writes the given values to the given addresses as unsigned bytes

__memory.writefloat__%%%

* void memory.writefloat(long addr, double value, bool bigendian, [[string domain = nil]])

* Writes the given 32-bit float value to the given address and endian

%%TAB memorysavestate%%

__memorysavestate.clearstatesfrommemory__%%%

* void memorysavestate.clearstatesfrommemory()

* clears all savestates stored in memory

__memorysavestate.loadcorestate__%%%

* void memorysavestate.loadcorestate(string identifier)

* loads an in memory state with the given identifier

__memorysavestate.removestate__%%%

* void memorysavestate.removestate(string identifier)

* removes the savestate with the given identifier from memory

__memorysavestate.savecorestate__%%%

* string memorysavestate.savecorestate()

* creates a core savestate and stores it in memory.  Note: a core savestate is only the raw data from the core, and not extras such as movie input logs, or framebuffers. Returns a unique identifer for the savestate

%%TAB movie%%

__movie.filename__%%%

* string movie.filename()

* Returns the file name including path of the currently loaded movie

__movie.getcomments__%%%

* nluatable movie.getcomments()

* If a movie is active, will return the movie comments as a lua table

__movie.getfps__%%%

* double movie.getfps()

* If a movie is loaded, gets the frames per second used by the movie to determine the movie length time

__movie.getheader__%%%

* nluatable movie.getheader()

* If a movie is active, will return the movie header as a lua table

__movie.getinput__%%%

* nluatable movie.getinput(int frame, [[int? controller = nil]])

* Returns a table of buttons pressed on a given frame of the loaded movie

__movie.getinputasmnemonic__%%%

* string movie.getinputasmnemonic(int frame)

* Returns the input of a given frame of the loaded movie in a raw inputlog string

__movie.getreadonly__%%%

* bool movie.getreadonly()

* Returns true if the movie is in read-only mode, false if in read+write

__movie.getrerecordcount__%%%

* ulong movie.getrerecordcount()

* Gets the rerecord count of the current movie.

__movie.getrerecordcounting__%%%

* bool movie.getrerecordcounting()

* Returns whether or not the current movie is incrementing rerecords on loadstate

__movie.getsubtitles__%%%

* nluatable movie.getsubtitles()

* If a movie is active, will return the movie subtitles as a lua table

__movie.isloaded__%%%

* bool movie.isloaded()

* Returns true if a movie is loaded in memory (play, record, or finished modes), false if not (inactive mode)

__movie.length__%%%

* int movie.length()

* Returns the total number of frames of the loaded movie

__movie.mode__%%%

* string movie.mode()

* Returns the mode of the current movie. Possible modes: "PLAY", "RECORD", "FINISHED", "INACTIVE"

__movie.play_from_start__%%%

* bool movie.play_from_start([[string path = ]])

* Resets the core to frame 0 with the currently loaded movie in playback mode. If a path to a movie is specified, attempts to load it, then continues with playback if it was successful. Returns true iff successful.

__movie.save__%%%

* void movie.save([[string filename = ]])

* Saves the current movie to the disc. If the filename is provided (no extension or path needed), the movie is saved under the specified name to the current movie directory. The filename may contain a subdirectory, it will be created if it doesn't exist. Existing files won't get overwritten.

__movie.setreadonly__%%%

* void movie.setreadonly(bool readonly)

* Sets the read-only state to the given value. true for read only, false for read+write

__movie.setrerecordcount__%%%

* void movie.setrerecordcount(ulong  count)

* Sets the rerecord count of the current movie.

__movie.setrerecordcounting__%%%

* void movie.setrerecordcounting(bool counting)

* Sets whether or not the current movie will increment the rerecord counter on loadstate

__movie.startsfromsaveram__%%%

* bool movie.startsfromsaveram()

* Returns whether or not the movie is a saveram-anchored movie

__movie.startsfromsavestate__%%%

* bool movie.startsfromsavestate()

* Returns whether or not the movie is a savestate-anchored movie

__movie.stop__%%%

* void movie.stop([[bool savechanges = True]])

* Stops the current movie. Pass false to discard changes.

%%TAB nds%%

Functions specific to NDSHawk (functions may not run when an NDS game is not loaded)

__nds.getaudiobitrate__%%%

* string nds.getaudiobitrate()

* Returns the audio bitrate setting

__nds.getscreengap__%%%

* int nds.getscreengap()

* Returns the gap between the screens

__nds.getscreeninvert__%%%

* bool nds.getscreeninvert()

* Returns whether screens are inverted

__nds.getscreenlayout__%%%

* string nds.getscreenlayout()

* Returns which screen layout is active

__nds.getscreenrotation__%%%

* string nds.getscreenrotation()

* Returns how screens are rotated

__nds.setaudiobitrate__%%%

* void nds.setaudiobitrate(string value)

* Sets the audio bitrate setting

__nds.setscreengap__%%%

* void nds.setscreengap(int value)

* Sets the gap between the screens

__nds.setscreeninvert__%%%

* void nds.setscreeninvert(bool value)

* Sets whether screens are inverted

__nds.setscreenlayout__%%%

* void nds.setscreenlayout(string value)

* Sets which screen layout is active

__nds.setscreenrotation__%%%

* void nds.setscreenrotation(string value)

* Sets how screens are rotated

%%TAB nes%%

Functions related specifically to Nes Cores

__nes.getallowmorethaneightsprites__%%%

* bool nes.getallowmorethaneightsprites()

* Gets the NES setting 'Allow more than 8 sprites per scanline' value

__nes.getbottomscanline__%%%

* int nes.getbottomscanline([[bool pal = False]])

* Gets the current value for the bottom scanline value

__nes.getclipleftandright__%%%

* bool nes.getclipleftandright()

* Gets the current value for the Clip Left and Right sides option

__nes.getdispbackground__%%%

* bool nes.getdispbackground()

* Indicates whether or not the bg layer is being displayed

__nes.getdispsprites__%%%

* bool nes.getdispsprites()

* Indicates whether or not sprites are being displayed

__nes.gettopscanline__%%%

* int nes.gettopscanline([[bool pal = False]])

* Gets the current value for the top scanline value

__nes.setallowmorethaneightsprites__%%%

* void nes.setallowmorethaneightsprites(bool allow)

* Sets the NES setting 'Allow more than 8 sprites per scanline'

__nes.setclipleftandright__%%%

* void nes.setclipleftandright(bool leftandright)

* Sets the Clip Left and Right sides option

__nes.setdispbackground__%%%

* void nes.setdispbackground(bool show)

* Sets whether or not the background layer will be displayed

__nes.setdispsprites__%%%

* void nes.setdispsprites(bool show)

* Sets whether or not sprites will be displayed

__nes.setscanlines__%%%

* void nes.setscanlines(int top, int bottom, [[bool pal = False]])

* sets the top and bottom scanlines to be drawn (same values as in the graphics options dialog). Top must be in the range of 0 to 127, bottom must be between 128 and 239. Not supported in the Quick Nes core

%%TAB savestate%%

__savestate.load__%%%

* bool savestate.load(string path, [[bool suppressosd = False]])

* Loads a savestate with the given path. Returns true iff succeeded. If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes (and the path is ignored).

__savestate.loadslot__%%%

* bool savestate.loadslot(int slotnum, [[bool suppressosd = False]])

* Loads the savestate at the given slot number (must be an integer between 1 and 10). Returns true iff succeeded. If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes with the slot number.

__savestate.save__%%%

* void savestate.save(string path, [[bool suppressosd = False]])

* Saves a state at the given path. If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes (and the path is ignored).

__savestate.saveslot__%%%

* void savestate.saveslot(int slotnum, [[bool suppressosd = False]])

* Saves a state at the given save slot (must be an integer between 1 and 10). If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes with the slot number.

%%TAB snes%%

Functions specific to SNESHawk (functions may not run when an SNES game is not loaded)

__snes.getlayer_bg_1__%%%

* bool snes.getlayer_bg_1()

* Returns whether the bg 1 layer is displayed

__snes.getlayer_bg_2__%%%

* bool snes.getlayer_bg_2()

* Returns whether the bg 2 layer is displayed

__snes.getlayer_bg_3__%%%

* bool snes.getlayer_bg_3()

* Returns whether the bg 3 layer is displayed

__snes.getlayer_bg_4__%%%

* bool snes.getlayer_bg_4()

* Returns whether the bg 4 layer is displayed

__snes.getlayer_obj_1__%%%

* bool snes.getlayer_obj_1()

* Returns whether the obj 1 layer is displayed

__snes.getlayer_obj_2__%%%

* bool snes.getlayer_obj_2()

* Returns whether the obj 2 layer is displayed

__snes.getlayer_obj_3__%%%

* bool snes.getlayer_obj_3()

* Returns whether the obj 3 layer is displayed

__snes.getlayer_obj_4__%%%

* bool snes.getlayer_obj_4()

* Returns whether the obj 4 layer is displayed

__snes.setlayer_bg_1__%%%

* void snes.setlayer_bg_1(bool value)

* Sets whether the bg 1 layer is displayed

__snes.setlayer_bg_2__%%%

* void snes.setlayer_bg_2(bool value)

* Sets whether the bg 2 layer is displayed

__snes.setlayer_bg_3__%%%

* void snes.setlayer_bg_3(bool value)

* Sets whether the bg 3 layer is displayed

__snes.setlayer_bg_4__%%%

* void snes.setlayer_bg_4(bool value)

* Sets whether the bg 4 layer is displayed

__snes.setlayer_obj_1__%%%

* void snes.setlayer_obj_1(bool value)

* Sets whether the obj 1 layer is displayed

__snes.setlayer_obj_2__%%%

* void snes.setlayer_obj_2(bool value)

* Sets whether the obj 2 layer is displayed

__snes.setlayer_obj_3__%%%

* void snes.setlayer_obj_3(bool value)

* Sets whether the obj 3 layer is displayed

__snes.setlayer_obj_4__%%%

* void snes.setlayer_obj_4(bool value)

* Sets whether the obj 4 layer is displayed

%%TAB SQL%%

A library for performing SQLite operations.

__SQL.createdatabase__%%%

* string SQL.createdatabase(string name)

* Creates a SQLite Database. Name should end with .db

__SQL.opendatabase__%%%

* string SQL.opendatabase(string name)

* Opens a SQLite database. Name should end with .db

__SQL.readcommand__%%%

* object SQL.readcommand([[string query = ]])

* Run a SQLite read command which includes Select. Returns all rows into a LuaTable.Ex: select * from rewards

__SQL.writecommand__%%%

* string SQL.writecommand([[string query = ]])

* Runs a SQLite write command which includes CREATE,INSERT, UPDATE. Ex: create TABLE rewards (ID integer  PRIMARY KEY, action VARCHAR(20)) 

%%TAB tastudio%%

A library for manipulating the Tastudio dialog of the EmuHawk client

__tastudio.addcolumn__%%%

* void tastudio.addcolumn(string name, string text, int width)

* 

__tastudio.applyinputchanges__%%%

* void tastudio.applyinputchanges()

__tastudio.clearIconCache__%%%

* void tastudio.clearIconCache()

* Clears the cache that is built up by using {{tastudio.onqueryitemicon}}, so that changes to the icons on disk can be picked up.

__tastudio.clearinputchanges__%%%

* void tastudio.clearinputchanges()

__tastudio.engaged__%%%

* bool tastudio.engaged()

* returns whether or not tastudio is currently engaged (active)

__tastudio.getbranches__%%%

* nluatable tastudio.getbranches()

* Returns a list of the current tastudio branches.  Each entry will have the Id, Frame, and Text properties of the branch

__tastudio.getbranchinput__%%%

* nluatable tastudio.getbranchinput(string branchid, int frame)

* Gets the controller state of the given frame with the given branch identifier

__tastudio.getmarker__%%%

* string tastudio.getmarker(int frame)

* returns the marker text at the given frame, or an empty string if there is no marker for the given frame

__tastudio.getrecording__%%%

* bool tastudio.getrecording()

* returns whether or not TAStudio is in recording mode

__tastudio.getselection__%%%

* nluatable tastudio.getselection()

* gets the currently selected frames

__tastudio.hasstate__%%%

* bool tastudio.hasstate(int frame)

* Returns whether or not the given frame has a savestate associated with it

__tastudio.islag__%%%

* bool? tastudio.islag(int frame)

* Returns whether or not the given frame was a lag frame, null if unknown

__tastudio.loadbranch__%%%

* void tastudio.loadbranch(int index)

* Loads a branch at the given index, if a branch at that index exists.

__tastudio.onbranchload__%%%

* void tastudio.onbranchload(nluafunc luaf)

* called whenever a branch is loaded. luaf must be a function that takes the integer branch index as a parameter

__tastudio.onbranchremove__%%%

* void tastudio.onbranchremove(nluafunc luaf)

* called whenever a branch is removed. luaf must be a function that takes the integer branch index as a parameter

__tastudio.onbranchsave__%%%

* void tastudio.onbranchsave(nluafunc luaf)

* called whenever a branch is created or updated. luaf must be a function that takes the integer branch index as a parameter

__tastudio.ongreenzoneinvalidated__%%%

* void tastudio.ongreenzoneinvalidated(nluafunc luaf)

* Called whenever the greenzone is invalidated. Your callback can have 1 parameter, which will be the index of the first row that was invalidated.

__tastudio.onqueryitembg__%%%

* void tastudio.onqueryitembg(nluafunc luaf)

* called during the background draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column.  The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)

__tastudio.onqueryitemicon__%%%

* void tastudio.onqueryitemicon(nluafunc luaf)

* Called during the icon draw event of the tastudio listview. {{luaf}} must be a function that takes 2 params: {{(index, column)}}. The first is the integer row index of the listview, and the 2nd is the string column name. The callback should return a string, the path to the {{.ico}} file to be displayed. The file will be cached, so if you change the file on disk, call {{tastudio.clearIconCache()}}.

__tastudio.onqueryitemtext__%%%

* void tastudio.onqueryitemtext(nluafunc luaf)

* Called during the text draw event of the tastudio listview. {{luaf}} must be a function that takes 2 params: {{(index, column)}}. The first is the integer row index of the listview, and the 2nd is the string column name. The callback should return a string to be displayed.

__tastudio.removemarker__%%%

* void tastudio.removemarker(int frame)

* if there is a marker for the given frame, it will be removed

__tastudio.setbranchtext__%%%

* void tastudio.setbranchtext(string text, [[int? index = nil]])

* adds the given message to the existing branch, or to the branch that will be created next if branch index is not specified

__tastudio.setlag__%%%

* void tastudio.setlag(int frame, bool? value)

* Sets the lag information for the given frame, if the frame does not exist in the lag log, it will be added. If the value is null, the lag information for that frame will be removed

__tastudio.setmarker__%%%

* void tastudio.setmarker(int frame, [[string message = nil]])

* Adds or sets a marker at the given frame, with an optional message

__tastudio.setplayback__%%%

* void tastudio.setplayback(object frame)

* Seeks the given frame (a number) or marker (a string)

__tastudio.setrecording__%%%

* void tastudio.setrecording(bool val)

* sets the recording mode on/off depending on the parameter

__tastudio.submitanalogchange__%%%

* void tastudio.submitanalogchange(int frame, string button, singlevalue)

* 

__tastudio.submitclearframes__%%%

* void tastudio.submitclearframes(int frame, int number)

* 

__tastudio.submitdeleteframes__%%%

* void tastudio.submitdeleteframes(int frame, int number)

* 

__tastudio.submitinputchange__%%%

* void tastudio.submitinputchange(int frame, string button, bool value)

* 

__tastudio.submitinsertframes__%%%

* void tastudio.submitinsertframes(int frame, int number)

* 

__tastudio.togglerecording__%%%

* void tastudio.togglerecording()

* toggles tastudio recording mode on/off depending on its current state

%%TAB userdata%%

A library for setting and retrieving dynamic data that will be saved and loaded with savestates

__userdata.clear__%%%

* void userdata.clear()

* clears all user data

__userdata.containskey__%%%

* bool userdata.containskey(string key)

* returns whether or not there is an entry for the given key

__userdata.get__%%%

* object userdata.get(string key)

* gets the data with the given key, if the key does not exist it will return nil

__userdata.get_keys__%%%

* nluatable userdata.get_keys()

* returns a list-like table of valid keys

__userdata.remove__%%%

* bool userdata.remove(string key)

* remove the data with the given key. Returns true if the element is successfully found and removed; otherwise, false.

__userdata.set__%%%

* void userdata.set(string name, object value)

* adds or updates the data with the given key with the given value

%%TAB_END%%