1---
2title: Script Window
3weight: 25
4chapter: false
5---
6
7<div class="imgBox"><div>
8	<img src="/images/ScriptWindow.png" />
9	<span>Script Window</span>
10</div></div>
11
12The Script Window allows [Lua](https://www.lua.org/) scripting via a [Mesen-specific API](/apireference.html). Using this API, you can interact with the emulation core to perform a variety of things (e.g: logging, drawing, implementing an AI).
13
14The code editor contains an autocomplete feature for all of Mesen's API -- typing `emu.` will display an autocomplete popup displaying all available functions.  Select a function in the list to see its parameters, return value and description.
15Multiple script windows can be opened at once to combine the effects of several scripts together.
16
17Scripts can be loaded from the disk and edited in any other text editor.  When using an external editor to modify the script, it is suggested to turn on the **<kbd>Script&rarr;Auto-reload when file changes</kbd>** option to automatically reload the script each time it is saved to the disk.
18
19To start a script, press **<kbd>F5</kbd>**.
20To stop a script, press **<kbd>Escape</kbd>** or close the script window.
21
22The Log Window at the bottom will display any Lua errors that occur while running the script.
23Additionally, any calls to `emu.log()` will also display their content in the log window.
24
25### Built-in Scripts ###
26
27A number of built-in scripts are accessible from the script window's UI. They can be accessed from the **<kbd>File&rarr;Built-in Scripts</kbd>** menu, or directly from the toolbar.
28These scripts serve as both examples for the Lua API and can also be useful in a number of ways.
29
30The scripts have (mostly) been contributed by users of Mesen (see the top of each script for proper credits) - **if you have useful/interesting scripts that you have written and would like to have included, let me know!**