TASVideos

Tool-assisted game movies
When human skills are just not enough

Bizhawk / Lua Functions

<< Bizhawk

This page documents the the behavior and parameters of Lua functions available for the BizHawk emulator. This is an autogenerated page, do not edit

All type names represent the standard .NET types of the same name. Except for func which represents a lua function and table which represents a lua table. For more information on .NET types can be found in MSDN documentation.

Types and notation

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

userdata.set

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

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

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.clear

  • void userdata.clear()

  • clears all user data

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.containskey

  • bool userdata.containskey(string key)

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

A library for performing standard bitwise operations.

bit.band

  • uint bit.band(uint val, uint amt)

  • Bitwise AND of 'val' against 'amt'

bit.bnot

  • uint bit.bnot(uint val)

  • Bitwise NOT of 'val' against 'amt'

bit.bor

  • uint bit.bor(uint val, uint amt)

  • Bitwise OR of 'val' against 'amt'

bit.bxor

  • uint bit.bxor(uint val, uint amt)

  • Bitwise XOR of 'val' against 'amt'

bit.lshift

  • 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

  • uint bit.rshift(uint val, int amt)

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

bit.arshift

  • int bit.arshift(int val, int amt)

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

bit.check

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

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

bit.set

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

  • Sets the bit 'pos' in 'num'

bit.clear

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

  • Clears the bit 'pos' in 'num'

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'

A library for interacting with the currently loaded emulator core

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.disassemble

  • object 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.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

  • table emu.getregisters()

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

emu.setregister

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

  • sets the given register name to the given value

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.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.lagcount

  • int emu.lagcount()

  • Returns the current lag count

emu.setlagcount

  • void emu.setlagcount(int count)

  • Sets 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.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.yield

  • void emu.yield()

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

emu.getdisplaytype

  • string emu.getdisplaytype()

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

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.onframeend

  • string event.onframeend(func luaf, [string name = null])

  • 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(func luaf, [string name = null])

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

event.oninputpoll

  • string event.oninputpoll(func luaf, [string name = null])

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

event.onloadstate

  • string event.onloadstate(func luaf, [string name = null])

  • Fires after a state is loaded. Receives a lua function name, and registers it to the event immediately following a successful savestate event

event.onmemoryexecute

  • string event.onmemoryexecute(func luaf, uint address, [string name = null])

  • Fires after the given address is executed by the core

event.onmemoryread

  • string event.onmemoryread(func luaf, [uint? address = null], [string name = null])

  • Fires after the given address is read by the core. If no address is given, it will attach to every memory read

event.onmemorywrite

  • string event.onmemorywrite(func luaf, [uint? address = null], [string name = null])

  • Fires after the given address is written by the core. If no address is given, it will attach to every memory write

event.onsavestate

  • string event.onsavestate(func luaf, [string name = null])

  • Fires after a state is saved

event.onexit

  • string event.onexit(func luaf, [string name = null])

  • Fires after the calling script has stopped

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.

gameinfo.getromname

  • string gameinfo.getromname()

  • returns the path of the currently loaded rom, if a rom is loaded

gameinfo.getromhash

  • string gameinfo.getromhash()

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

gameinfo.indatabase

  • bool gameinfo.indatabase()

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

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.isstatusbad

  • bool gameinfo.isstatusbad()

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

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

  • table gameinfo.getoptions()

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

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

joypad.get

  • table joypad.get([int? controller = null])

  • 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

  • table joypad.getimmediate()

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

joypad.setfrommnemonicstr

  • void joypad.setfrommnemonicstr(string inputlogentry)

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

joypad.set

  • void joypad.set(table buttons, [int? controller = null])

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

joypad.setanalog

  • void joypad.setanalog(table controls, [object controller = null])

  • 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.

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

mainmemory.getname

  • string mainmemory.getname()

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

mainmemory.getcurrentmemorydomainsize

  • uint mainmemory.getcurrentmemorydomainsize()

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

mainmemory.readbyte

  • uint mainmemory.readbyte(int addr)

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

mainmemory.writebyte

  • void mainmemory.writebyte(int addr, uint value)

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

mainmemory.readbyterange

  • table mainmemory.readbyterange(int addr, int length)

  • Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the address is the key).

mainmemory.writebyterange

  • void mainmemory.writebyterange(table memoryblock)

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

mainmemory.readfloat

  • single mainmemory.readfloat(int addr, bool bigendian)

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

mainmemory.writefloat

  • void mainmemory.writefloat(int addr, double value, bool bigendian)

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

mainmemory.read_s8

  • int mainmemory.read_s8(int addr)

  • read signed byte

mainmemory.write_s8

  • void mainmemory.write_s8(int addr, uint value)

  • write signed byte

mainmemory.read_u8

  • uint mainmemory.read_u8(int addr)

  • read unsigned byte

mainmemory.write_u8

  • void mainmemory.write_u8(int addr, uint value)

  • write unsigned byte

mainmemory.read_s16_le

  • int mainmemory.read_s16_le(int addr)

  • read signed 2 byte value, little endian

mainmemory.write_s16_le

  • void mainmemory.write_s16_le(int addr, int value)

  • write signed 2 byte value, little endian

mainmemory.read_s16_be

  • int mainmemory.read_s16_be(int addr)

  • read signed 2 byte value, big endian

mainmemory.write_s16_be

  • void mainmemory.write_s16_be(int addr, int value)

  • write signed 2 byte value, big endian

mainmemory.read_u16_le

  • uint mainmemory.read_u16_le(int addr)

  • read unsigned 2 byte value, little endian

mainmemory.write_u16_le

  • void mainmemory.write_u16_le(int addr, uint value)

  • write unsigned 2 byte value, little endian

mainmemory.read_u16_be

  • uint mainmemory.read_u16_be(int addr)

  • read unsigned 2 byte value, big endian

mainmemory.write_u16_be

  • void mainmemory.write_u16_be(int addr, uint value)

  • write unsigned 2 byte value, big endian

mainmemory.read_s24_le

  • int mainmemory.read_s24_le(int addr)

  • read signed 24 bit value, little endian

mainmemory.write_s24_le

  • void mainmemory.write_s24_le(int addr, int value)

  • write signed 24 bit value, little endian

mainmemory.read_s24_be

  • int mainmemory.read_s24_be(int addr)

  • read signed 24 bit value, big endian

mainmemory.write_s24_be

  • void mainmemory.write_s24_be(int addr, int value)

  • write signed 24 bit value, big endian

mainmemory.read_u24_le

  • uint mainmemory.read_u24_le(int addr)

  • read unsigned 24 bit value, little endian

mainmemory.write_u24_le

  • void mainmemory.write_u24_le(int addr, uint value)

  • write unsigned 24 bit value, little endian

mainmemory.read_u24_be

  • uint mainmemory.read_u24_be(int addr)

  • read unsigned 24 bit value, big endian

mainmemory.write_u24_be

  • void mainmemory.write_u24_be(int addr, uint value)

  • write unsigned 24 bit value, big endian

mainmemory.read_s32_le

  • int mainmemory.read_s32_le(int addr)

  • read signed 4 byte value, little endian

mainmemory.write_s32_le

  • void mainmemory.write_s32_le(int addr, int value)

  • write signed 4 byte value, little endian

mainmemory.read_s32_be

  • int mainmemory.read_s32_be(int addr)

  • read signed 4 byte value, big endian

mainmemory.write_s32_be

  • void mainmemory.write_s32_be(int addr, int value)

  • write signed 4 byte value, big endian

mainmemory.read_u32_le

  • uint mainmemory.read_u32_le(int addr)

  • read unsigned 4 byte value, little endian

mainmemory.write_u32_le

  • void mainmemory.write_u32_le(int addr, uint value)

  • write unsigned 4 byte value, little endian

mainmemory.read_u32_be

  • uint mainmemory.read_u32_be(int addr)

  • read unsigned 4 byte value, big endian

mainmemory.write_u32_be

  • void mainmemory.write_u32_be(int addr, uint value)

  • write unsigned 4 byte value, big endian

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 main memory. 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.getmemorydomainlist

  • table 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.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.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.readbyte

  • uint memory.readbyte(int addr, [string domain = null])

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

memory.writebyte

  • void memory.writebyte(int addr, uint value, [string domain = null])

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

memory.readbyterange

  • table memory.readbyterange(int addr, int length, [string domain = null])

  • Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the address is the key).

memory.writebyterange

  • void memory.writebyterange(table memoryblock, [string domain = null])

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

memory.readfloat

  • single memory.readfloat(int addr, bool bigendian, [string domain = null])

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

memory.writefloat

  • void memory.writefloat(int addr, double value, bool bigendian, [string domain = null])

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

memory.read_s8

  • int memory.read_s8(int addr, [string domain = null])

  • read signed byte

memory.write_s8

  • void memory.write_s8(int addr, uint value, [string domain = null])

  • write signed byte

memory.read_u8

  • uint memory.read_u8(int addr, [string domain = null])

  • read unsigned byte

memory.write_u8

  • void memory.write_u8(int addr, uint value, [string domain = null])

  • write unsigned byte

memory.read_s16_le

  • int memory.read_s16_le(int addr, [string domain = null])

  • read signed 2 byte value, little endian

memory.write_s16_le

  • void memory.write_s16_le(int addr, int value, [string domain = null])

  • write signed 2 byte value, little endian

memory.read_s16_be

  • int memory.read_s16_be(int addr, [string domain = null])

  • read signed 2 byte value, big endian

memory.write_s16_be

  • void memory.write_s16_be(int addr, int value, [string domain = null])

  • write signed 2 byte value, big endian

memory.read_u16_le

  • uint memory.read_u16_le(int addr, [string domain = null])

  • read unsigned 2 byte value, little endian

memory.write_u16_le

  • void memory.write_u16_le(int addr, uint value, [string domain = null])

  • write unsigned 2 byte value, little endian

memory.read_u16_be

  • uint memory.read_u16_be(int addr, [string domain = null])

  • read unsigned 2 byte value, big endian

memory.write_u16_be

  • void memory.write_u16_be(int addr, uint value, [string domain = null])

  • write unsigned 2 byte value, big endian

memory.read_s24_le

  • int memory.read_s24_le(int addr, [string domain = null])

  • read signed 24 bit value, little endian

memory.write_s24_le

  • void memory.write_s24_le(int addr, int value, [string domain = null])

  • write signed 24 bit value, little endian

memory.read_s24_be

  • int memory.read_s24_be(int addr, [string domain = null])

  • read signed 24 bit value, big endian

memory.write_s24_be

  • void memory.write_s24_be(int addr, int value, [string domain = null])

  • write signed 24 bit value, big endian

memory.read_u24_le

  • uint memory.read_u24_le(int addr, [string domain = null])

  • read unsigned 24 bit value, little endian

memory.write_u24_le

  • void memory.write_u24_le(int addr, uint value, [string domain = null])

  • write unsigned 24 bit value, little endian

memory.read_u24_be

  • uint memory.read_u24_be(int addr, [string domain = null])

  • read unsigned 24 bit value, big endian

memory.write_u24_be

  • void memory.write_u24_be(int addr, uint value, [string domain = null])

  • write unsigned 24 bit value, big endian

memory.read_s32_le

  • int memory.read_s32_le(int addr, [string domain = null])

  • read signed 4 byte value, little endian

memory.write_s32_le

  • void memory.write_s32_le(int addr, int value, [string domain = null])

  • write signed 4 byte value, little endian

memory.read_s32_be

  • int memory.read_s32_be(int addr, [string domain = null])

  • read signed 4 byte value, big endian

memory.write_s32_be

  • void memory.write_s32_be(int addr, int value, [string domain = null])

  • write signed 4 byte value, big endian

memory.read_u32_le

  • uint memory.read_u32_le(int addr, [string domain = null])

  • read unsigned 4 byte value, little endian

memory.write_u32_le

  • void memory.write_u32_le(int addr, uint value, [string domain = null])

  • write unsigned 4 byte value, little endian

memory.read_u32_be

  • uint memory.read_u32_be(int addr, [string domain = null])

  • read unsigned 4 byte value, big endian

memory.write_u32_be

  • void memory.write_u32_be(int addr, uint value, [string domain = null])

  • write unsigned 4 byte value, big endian

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

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.clearstatesfrommemory

  • void memorysavestate.clearstatesfrommemory()

  • clears all savestates stored in memory

movie.startsfromsavestate

  • bool movie.startsfromsavestate()

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

movie.startsfromsaveram

  • bool movie.startsfromsaveram()

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

movie.filename

  • string movie.filename()

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

movie.getinput

  • table movie.getinput(int frame)

  • 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.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

  • double 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.rerecordcount

  • string movie.rerecordcount()

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(double 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.stop

  • void movie.stop()

  • Stops the current movie

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

  • table movie.getheader()

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

movie.getcomments

  • table movie.getcomments()

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

movie.getsubtitles

  • table movie.getsubtitles()

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

Functions related specifically to Nes Cores

nes.addgamegenie

  • void nes.addgamegenie(string code)

  • Adds the specified game genie code. If an NES game is not currently loaded or the code is not a valid game genie code, this will have no effect

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.removegamegenie

  • void nes.removegamegenie(string code)

  • Removes the specified game genie code. If an NES game is not currently loaded or the code is not a valid game genie code, this will have no effect

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

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

A library exposing standard .NET string methods

bizstring.hex

  • string bizstring.hex(long num)

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

bizstring.binary

  • string bizstring.binary(long num)

  • Converts the number to a string representation of the binary 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.trim

  • string bizstring.trim(string str)

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

bizstring.replace

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

  • Returns a string that replaces all occurances of str2 in str1 with the value of replace

bizstring.toupper

  • string bizstring.toupper(string str)

  • Returns an uppercase version of the given string

bizstring.tolower

  • string bizstring.tolower(string str)

  • Returns an lowercase version of the given string

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.remove

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

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

bizstring.contains

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

  • Returns whether or not str contains str2

bizstring.startswith

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

  • Returns whether str starts with str2

bizstring.endswith

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

  • Returns whether str ends wth str2

bizstring.split

  • table bizstring.split(string str, string separator)

  • Splits str based on separator into a LuaTable. Separator must be one character!. Same functionality as .NET string.Split() using the RemoveEmptyEntries option

A library for manipulating the EmuHawk client UI

client.exit

  • void client.exit()

  • Closes the emulator

client.exitCode

  • void client.exitCode(int exitcode)

  • Closes the emulator and returns the provided code

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, 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.bufferwidth

  • int client.bufferwidth()

  • Gets the visible width of 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.clearautohold

  • void client.clearautohold()

  • Clears all autohold keys

client.closerom

  • void client.closerom()

  • Closes the loaded Rom

client.enablerewind

  • void client.enablerewind(bool enabled)

  • Sets whether or not the rewind feature is enabled

client.frameskip

  • void client.frameskip(int numframes)

  • Sets the frame skip value of the client UI

client.gettargetscanlineintensity

  • int client.gettargetscanlineintensity()

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

client.getwindowsize

  • int client.getwindowsize()

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

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.SetSoundOn

  • void client.SetSoundOn(bool enable)

  • Sets the state of the Sound On toggle

client.GetSoundOn

  • bool client.GetSoundOn()

  • Gets the state of the Sound On toggle

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.ispaused

  • bool client.ispaused()

  • Returns true if emulator is paused, otherwise, false

client.opencheats

  • void client.opencheats()

  • opens the Cheats dialog

client.openhexeditor

  • void client.openhexeditor()

  • opens the Hex Editor dialog

client.openramwatch

  • void client.openramwatch()

  • opens the RAM Watch dialog

client.openramsearch

  • void client.openramsearch()

  • opens the RAM Search dialog

client.openrom

  • void client.openrom(string path)

  • opens the Open ROM dialog

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.screenheight

  • int client.screenheight()

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

client.screenshot

  • void client.screenshot([string path = null])

  • 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.settargetscanlineintensity

  • void client.settargetscanlineintensity(int val)

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

client.setscreenshotosd

  • void client.setscreenshotosd(bool value)

  • Sets the screenshot Capture OSD property of the client

client.screenwidth

  • int client.screenwidth()

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

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.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.transformPointX

  • int client.transformPointX(int x)

  • Transforms an x-coordinate in emulator space to an x-coordinate in client space

client.transformPointY

  • int client.transformPointY(int y)

  • Transforms an y-coordinate in emulator space to an y-coordinate 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

client.getavailabletools

  • table client.getavailabletools()

  • Returns a list of the tools currently open

client.gettool

  • table 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 gettools to get a list of names

client.createinstance

  • table 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

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.writeline

  • void console.writeline(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

A library for creating and managing custom dialogs

forms.addclick

  • void forms.addclick(int handle, func clickevent)

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

forms.button

  • int forms.button(int formhandle, string caption, func clickevent, [int? x = null], [int? y = null], [int? width = null], [int? height = null])

  • 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

  • int forms.checkbox(int formhandle, string caption, [int? x = null], [int? y = null])

  • 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.clearclicks

  • void forms.clearclicks(int handle)

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

forms.destroy

  • bool forms.destroy(int 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.dropdown

  • int forms.dropdown(int formhandle, table items, [int? x = null], [int? y = null], [int? width = null], [int? height = null])

  • 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.getproperty

  • string forms.getproperty(int 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(int handle)

  • Returns the text property of a given form or control

forms.ischecked

  • bool forms.ischecked(int handle)

  • Returns the given checkbox's checked property

forms.label

  • int forms.label(int formhandle, string caption, [int? x = null], [int? y = null], [int? width = null], [int? height = null], [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

  • int forms.newform([int? width = null], [int? height = null], [string title = null], [func onclose = null])

  • 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 = null], [string initialdirectory = null], [string filter = All files (*.*)|*.*])

  • 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.setlocation

  • void forms.setlocation(int 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(int 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.createcolor

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

  • Creates a color object useful with setproperty

forms.setsize

  • void forms.setsize(int handle, int width, int height)

  • TODO

forms.settext

  • void forms.settext(int handle, string caption)

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

forms.textbox

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

  • 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

gui.DrawNew

  • 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.DrawFinish

  • void gui.DrawFinish()

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

gui.addmessage

  • void gui.addmessage(string message)

  • Adds a message to the OSD's message area

gui.clearGraphics

  • void gui.clearGraphics()

  • clears all lua drawn graphics from the screen

gui.cleartext

  • void gui.cleartext()

  • clears all text created by gui.text()

gui.defaultForeground

  • void gui.defaultForeground(color color)

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

gui.defaultBackground

  • void gui.defaultBackground(color color)

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

gui.defaultTextBackground

  • void gui.defaultTextBackground(color color)

  • Sets the default backgroiund color to use in text drawing methods, half-transparent black 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.drawBezier

  • void gui.drawBezier(table points, color color)

  • 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, [color? line = null], [color? background = null])

  • 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, [color? line = null], [color? background = null])

  • 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.drawIcon

  • void gui.drawIcon(string path, int x, int y, [int? width = null], [int? height = null])

  • 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 = null], [int? height = null])

  • 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 = null], [int? dest_height = null])

  • 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, [color? color = null])

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

gui.drawAxis

  • void gui.drawAxis(int x, int y, int size, [color? color = null])

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

gui.drawPie

  • void gui.drawPie(int x, int y, int width, int height, int startangle, int sweepangle, [color? line = null], [color? background = null])

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

gui.drawPixel

  • void gui.drawPixel(int x, int y, [color? color = null])

  • 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(table points, [color? line = null], [color? background = null])

  • 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

gui.drawRectangle

  • void gui.drawRectangle(int x, int y, int width, int height, [color? line = null], [color? background = null])

  • 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, [color? forecolor = null], [color? backcolor = null], [int? fontsize = null], [string fontfamily = null], [string fontstyle = null])

  • Alias of gui.drawText()

gui.drawText

  • void gui.drawText(int x, int y, string message, [color? forecolor = null], [color? backcolor = null], [int? fontsize = null], [string fontfamily = null], [string fontstyle = null])

  • 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. Font style options are regular, bold, italic, strikethrough, underline

gui.pixelText

  • void gui.pixelText(int x, int y, string message, [color? forecolor = null], [color? backcolor = null], [string fontfamily = null])

  • 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 emulaors 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, [color? forecolor = null], [string anchor = null])

  • 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.createcanvas

  • table gui.createcanvas(int width, int height)

  • Creates a canvas of the given size.

input.get

  • table 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

  • table 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

savestate.load

  • void savestate.load(string path)

  • Loads a savestate with the given path

savestate.loadslot

  • void savestate.loadslot(int slotnum)

  • Loads the savestate at the given slot number (must be an integer between 0 and 9)

savestate.save

  • void savestate.save(string path)

  • Saves a state at the given path

savestate.saveslot

  • void savestate.saveslot(int slotnum)

  • Saves a state at the given save slot (must be an integer between 0 and 9)

A library for manipulating the Tastudio dialog of the EmuHawk client

tastudio.engaged

  • bool tastudio.engaged()

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

tastudio.setbranchtext

  • void tastudio.setbranchtext(string text, [int? index = null])

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

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.removemarker

  • void tastudio.removemarker(int frame)

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

tastudio.setmarker

  • void tastudio.setmarker(int frame, string message)

  • Adds or sets a marker at the given frame with the given message

tastudio.islag

  • bool? tastudio.islag(int frame)

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

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.hasstate

  • bool tastudio.hasstate(int frame)

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

tastudio.onqueryitembg

  • void tastudio.onqueryitembg(func luaf)

  • called during the background draw event of the tastudio listview

tastudio.onqueryitemtext

  • void tastudio.onqueryitemtext(func luaf)

  • called during the text draw event of the tastudio listview

tastudio.onqueryitemicon

  • void tastudio.onqueryitemicon(func luaf)

  • called during the icon draw event of the tastudio listview

tastudio.ongreenzoneinvalidated

  • void tastudio.ongreenzoneinvalidated(func luaf)

  • called whenever the greenzone is invalidated and returns the first frame that was invalidated



Combined RSS Feed
Bizhawk/LuaFunctions last edited by adelikat on 2016-12-02 21:36:58
Page info and history | Latest diff | List referrers | View Source