porymap/docs/manual/scripting-capabilities.html
2021-12-26 12:40:26 -06:00

2302 lines
No EOL
158 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scripting Capabilities &mdash; porymap documentation</title>
<link rel="shortcut icon" href="../_static/porymap-icon-2.ico"/>
<script type="text/javascript" src="../_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/custom.css" type="text/css" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Project Files" href="project-files.html" />
<link rel="prev" title="The Region Map Editor" href="region-map-editor.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" style="background: linear-gradient(180deg, #08ACD5 50%, #FF6262 0%);" >
<a href="../index.html" class="icon icon-home"> porymap
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">User Manual</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a><ul>
<li class="toctree-l2"><a class="reference internal" href="introduction.html#about-porymap">About Porymap</a></li>
<li class="toctree-l2"><a class="reference internal" href="introduction.html#getting-started">Getting Started</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="navigation.html">Navigation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="navigation.html#map-list">Map List</a></li>
<li class="toctree-l2"><a class="reference internal" href="navigation.html#main-window">Main Window</a></li>
<li class="toctree-l2"><a class="reference internal" href="navigation.html#tileset-editor">Tileset Editor</a></li>
<li class="toctree-l2"><a class="reference internal" href="navigation.html#region-map-editor">Region Map Editor</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="editing-map-tiles.html">Editing Map Tiles</a><ul>
<li class="toctree-l2"><a class="reference internal" href="editing-map-tiles.html#visual-options">Visual Options</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-tiles.html#selecting-metatiles">Selecting Metatiles</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-tiles.html#pencil-tool">Pencil Tool</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-tiles.html#pointer-tool">Pointer Tool</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-tiles.html#bucket-fill-tool">Bucket Fill Tool</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-tiles.html#map-shift-tool">Map Shift Tool</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-tiles.html#smart-paths">Smart Paths</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-tiles.html#straight-paths">Straight Paths</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-tiles.html#change-map-border">Change Map Border</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-tiles.html#change-map-tilesets">Change Map Tilesets</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-tiles.html#undo-redo">Undo &amp; Redo</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="editing-map-collisions.html">Editing Map Collisions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="editing-map-collisions.html#selecting-collision-types">Selecting Collision Types</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-collisions.html#painting-collisions">Painting Collisions</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-collisions.html#collision-types">Collision Types</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="editing-map-events.html">Editing Map Events</a><ul>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#adding-deleting-events">Adding &amp; Deleting Events</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#event-positions">Event Positions</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#object-events">Object Events</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#warp-events">Warp Events</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#trigger-events">Trigger Events</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#weather-trigger-events">Weather Trigger Events</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#sign-event">Sign Event</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#hidden-item-event">Hidden Item Event</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#secret-base-event">Secret Base Event</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#heal-location-healspots">Heal Location / Healspots</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#open-map-scripts">Open Map Scripts</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#tool-buttons">Tool Buttons</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-events.html#ruler-tool">Ruler Tool</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="editing-map-header.html">Editing Map Headers</a></li>
<li class="toctree-l1"><a class="reference internal" href="editing-map-connections.html">Editing Map Connections</a><ul>
<li class="toctree-l2"><a class="reference internal" href="editing-map-connections.html#dive-emerge-warps">Dive &amp; Emerge Warps</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-connections.html#mirror-connections">Mirror Connections</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-map-connections.html#follow-connections">Follow Connections</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="editing-wild-encounters.html">Editing Wild Encounters</a><ul>
<li class="toctree-l2"><a class="reference internal" href="editing-wild-encounters.html#adding-new-encounter-groups">Adding New Encounter Groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="editing-wild-encounters.html#configuring-the-wild-encounter-fields">Configuring the Wild Encounter Fields</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="creating-new-maps.html">Creating New Maps</a><ul>
<li class="toctree-l2"><a class="reference internal" href="creating-new-maps.html#new-map-options">New Map Options</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="region-map-editor.html">The Region Map Editor</a><ul>
<li class="toctree-l2"><a class="reference internal" href="region-map-editor.html#background-image-tab">Background Image Tab</a></li>
<li class="toctree-l2"><a class="reference internal" href="region-map-editor.html#map-layout-tab">Map Layout Tab</a></li>
<li class="toctree-l2"><a class="reference internal" href="region-map-editor.html#map-entries-tab">Map Entries Tab</a></li>
<li class="toctree-l2"><a class="reference internal" href="region-map-editor.html#city-maps">City Maps</a></li>
</ul>
</li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Scripting Capabilities</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#writing-a-custom-script">Writing a Custom Script</a></li>
<li class="toctree-l2"><a class="reference internal" href="#registering-script-actions">Registering Script Actions</a></li>
<li class="toctree-l2"><a class="reference internal" href="#scripting-api">Scripting API</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#callbacks">Callbacks</a></li>
<li class="toctree-l3"><a class="reference internal" href="#functions">Functions</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#map-editing-functions">Map Editing Functions</a></li>
<li class="toctree-l4"><a class="reference internal" href="#map-overlay-functions">Map Overlay Functions</a></li>
<li class="toctree-l4"><a class="reference internal" href="#tileset-functions">Tileset Functions</a></li>
<li class="toctree-l4"><a class="reference internal" href="#settings-functions">Settings Functions</a></li>
<li class="toctree-l4"><a class="reference internal" href="#utility-functions">Utility Functions</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="project-files.html">Project Files</a></li>
<li class="toctree-l1"><a class="reference internal" href="shortcuts.html">Shortcuts</a><ul>
<li class="toctree-l2"><a class="reference internal" href="shortcuts.html#main-window">Main Window</a></li>
<li class="toctree-l2"><a class="reference internal" href="shortcuts.html#tileset-editor">Tileset Editor</a></li>
<li class="toctree-l2"><a class="reference internal" href="shortcuts.html#region-map-editor">Region Map Editor</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="settings-and-options.html">Porymap Settings</a></li>
</ul>
<p class="caption"><span class="caption-text">Reference</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../reference/changelog.html">Changelog</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#unreleased">Unreleased</a></li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id1">4.5.0 - 2021-12-26</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#added">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#changed">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#fixed">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id2">4.4.0 - 2020-12-20</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id3">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id4">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id5">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id6">4.3.1 - 2020-07-17</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id7">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id8">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id9">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id10">4.3.0 - 2020-06-27</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id11">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id12">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id13">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id14">4.2.0 - 2020-06-06</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id15">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id16">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id17">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id18">4.1.0 - 2020-05-18</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id19">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id20">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id21">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id22">4.0.0 - 2020-04-28</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#breaking-changes">Breaking Changes</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id23">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id24">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id25">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id26">3.0.1 - 2020-03-04</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id27">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id28">3.0.0 - 2020-03-04</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id29">Breaking Changes</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id30">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id31">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id32">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id33">2.0.0 - 2019-10-16</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id34">Breaking Changes</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id35">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id36">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id37">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id38">1.2.2 - 2019-05-16</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id39">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id40">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id41">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id42">1.2.1 - 2019-02-16</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id43">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id44">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id45">1.2.0 - 2019-02-04</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id46">Breaking Changes</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id47">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id48">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id49">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id50">1.1.0 - 2018-12-27</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id51">Breaking Changes</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id52">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id53">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id54">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id55">1.0.0 - 2018-10-26</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../reference/related-projects.html">Related Projects</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">porymap</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> &raquo;</li>
<li>Scripting Capabilities</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/huderlem/porymap/blob/master/docsrc/manual/scripting-capabilities.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="scripting-capabilities">
<h1>Scripting Capabilities<a class="headerlink" href="#scripting-capabilities" title="Permalink to this headline"></a></h1>
<p>Porymap is extensible via scripting capabilities. This allows the user to write custom JavaScript (technically, ECMAScript) files to support enhanced workflows, without having to fork Porymap itself. While the possibilities are endless, some useful examples of scripting might be:</p>
<ul class="simple">
<li><p>Toggle Day/Night Palettes</p></li>
<li><p>Custom Map Painting Brushes</p></li>
<li><p>Detect Tile Errors</p></li>
<li><p>Show Diagonistic Information</p></li>
<li><p>Procedurally Generated Maps</p></li>
<li><p>Randomize Grass Patterns</p></li>
</ul>
<div class="section" id="writing-a-custom-script">
<h2>Writing a Custom Script<a class="headerlink" href="#writing-a-custom-script" title="Permalink to this headline"></a></h2>
<p>Lets write a custom script that will randomize grass patterns when the user is editing the map. This is useful, since its cumbersome to manually add randomness to grass patches. With the custom script, it will happen automatically. Whenever the user paints a grass tile onto the map, the script will overwrite the tile with a random grass tile instead.</p>
<p>First, create a new script file called <code class="docutils literal notranslate"><span class="pre">my_script.js</span></code>place it in the project directory (e.g. <code class="docutils literal notranslate"><span class="pre">pokefirered/</span></code>).</p>
<p>Next, open the Porymap project config file, <code class="docutils literal notranslate"><span class="pre">porymap.project.cfg</span></code>, in the project directory. Add the script file to the <code class="docutils literal notranslate"><span class="pre">custom_scripts</span></code> configuration value. Multiple script files can be loaded by separating the filepaths with a comma.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">custom_scripts</span><span class="o">=</span><span class="n">my_script</span><span class="o">.</span><span class="n">js</span>
</pre></div>
</div>
<p>Now that Porymap is configured to load the script file, lets write the actual code that will power the grass-randomizer. Scripts have access to several “callbacks” for events that occur while Porymap is running. This means our script can define functions for each of these callbacks. Were interested in the <code class="docutils literal notranslate"><span class="pre">onBlockChanged()</span></code> callback, since we want our script to take action whenever a user paints a block on the map.</p>
<div class="highlight-js notranslate"><div class="highlight"><pre><span></span><span class="c1">// Porymap callback when a block is painted.</span>
<span class="kr">export</span> <span class="kd">function</span> <span class="nx">onBlockChanged</span><span class="p">(</span><span class="nx">x</span><span class="p">,</span> <span class="nx">y</span><span class="p">,</span> <span class="nx">prevBlock</span><span class="p">,</span> <span class="nx">newBlock</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Grass-randomizing logic goes here.</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Its very <strong>important</strong> to remember to <code class="docutils literal notranslate"><span class="pre">export</span></code> the callback functions in the script. Otherwise, Porymap will not be able to execute them.</p>
<p>In addition to the callbacks, Porymap also supports a scripting API so that the script can interact with Porymap in interesting ways. For example, a script can change a block or add overlay text on the map. Since we want to paint random grass tiles, well be using the <code class="docutils literal notranslate"><span class="pre">map.setMetatileId()</span></code> function. Lets fill in the rest of the grass-randomizing code.</p>
<div class="highlight-js notranslate"><div class="highlight"><pre><span></span><span class="kd">function</span> <span class="nx">randInt</span><span class="p">(</span><span class="nx">min</span><span class="p">,</span> <span class="nx">max</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">min</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">ceil</span><span class="p">(</span><span class="nx">min</span><span class="p">);</span>
<span class="nx">max</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">(</span><span class="nx">max</span><span class="p">);</span>
<span class="k">return</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span> <span class="o">*</span> <span class="p">(</span><span class="nx">max</span> <span class="o">-</span> <span class="nx">min</span><span class="p">))</span> <span class="o">+</span> <span class="nx">min</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">// These are the grass metatiles in pokefirered.</span>
<span class="kr">const</span> <span class="nx">grassTiles</span> <span class="o">=</span> <span class="p">[</span><span class="mh">0x8</span><span class="p">,</span> <span class="mh">0x9</span><span class="p">,</span> <span class="mh">0x10</span><span class="p">,</span> <span class="mh">0x11</span><span class="p">];</span>
<span class="c1">// Porymap callback when a block is painted.</span>
<span class="kr">export</span> <span class="kd">function</span> <span class="nx">onBlockChanged</span><span class="p">(</span><span class="nx">x</span><span class="p">,</span> <span class="nx">y</span><span class="p">,</span> <span class="nx">prevBlock</span><span class="p">,</span> <span class="nx">newBlock</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Check if the user is painting a grass tile.</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">grassTiles</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">newBlock</span><span class="p">.</span><span class="nx">metatileId</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Choose a random grass tile and paint it on the map.</span>
<span class="kr">const</span> <span class="nx">i</span> <span class="o">=</span> <span class="nx">randInt</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nx">grassTiles</span><span class="p">.</span><span class="nx">length</span><span class="p">);</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">setMetatileId</span><span class="p">(</span><span class="nx">x</span><span class="p">,</span> <span class="nx">y</span><span class="p">,</span> <span class="nx">grassTiles</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Lets test the script out by re-launching Porymap. If we try to paint grass on the map, we should see our script inserting a nice randomized grass pattern.</p>
<div class="figure align-default" id="id3">
<img alt="Grass-Randomizing Script" src="../_images/porymap-scripting-grass.gif" />
<p class="caption"><span class="caption-text">Grass-Randomizing Script</span><a class="headerlink" href="#id3" title="Permalink to this image"></a></p>
</div>
</div>
<div class="section" id="registering-script-actions">
<h2>Registering Script Actions<a class="headerlink" href="#registering-script-actions" title="Permalink to this headline"></a></h2>
<p>The grass-randomizer script above happens implicitly when the user paints on the map. However, other times we probably want to call the custom script on demand. One of the API functions Porymap provides is the ability to trigger scripting functions from the <code class="docutils literal notranslate"><span class="pre">Tools</span></code> menu, or a keyboard shortcut. To do this, we will usually want to register the action when the project loads. Here is an example script where some custom actions are registered.</p>
<div class="highlight-js notranslate"><div class="highlight"><pre><span></span><span class="kr">export</span> <span class="kd">function</span> <span class="nx">applyNightTint</span><span class="p">()</span> <span class="p">{</span>
<span class="c1">// Apply night palette tinting...</span>
<span class="p">}</span>
<span class="c1">// Porymap callback when project is opened.</span>
<span class="kr">export</span> <span class="kd">function</span> <span class="nx">onProjectOpened</span><span class="p">(</span><span class="nx">projectPath</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">registerAction</span><span class="p">(</span><span class="s2">&quot;applyNightTint&quot;</span><span class="p">,</span> <span class="s2">&quot;View Night Tint&quot;</span><span class="p">,</span> <span class="s2">&quot;T&quot;</span><span class="p">)</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Then, to trigger the <code class="docutils literal notranslate"><span class="pre">applyNightTint()</span></code> function, we could either click <code class="docutils literal notranslate"><span class="pre">Tools</span> <span class="pre">-&gt;</span> <span class="pre">View</span> <span class="pre">Night</span> <span class="pre">Tint</span></code> or use the <code class="docutils literal notranslate"><span class="pre">T</span></code> keyboard shortcut.</p>
<p>Now that we have an overview of how to utilize Porymaps scripting capabilities, the entire scripting API is documented below.</p>
</div>
<div class="section" id="scripting-api">
<h2>Scripting API<a class="headerlink" href="#scripting-api" title="Permalink to this headline"></a></h2>
<div class="section" id="callbacks">
<h3>Callbacks<a class="headerlink" href="#callbacks" title="Permalink to this headline"></a></h3>
<dl class="js function">
<dt id="onProjectOpened">
<code class="sig-name descname">onProjectOpened</code><span class="sig-paren">(</span><em class="sig-param">projectPath</em><span class="sig-paren">)</span><a class="headerlink" href="#onProjectOpened" title="Permalink to this definition"></a></dt>
<dd><p>Called when Porymap successfully opens a project.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>projectPath</strong> (<em>string</em>) the directory path of the opened project</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="onProjectClosed">
<code class="sig-name descname">onProjectClosed</code><span class="sig-paren">(</span><em class="sig-param">projectPath</em><span class="sig-paren">)</span><a class="headerlink" href="#onProjectClosed" title="Permalink to this definition"></a></dt>
<dd><p>Called when Porymap closes a project. For example, this is called when opening a different project.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>projectPath</strong> (<em>string</em>) the directory path of the closed project</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="onMapOpened">
<code class="sig-name descname">onMapOpened</code><span class="sig-paren">(</span><em class="sig-param">mapName</em><span class="sig-paren">)</span><a class="headerlink" href="#onMapOpened" title="Permalink to this definition"></a></dt>
<dd><p>Called when a map is opened.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>mapName</strong> (<em>string</em>) the name of the opened map</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="onBlockChanged">
<code class="sig-name descname">onBlockChanged</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">prevBlock</em>, <em class="sig-param">newBlock</em><span class="sig-paren">)</span><a class="headerlink" href="#onBlockChanged" title="Permalink to this definition"></a></dt>
<dd><p>Called when a block is changed on the map. For example, this is called when a user paints a new tile or changes the collision property of a block.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) x coordinate of the block</p></li>
<li><p><strong>y</strong> (<em>number</em>) y coordinate of the block</p></li>
<li><p><strong>prevBlock</strong> (<em>object</em>) the blocks state before it was modified. The objects shape is <code class="docutils literal notranslate"><span class="pre">{metatileId,</span> <span class="pre">collision,</span> <span class="pre">elevation,</span> <span class="pre">rawValue}</span></code></p></li>
<li><p><strong>newBlock</strong> (<em>object</em>) the blocks new state after it was modified. The objects shape is <code class="docutils literal notranslate"><span class="pre">{metatileId,</span> <span class="pre">collision,</span> <span class="pre">elevation,</span> <span class="pre">rawValue}</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="onBlockHoverChanged">
<code class="sig-name descname">onBlockHoverChanged</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em><span class="sig-paren">)</span><a class="headerlink" href="#onBlockHoverChanged" title="Permalink to this definition"></a></dt>
<dd><p>Called when the mouse enters a new map block.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) x coordinate of the block</p></li>
<li><p><strong>y</strong> (<em>number</em>) y coordinate of the block</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="onBlockHoverCleared">
<code class="sig-name descname">onBlockHoverCleared</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#onBlockHoverCleared" title="Permalink to this definition"></a></dt>
<dd><p>Called when the mouse exits the map.</p>
</dd></dl>
<dl class="js function">
<dt id="onMapResized">
<code class="sig-name descname">onMapResized</code><span class="sig-paren">(</span><em class="sig-param">oldWidth</em>, <em class="sig-param">oldHeight</em>, <em class="sig-param">newWidth</em>, <em class="sig-param">newHeight</em><span class="sig-paren">)</span><a class="headerlink" href="#onMapResized" title="Permalink to this definition"></a></dt>
<dd><p>Called when the dimensions of the map are changed.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>oldWidth</strong> (<em>number</em>) the width of the map before the change</p></li>
<li><p><strong>oldHeight</strong> (<em>number</em>) the height of the map before the change</p></li>
<li><p><strong>newWidth</strong> (<em>number</em>) the width of the map after the change</p></li>
<li><p><strong>newHeight</strong> (<em>number</em>) the height of the map after the change</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="onMapShifted">
<code class="sig-name descname">onMapShifted</code><span class="sig-paren">(</span><em class="sig-param">xDelta</em>, <em class="sig-param">yDelta</em><span class="sig-paren">)</span><a class="headerlink" href="#onMapShifted" title="Permalink to this definition"></a></dt>
<dd><p>Called when the map is updated by use of the Map Shift tool.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>xDelta</strong> (<em>number</em>) the horizontal change from the shift</p></li>
<li><p><strong>yDelta</strong> (<em>number</em>) the vertical change from the shift</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="onTilesetUpdated">
<code class="sig-name descname">onTilesetUpdated</code><span class="sig-paren">(</span><em class="sig-param">tilesetName</em><span class="sig-paren">)</span><a class="headerlink" href="#onTilesetUpdated" title="Permalink to this definition"></a></dt>
<dd><p>Called when the currently loaded tileset is changed by switching to a new one or by saving changes to it in the Tileset Editor.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tilesetName</strong> (<em>string</em>) the name of the updated tileset</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="onMainTabChanged">
<code class="sig-name descname">onMainTabChanged</code><span class="sig-paren">(</span><em class="sig-param">oldTab</em>, <em class="sig-param">newTab</em><span class="sig-paren">)</span><a class="headerlink" href="#onMainTabChanged" title="Permalink to this definition"></a></dt>
<dd><p>Called when the selected tab in the main tab bar is changed. Tabs are indexed from left to right, starting at 0 (<code class="docutils literal notranslate"><span class="pre">0</span></code>: Map, <code class="docutils literal notranslate"><span class="pre">1</span></code>: Events, <code class="docutils literal notranslate"><span class="pre">2</span></code>: Header, <code class="docutils literal notranslate"><span class="pre">3</span></code>: Connections, <code class="docutils literal notranslate"><span class="pre">4</span></code>: Wild Pokemon).</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>oldTab</strong> (<em>number</em>) the index of the previously selected tab</p></li>
<li><p><strong>newTab</strong> (<em>number</em>) the index of the newly selected tab</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="onMapViewTabChanged">
<code class="sig-name descname">onMapViewTabChanged</code><span class="sig-paren">(</span><em class="sig-param">oldTab</em>, <em class="sig-param">newTab</em><span class="sig-paren">)</span><a class="headerlink" href="#onMapViewTabChanged" title="Permalink to this definition"></a></dt>
<dd><p>Called when the selected tab in the map view tab bar is changed. Tabs are indexed from left to right, starting at 0 (<code class="docutils literal notranslate"><span class="pre">0</span></code>: Metatiles, <code class="docutils literal notranslate"><span class="pre">1</span></code>: Collision).</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>oldTab</strong> (<em>number</em>) the index of the previously selected tab</p></li>
<li><p><strong>newTab</strong> (<em>number</em>) the index of the newly selected tab</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="functions">
<h3>Functions<a class="headerlink" href="#functions" title="Permalink to this headline"></a></h3>
<p>All scripting functions are callable via the global <code class="docutils literal notranslate"><span class="pre">map</span></code> object.</p>
<div class="section" id="map-editing-functions">
<h4>Map Editing Functions<a class="headerlink" href="#map-editing-functions" title="Permalink to this headline"></a></h4>
<p>The following functions are related to editing the maps blocks or retrieving information about them.</p>
<dl class="js function">
<dt id="map.getBlock">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getBlock</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getBlock" title="Permalink to this definition"></a></dt>
<dd><p>Gets a block in the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) x coordinate of the block</p></li>
<li><p><strong>y</strong> (<em>number</em>) y coordinate of the block</p></li>
</ul>
</dd>
<dt class="field-even">Returns {metatileId, collision, elevation, rawValue}</dt>
<dd class="field-even"><p>the block object</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setBlock">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setBlock</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">metatileId</em>, <em class="sig-param">collision</em>, <em class="sig-param">elevation</em>, <em class="sig-param">forceRedraw = true</em>, <em class="sig-param">commitChanges = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setBlock" title="Permalink to this definition"></a></dt>
<dd><p>Sets a block in the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) x coordinate of the block</p></li>
<li><p><strong>y</strong> (<em>number</em>) y coordinate of the block</p></li>
<li><p><strong>metatileId</strong> (<em>number</em>) the metatile id of the block</p></li>
<li><p><strong>collision</strong> (<em>number</em>) the collision of the block (<code class="docutils literal notranslate"><span class="pre">0</span></code> = passable, <code class="docutils literal notranslate"><span class="pre">1</span></code> = impassable)</p></li>
<li><p><strong>elevation</strong> (<em>number</em>) the elevation of the block</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) Commit the changes to the maps edit/undo history. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. When making many related map edits, it can be useful to set this to <code class="docutils literal notranslate"><span class="pre">false</span></code>, and then commit all of them together with <code class="docutils literal notranslate"><span class="pre">map.commit()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileId">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileId</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileId" title="Permalink to this definition"></a></dt>
<dd><p>Gets the metatile id of a block in the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) x coordinate of the block</p></li>
<li><p><strong>y</strong> (<em>number</em>) y coordinate of the block</p></li>
</ul>
</dd>
<dt class="field-even">Returns number</dt>
<dd class="field-even"><p>the metatile id of the block</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMetatileId">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileId</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">metatileId</em>, <em class="sig-param">forceRedraw = true</em>, <em class="sig-param">commitChanges = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMetatileId" title="Permalink to this definition"></a></dt>
<dd><p>Sets the metatile id of a block in the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) x coordinate of the block</p></li>
<li><p><strong>y</strong> (<em>number</em>) y coordinate of the block</p></li>
<li><p><strong>metatileId</strong> (<em>number</em>) the metatile id of the block</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) Commit the changes to the maps edit/undo history. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. When making many related map edits, it can be useful to set this to <code class="docutils literal notranslate"><span class="pre">false</span></code>, and then commit all of them together with <code class="docutils literal notranslate"><span class="pre">map.commit()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getCollision">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getCollision</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getCollision" title="Permalink to this definition"></a></dt>
<dd><p>Gets the collision of a block in the currently-opened map. (<code class="docutils literal notranslate"><span class="pre">0</span></code> = passable, <code class="docutils literal notranslate"><span class="pre">1</span></code> = impassable)</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) x coordinate of the block</p></li>
<li><p><strong>y</strong> (<em>number</em>) y coordinate of the block</p></li>
</ul>
</dd>
<dt class="field-even">Returns number</dt>
<dd class="field-even"><p>the collision of the block</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setCollision">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setCollision</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">collision</em>, <em class="sig-param">forceRedraw = true</em>, <em class="sig-param">commitChanges = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setCollision" title="Permalink to this definition"></a></dt>
<dd><p>Sets the collision of a block in the currently-opened map. (<code class="docutils literal notranslate"><span class="pre">0</span></code> = passable, <code class="docutils literal notranslate"><span class="pre">1</span></code> = impassable)</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) x coordinate of the block</p></li>
<li><p><strong>y</strong> (<em>number</em>) y coordinate of the block</p></li>
<li><p><strong>collision</strong> (<em>number</em>) the collision of the block</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) Commit the changes to the maps edit/undo history. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. When making many related map edits, it can be useful to set this to <code class="docutils literal notranslate"><span class="pre">false</span></code>, and then commit all of them together with <code class="docutils literal notranslate"><span class="pre">map.commit()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getElevation">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getElevation</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getElevation" title="Permalink to this definition"></a></dt>
<dd><p>Gets the elevation of a block in the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) x coordinate of the block</p></li>
<li><p><strong>y</strong> (<em>number</em>) y coordinate of the block</p></li>
</ul>
</dd>
<dt class="field-even">Returns number</dt>
<dd class="field-even"><p>the elevation of the block</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setElevation">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setElevation</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">elevation</em>, <em class="sig-param">forceRedraw = true</em>, <em class="sig-param">commitChanges = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setElevation" title="Permalink to this definition"></a></dt>
<dd><p>Sets the elevation of a block in the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) x coordinate of the block</p></li>
<li><p><strong>y</strong> (<em>number</em>) y coordinate of the block</p></li>
<li><p><strong>elevation</strong> (<em>number</em>) the elevation of the block</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) Commit the changes to the maps edit/undo history. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. When making many related map edits, it can be useful to set this to <code class="docutils literal notranslate"><span class="pre">false</span></code>, and then commit all of them together with <code class="docutils literal notranslate"><span class="pre">map.commit()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setBlocksFromSelection">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setBlocksFromSelection</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">forceRedraw = true</em>, <em class="sig-param">commitChanges = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setBlocksFromSelection" title="Permalink to this definition"></a></dt>
<dd><p>Sets blocks on the map using the users current metatile selection.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) initial x coordinate</p></li>
<li><p><strong>y</strong> (<em>number</em>) initial y coordinate</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) Commit the changes to the maps edit/undo history. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. When making many related map edits, it can be useful to set this to <code class="docutils literal notranslate"><span class="pre">false</span></code>, and then commit all of them together with <code class="docutils literal notranslate"><span class="pre">map.commit()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.bucketFill">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">bucketFill</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">metatileId</em>, <em class="sig-param">forceRedraw = true</em>, <em class="sig-param">commitChanges = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.bucketFill" title="Permalink to this definition"></a></dt>
<dd><p>Performs a bucket fill of a metatile id, starting at the given coordinates.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) initial x coordinate</p></li>
<li><p><strong>y</strong> (<em>number</em>) initial y coordinate</p></li>
<li><p><strong>metatileId</strong> (<em>number</em>) metatile id to fill</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) Commit the changes to the maps edit/undo history. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. When making many related map edits, it can be useful to set this to <code class="docutils literal notranslate"><span class="pre">false</span></code>, and then commit all of them together with <code class="docutils literal notranslate"><span class="pre">map.commit()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.bucketFillFromSelection">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">bucketFillFromSelection</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">forceRedraw = true</em>, <em class="sig-param">commitChanges = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.bucketFillFromSelection" title="Permalink to this definition"></a></dt>
<dd><p>Performs a bucket fill using the users current metatile selection, starting at the given coordinates.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) initial x coordinate</p></li>
<li><p><strong>y</strong> (<em>number</em>) initial y coordinate</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) Commit the changes to the maps edit/undo history. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. When making many related map edits, it can be useful to set this to <code class="docutils literal notranslate"><span class="pre">false</span></code>, and then commit all of them together with <code class="docutils literal notranslate"><span class="pre">map.commit()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.magicFill">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">magicFill</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">metatileId</em>, <em class="sig-param">forceRedraw = true</em>, <em class="sig-param">commitChanges = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.magicFill" title="Permalink to this definition"></a></dt>
<dd><p>Performs a magic fill of a metatile id, starting at the given coordinates.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) initial x coordinate</p></li>
<li><p><strong>y</strong> (<em>number</em>) initial y coordinate</p></li>
<li><p><strong>metatileId</strong> (<em>number</em>) metatile id to magic fill</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) Commit the changes to the maps edit/undo history. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. When making many related map edits, it can be useful to set this to <code class="docutils literal notranslate"><span class="pre">false</span></code>, and then commit all of them together with <code class="docutils literal notranslate"><span class="pre">map.commit()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.magicFillFromSelection">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">magicFillFromSelection</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">forceRedraw = true</em>, <em class="sig-param">commitChanges = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.magicFillFromSelection" title="Permalink to this definition"></a></dt>
<dd><p>Performs a magic fill using the users current metatile selection, starting at the given coordinates.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) initial x coordinate</p></li>
<li><p><strong>y</strong> (<em>number</em>) initial y coordinate</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) Commit the changes to the maps edit/undo history. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. When making many related map edits, it can be useful to set this to <code class="docutils literal notranslate"><span class="pre">false</span></code>, and then commit all of them together with <code class="docutils literal notranslate"><span class="pre">map.commit()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.shift">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">shift</code><span class="sig-paren">(</span><em class="sig-param">xDelta</em>, <em class="sig-param">yDelta</em>, <em class="sig-param">forceRedraw = true</em>, <em class="sig-param">commitChanges = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.shift" title="Permalink to this definition"></a></dt>
<dd><p>Performs a shift on the maps blocks.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>xDelta</strong> (<em>number</em>) number of blocks to shift horizontally</p></li>
<li><p><strong>yDelta</strong> (<em>number</em>) number of blocks to shift vertically</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) Commit the changes to the maps edit/undo history. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. When making many related map edits, it can be useful to set this to <code class="docutils literal notranslate"><span class="pre">false</span></code>, and then commit all of them together with <code class="docutils literal notranslate"><span class="pre">map.commit()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getDimensions">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getDimensions</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getDimensions" title="Permalink to this definition"></a></dt>
<dd><p>Gets the dimensions of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns {width, height}</dt>
<dd class="field-odd"><p>the dimensions of the map</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getWidth">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getWidth</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getWidth" title="Permalink to this definition"></a></dt>
<dd><p>Gets the width of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>the width of the map</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getHeight">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getHeight</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getHeight" title="Permalink to this definition"></a></dt>
<dd><p>Gets the height of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>the height of the map</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setDimensions">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setDimensions</code><span class="sig-paren">(</span><em class="sig-param">width</em>, <em class="sig-param">height</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setDimensions" title="Permalink to this definition"></a></dt>
<dd><p>Sets the dimensions of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>width</strong> (<em>number</em>) width in blocks</p></li>
<li><p><strong>height</strong> (<em>number</em>) height in blocks</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setWidth">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setWidth</code><span class="sig-paren">(</span><em class="sig-param">width</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setWidth" title="Permalink to this definition"></a></dt>
<dd><p>Sets the width of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>width</strong> (<em>number</em>) width in blocks</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setHeight">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setHeight</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.setHeight" title="Permalink to this definition"></a></dt>
<dd><p>Sets the height of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>height</strong> (<em>number</em>) height in blocks</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.redraw">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">redraw</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.redraw" title="Permalink to this definition"></a></dt>
<dd><p>Redraws the entire map area. Useful when delaying map redraws using <code class="docutils literal notranslate"><span class="pre">forceRedraw</span> <span class="pre">=</span> <span class="pre">false</span></code> in certain map editing functions.</p>
</dd></dl>
<dl class="js function">
<dt id="map.commit">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">commit</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.commit" title="Permalink to this definition"></a></dt>
<dd><p>Commits any uncommitted changes to the maps edit/undo history. Useful when delaying commits using <code class="docutils literal notranslate"><span class="pre">commitChanges</span> <span class="pre">=</span> <span class="pre">false</span></code> in certain map editing functions.</p>
</dd></dl>
</div>
<div class="section" id="map-overlay-functions">
<h4>Map Overlay Functions<a class="headerlink" href="#map-overlay-functions" title="Permalink to this headline"></a></h4>
<p>The following functions are related to an overlay that is drawn on top of the map area. Text, images, and shapes can be drawn using these functions. Items can be drawn and manipulated on separate layers by specifiying a layer id. Items on higher layer ids will be drawn above those on lower layers. If no layer is specified they will be added to the default layer <code class="docutils literal notranslate"><span class="pre">0</span></code>. The visibility and position of each layer can be changed; by default all layers are visible, and their position is <code class="docutils literal notranslate"><span class="pre">0,0</span></code>.</p>
<dl class="js function">
<dt id="map.clearOverlay">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">clearOverlay</code><span class="sig-paren">(</span><em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.clearOverlay" title="Permalink to this definition"></a></dt>
<dd><p>Clears and erases all overlay items on the specified layer that were previously-added to the map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.clearOverlays">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">clearOverlays</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.clearOverlays" title="Permalink to this definition"></a></dt>
<dd><p>Clears and erases all overlay items that were previously-added to the map.</p>
</dd></dl>
<dl class="js function">
<dt id="map.hideOverlay">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">hideOverlay</code><span class="sig-paren">(</span><em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.hideOverlay" title="Permalink to this definition"></a></dt>
<dd><p>Hides all overlay items on the specified layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.hideOverlays">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">hideOverlays</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.hideOverlays" title="Permalink to this definition"></a></dt>
<dd><p>Hides all overlay items on all active layers.</p>
</dd></dl>
<dl class="js function">
<dt id="map.showOverlay">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">showOverlay</code><span class="sig-paren">(</span><em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.showOverlay" title="Permalink to this definition"></a></dt>
<dd><p>Shows all overlay items on the specified layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.showOverlays">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">showOverlays</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.showOverlays" title="Permalink to this definition"></a></dt>
<dd><p>Shows all overlay items on all active layers.</p>
</dd></dl>
<dl class="js function">
<dt id="map.getOverlayVisibility">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getOverlayVisibility</code><span class="sig-paren">(</span><em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getOverlayVisibility" title="Permalink to this definition"></a></dt>
<dd><p>Gets whether the specified overlay layer is currently showing or not.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
<dt class="field-even">Returns boolean</dt>
<dd class="field-even"><p>whether the layer is showing</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setOverlayVisibility">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setOverlayVisibility</code><span class="sig-paren">(</span><em class="sig-param">visible</em>, <em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setOverlayVisibility" title="Permalink to this definition"></a></dt>
<dd><p>Sets the visibility of the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>visible</strong> (<em>boolean</em>) whether the layer should be showing</p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setOverlaysVisibility">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setOverlaysVisibility</code><span class="sig-paren">(</span><em class="sig-param">visible</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setOverlaysVisibility" title="Permalink to this definition"></a></dt>
<dd><p>Sets the visibility of all active overlay layers.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>visible</strong> (<em>boolean</em>) whether the layers should be showing</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getOverlayX">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getOverlayX</code><span class="sig-paren">(</span><em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getOverlayX" title="Permalink to this definition"></a></dt>
<dd><p>Gets the x position of the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
<dt class="field-even">Returns number</dt>
<dd class="field-even"><p>the pixel x coordinate</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getOverlayY">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getOverlayY</code><span class="sig-paren">(</span><em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getOverlayY" title="Permalink to this definition"></a></dt>
<dd><p>Gets the y position of the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
<dt class="field-even">Returns number</dt>
<dd class="field-even"><p>the pixel y coordinate</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setOverlayX">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setOverlayX</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setOverlayX" title="Permalink to this definition"></a></dt>
<dd><p>Sets the x position of the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) the pixel x coordinate</p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setOverlayY">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setOverlayY</code><span class="sig-paren">(</span><em class="sig-param">y</em>, <em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setOverlayY" title="Permalink to this definition"></a></dt>
<dd><p>Sets the y position of the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>y</strong> (<em>number</em>) the pixel y coordinate</p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setOverlaysX">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setOverlaysX</code><span class="sig-paren">(</span><em class="sig-param">x</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setOverlaysX" title="Permalink to this definition"></a></dt>
<dd><p>Sets the x position of all active overlay layers.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) the pixel x coordinate</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setOverlaysY">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setOverlaysY</code><span class="sig-paren">(</span><em class="sig-param">y</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setOverlaysY" title="Permalink to this definition"></a></dt>
<dd><p>Sets the y position of all active overlay layers.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>y</strong> (<em>number</em>) the pixel y coordinate</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getOverlayPosition">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getOverlayPosition</code><span class="sig-paren">(</span><em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getOverlayPosition" title="Permalink to this definition"></a></dt>
<dd><p>Gets the position of the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
<dt class="field-even">Returns {x, y}</dt>
<dd class="field-even"><p>the layers pixel coordinates</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setOverlayPosition">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setOverlayPosition</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setOverlayPosition" title="Permalink to this definition"></a></dt>
<dd><p>Sets the position of the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) the pixel x coordinate</p></li>
<li><p><strong>y</strong> (<em>number</em>) the pixel y coordinate</p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setOverlaysPosition">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setOverlaysPosition</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setOverlaysPosition" title="Permalink to this definition"></a></dt>
<dd><p>Sets the position of all active overlay layers.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) the pixel x coordinate</p></li>
<li><p><strong>y</strong> (<em>number</em>) the pixel y coordinate</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.moveOverlay">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">moveOverlay</code><span class="sig-paren">(</span><em class="sig-param">deltaX</em>, <em class="sig-param">deltaY</em>, <em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.moveOverlay" title="Permalink to this definition"></a></dt>
<dd><p>Moves the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>deltaX</strong> (<em>number</em>) the number of pixels to move horizontally</p></li>
<li><p><strong>deltaY</strong> (<em>number</em>) the number of pixels to move vertically</p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.moveOverlays">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">moveOverlays</code><span class="sig-paren">(</span><em class="sig-param">deltaX</em>, <em class="sig-param">deltaY</em><span class="sig-paren">)</span><a class="headerlink" href="#map.moveOverlays" title="Permalink to this definition"></a></dt>
<dd><p>Moves all active overlay layers.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>deltaX</strong> (<em>number</em>) the number of pixels to move horizontally</p></li>
<li><p><strong>deltaY</strong> (<em>number</em>) the number of pixels to move vertically</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.addText">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">addText</code><span class="sig-paren">(</span><em class="sig-param">text</em>, <em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">color = &quot;#000000&quot;</em>, <em class="sig-param">size = 12</em>, <em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.addText" title="Permalink to this definition"></a></dt>
<dd><p>Adds a text item to the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>text</strong> (<em>string</em>) the text to display</p></li>
<li><p><strong>x</strong> (<em>number</em>) the x pixel coordinate of the text (relative to the layers position)</p></li>
<li><p><strong>y</strong> (<em>number</em>) the y pixel coordinate of the text (relative to the layers position)</p></li>
<li><p><strong>color</strong> (<em>string</em>) the color of the text. Can be specified as “#RRGGBB” or “#AARRGGBB”. Defaults to black.</p></li>
<li><p><strong>size</strong> (<em>number</em>) the font size of the text. Defaults to 12.</p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.addRect">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">addRect</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">width</em>, <em class="sig-param">height</em>, <em class="sig-param">color = &quot;#000000&quot;</em>, <em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.addRect" title="Permalink to this definition"></a></dt>
<dd><p>Adds a rectangle outline item to the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) the x pixel coordinate of the rectangles top-left corner (relative to the layers position)</p></li>
<li><p><strong>y</strong> (<em>number</em>) the y pixel coordinate of the rectangles top-left corner (relative to the layers position)</p></li>
<li><p><strong>width</strong> (<em>number</em>) the pixel width of the rectangle</p></li>
<li><p><strong>height</strong> (<em>number</em>) the pixel height of the rectangle</p></li>
<li><p><strong>color</strong> (<em>string</em>) the color of the rectangle. Can be specified as “#RRGGBB” or “#AARRGGBB”. Defaults to black.</p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.addFilledRect">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">addFilledRect</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">width</em>, <em class="sig-param">height</em>, <em class="sig-param">color = &quot;#000000&quot;</em>, <em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.addFilledRect" title="Permalink to this definition"></a></dt>
<dd><p>Adds a filled rectangle item to the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) the x pixel coordinate of the rectangles top-left corner (relative to the layers position)</p></li>
<li><p><strong>y</strong> (<em>number</em>) the y pixel coordinate of the rectangles top-left corner (relative to the layers position)</p></li>
<li><p><strong>width</strong> (<em>number</em>) the pixel width of the rectangle</p></li>
<li><p><strong>height</strong> (<em>number</em>) the pixel height of the rectangle</p></li>
<li><p><strong>color</strong> (<em>string</em>) the color of the rectangle. Can be specified as “#RRGGBB” or “#AARRGGBB”. Defaults to black.</p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.addImage">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">addImage</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">filepath</em>, <em class="sig-param">layer = 0</em>, <em class="sig-param">useCache = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.addImage" title="Permalink to this definition"></a></dt>
<dd><p>Adds an image item to the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) the x pixel coordinate of the images top-left corner (relative to the layers position)</p></li>
<li><p><strong>y</strong> (<em>number</em>) the y pixel coordinate of the images top-left corner (relative to the layers position)</p></li>
<li><p><strong>filepath</strong> (<em>string</em>) the images filepath</p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
<li><p><strong>useCache</strong> (<em>boolean</em>) whether the image should be saved/loaded using the cache. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Reading images from a file is slow. Setting <code class="docutils literal notranslate"><span class="pre">useCache</span></code> to <code class="docutils literal notranslate"><span class="pre">true</span></code> will save the image to memory so that the next time the filepath is encountered the image can be loaded from memory rather than the file.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.createImage">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">createImage</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">filepath</em>, <em class="sig-param">width = -1</em>, <em class="sig-param">height = -1</em>, <em class="sig-param">offset = 0</em>, <em class="sig-param">xflip = false</em>, <em class="sig-param">yflip = false</em>, <em class="sig-param">paletteId = -1</em>, <em class="sig-param">setTransparency = false</em>, <em class="sig-param">layer = 0</em>, <em class="sig-param">useCache = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.createImage" title="Permalink to this definition"></a></dt>
<dd><p>Creates an image item on the specified overlay layer. This differs from <code class="docutils literal notranslate"><span class="pre">map.addImage</span></code> by allowing the new image to be a transformation of the image file.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) the x pixel coordinate of the images top-left corner (relative to the layers position)</p></li>
<li><p><strong>y</strong> (<em>number</em>) the y pixel coordinate of the images top-left corner (relative to the layers position)</p></li>
<li><p><strong>filepath</strong> (<em>string</em>) the images filepath</p></li>
<li><p><strong>width</strong> (<em>number</em>) the image width. If <code class="docutils literal notranslate"><span class="pre">-1</span></code>, use the full width of the original image. Defaults to <code class="docutils literal notranslate"><span class="pre">-1</span></code></p></li>
<li><p><strong>height</strong> (<em>number</em>) the image height. If <code class="docutils literal notranslate"><span class="pre">-1</span></code>, use the full height of the original image. Defaults to <code class="docutils literal notranslate"><span class="pre">-1</span></code></p></li>
<li><p><strong>offset</strong> (<em>number</em>) the pixel offset into the original image where data should be read from. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
<li><p><strong>xflip</strong> (<em>boolean</em>) whether the image should be a horizontal flip of the original image. Defaults to <code class="docutils literal notranslate"><span class="pre">false</span></code></p></li>
<li><p><strong>yflip</strong> (<em>boolean</em>) whether the image should be a vertical flip of the original image. Defaults to <code class="docutils literal notranslate"><span class="pre">false</span></code></p></li>
<li><p><strong>paletteId</strong> (<em>number</em>) the id of which currently loaded tileset palette to use for the image. If <code class="docutils literal notranslate"><span class="pre">-1</span></code>, use the original images palette. Defaults to <code class="docutils literal notranslate"><span class="pre">-1</span></code></p></li>
<li><p><strong>setTransparency</strong> (<em>boolean</em>) whether the color at index 0 should be overwritten with transparent pixels. Defaults to <code class="docutils literal notranslate"><span class="pre">false</span></code></p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
<li><p><strong>useCache</strong> (<em>boolean</em>) whether the image should be saved/loaded using the cache. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Reading images from a file is slow. Setting <code class="docutils literal notranslate"><span class="pre">useCache</span></code> to <code class="docutils literal notranslate"><span class="pre">true</span></code> will save the image to memory so that the next time the filepath is encountered the image can be loaded from memory rather than the file.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.addTileImage">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">addTileImage</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">tileId</em>, <em class="sig-param">xflip</em>, <em class="sig-param">yflip</em>, <em class="sig-param">palette</em>, <em class="sig-param">setTransparency = false</em>, <em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.addTileImage" title="Permalink to this definition"></a></dt>
<dd><p>Creates an image of a tile on the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) the x pixel coordinate of the images top-left corner (relative to the layers position)</p></li>
<li><p><strong>y</strong> (<em>number</em>) the y pixel coordinate of the images top-left corner (relative to the layers position)</p></li>
<li><p><strong>tileId</strong> (<em>number</em>) tile value for the image</p></li>
<li><p><strong>xflip</strong> (<em>boolean</em>) whether the tile image is flipped horizontally</p></li>
<li><p><strong>yflip</strong> (<em>boolean</em>) whether the tile image is flipped vertically</p></li>
<li><p><strong>palette</strong> (<em>number</em>) palette number for the tile image</p></li>
<li><p><strong>setTransparency</strong> (<em>boolean</em>) whether the color at index 0 should be overwritten with transparent pixels. Defaults to <code class="docutils literal notranslate"><span class="pre">false</span></code></p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="id0">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">addTileImage</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">tile</em>, <em class="sig-param">setTransparency = false</em>, <em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#id0" title="Permalink to this definition"></a></dt>
<dd><p>Creates an image of a tile on the specified overlay layer. This is an overloaded function that takes a single tile as a JavaScript object instead of each of the tiles properties individually.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) the x pixel coordinate of the images top-left corner (relative to the layers position)</p></li>
<li><p><strong>y</strong> (<em>number</em>) the y pixel coordinate of the images top-left corner (relative to the layers position)</p></li>
<li><p><strong>tile</strong> (<em>{tileId,xflip,yflip,palette}</em>) the tile to create an image of</p></li>
<li><p><strong>setTransparency</strong> (<em>boolean</em>) whether the color at index 0 should be overwritten with transparent pixels. Defaults to <code class="docutils literal notranslate"><span class="pre">false</span></code></p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.addMetatileImage">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">addMetatileImage</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">metatileId</em>, <em class="sig-param">setTransparency = false</em>, <em class="sig-param">layer = 0</em><span class="sig-paren">)</span><a class="headerlink" href="#map.addMetatileImage" title="Permalink to this definition"></a></dt>
<dd><p>Creates an image of a metatile on the specified overlay layer.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>number</em>) the x pixel coordinate of the images top-left corner (relative to the layers position)</p></li>
<li><p><strong>y</strong> (<em>number</em>) the y pixel coordinate of the images top-left corner (relative to the layers position)</p></li>
<li><p><strong>metatileId</strong> (<em>number</em>) id of the metatile to create an image of</p></li>
<li><p><strong>setTransparency</strong> (<em>boolean</em>) whether the color at index 0 should be overwritten with transparent pixels. Defaults to <code class="docutils literal notranslate"><span class="pre">false</span></code></p></li>
<li><p><strong>layer</strong> (<em>number</em>) the layer id. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="tileset-functions">
<h4>Tileset Functions<a class="headerlink" href="#tileset-functions" title="Permalink to this headline"></a></h4>
<p>The following functions are related to tilesets and how they are rendered. The functions with “preview” in their name operate on a “fake” version of the palette colors. This means that changing these “preview” colors wont affect the actual tileset colors in the project. A good use of the “preview” palettes would be Day/Night tints, for example.</p>
<dl class="js function">
<dt id="map.getPrimaryTilesetPalettePreview">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getPrimaryTilesetPalettePreview</code><span class="sig-paren">(</span><em class="sig-param">paletteIndex</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getPrimaryTilesetPalettePreview" title="Permalink to this definition"></a></dt>
<dd><p>Gets a palette from the primary tileset of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>paletteIndex</strong> (<em>number</em>) the palette index</p></li>
</ul>
</dd>
<dt class="field-even">Returns array</dt>
<dd class="field-even"><p>array of colors. Each color is a 3-element RGB array</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setPrimaryTilesetPalettePreview">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setPrimaryTilesetPalettePreview</code><span class="sig-paren">(</span><em class="sig-param">paletteIndex</em>, <em class="sig-param">colors</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setPrimaryTilesetPalettePreview" title="Permalink to this definition"></a></dt>
<dd><p>Sets a palette in the primary tileset of the currently-opened map. This will NOT affect the true underlying colorsit only displays these colors in the map-editing area of Porymap.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>paletteIndex</strong> (<em>number</em>) the palette index</p></li>
<li><p><strong>colors</strong> (<em>array</em>) array of colors. Each color is a 3-element RGB array</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getPrimaryTilesetPalettesPreview">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getPrimaryTilesetPalettesPreview</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getPrimaryTilesetPalettesPreview" title="Permalink to this definition"></a></dt>
<dd><p>Gets all of the palettes from the primary tileset of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns array</dt>
<dd class="field-odd"><p>array of arrays of colors. Each color is a 3-element RGB array</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setPrimaryTilesetPalettesPreview">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setPrimaryTilesetPalettesPreview</code><span class="sig-paren">(</span><em class="sig-param">palettes</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setPrimaryTilesetPalettesPreview" title="Permalink to this definition"></a></dt>
<dd><p>Sets all of the palettes in the primary tileset of the currently-opened map. This will NOT affect the true underlying colorsit only displays these colors in the map-editing area of Porymap.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>palettes</strong> (<em>array</em>) array of arrays of colors. Each color is a 3-element RGB array</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getSecondaryTilesetPalettePreview">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getSecondaryTilesetPalettePreview</code><span class="sig-paren">(</span><em class="sig-param">paletteIndex</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getSecondaryTilesetPalettePreview" title="Permalink to this definition"></a></dt>
<dd><p>Gets a palette from the secondary tileset of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>paletteIndex</strong> (<em>number</em>) the palette index</p></li>
</ul>
</dd>
<dt class="field-even">Returns array</dt>
<dd class="field-even"><p>array of colors. Each color is a 3-element RGB array</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setSecondaryTilesetPalettePreview">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setSecondaryTilesetPalettePreview</code><span class="sig-paren">(</span><em class="sig-param">paletteIndex</em>, <em class="sig-param">colors</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setSecondaryTilesetPalettePreview" title="Permalink to this definition"></a></dt>
<dd><p>Sets a palette in the secondary tileset of the currently-opened map. This will NOT affect the true underlying colorsit only displays these colors in the map-editing area of Porymap.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>paletteIndex</strong> (<em>number</em>) the palette index</p></li>
<li><p><strong>colors</strong> (<em>array</em>) array of colors. Each color is a 3-element RGB array</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getSecondaryTilesetPalettesPreview">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getSecondaryTilesetPalettesPreview</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getSecondaryTilesetPalettesPreview" title="Permalink to this definition"></a></dt>
<dd><p>Gets all of the palettes from the secondary tileset of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns array</dt>
<dd class="field-odd"><p>array of arrays of colors. Each color is a 3-element RGB array</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setSecondaryTilesetPalettesPreview">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setSecondaryTilesetPalettesPreview</code><span class="sig-paren">(</span><em class="sig-param">palettes</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setSecondaryTilesetPalettesPreview" title="Permalink to this definition"></a></dt>
<dd><p>Sets all of the palettes in the secondary tileset of the currently-opened map. This will NOT affect the true underlying colorsit only displays these colors in the map-editing area of Porymap.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>palettes</strong> (<em>array</em>) array of arrays of colors. Each color is a 3-element RGB array</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getPrimaryTilesetPalette">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getPrimaryTilesetPalette</code><span class="sig-paren">(</span><em class="sig-param">paletteIndex</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getPrimaryTilesetPalette" title="Permalink to this definition"></a></dt>
<dd><p>Gets a palette from the primary tileset of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>paletteIndex</strong> (<em>number</em>) the palette index</p></li>
</ul>
</dd>
<dt class="field-even">Returns array</dt>
<dd class="field-even"><p>array of colors. Each color is a 3-element RGB array</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setPrimaryTilesetPalette">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setPrimaryTilesetPalette</code><span class="sig-paren">(</span><em class="sig-param">paletteIndex</em>, <em class="sig-param">colors</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setPrimaryTilesetPalette" title="Permalink to this definition"></a></dt>
<dd><p>Sets a palette in the primary tileset of the currently-opened map. This will permanently affect the palette and save the palette to disk.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>paletteIndex</strong> (<em>number</em>) the palette index</p></li>
<li><p><strong>colors</strong> (<em>array</em>) array of colors. Each color is a 3-element RGB array</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getPrimaryTilesetPalettes">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getPrimaryTilesetPalettes</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getPrimaryTilesetPalettes" title="Permalink to this definition"></a></dt>
<dd><p>Gets all of the palettes from the primary tileset of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns array</dt>
<dd class="field-odd"><p>array of arrays of colors. Each color is a 3-element RGB array</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setPrimaryTilesetPalettes">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setPrimaryTilesetPalettes</code><span class="sig-paren">(</span><em class="sig-param">palettes</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setPrimaryTilesetPalettes" title="Permalink to this definition"></a></dt>
<dd><p>Sets all of the palettes in the primary tileset of the currently-opened map. This will permanently affect the palettes and save the palettes to disk.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>palettes</strong> (<em>array</em>) array of arrays of colors. Each color is a 3-element RGB array</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getSecondaryTilesetPalette">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getSecondaryTilesetPalette</code><span class="sig-paren">(</span><em class="sig-param">paletteIndex</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getSecondaryTilesetPalette" title="Permalink to this definition"></a></dt>
<dd><p>Gets a palette from the secondary tileset of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>paletteIndex</strong> (<em>number</em>) the palette index</p></li>
</ul>
</dd>
<dt class="field-even">Returns array</dt>
<dd class="field-even"><p>array of colors. Each color is a 3-element RGB array</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setSecondaryTilesetPalette">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setSecondaryTilesetPalette</code><span class="sig-paren">(</span><em class="sig-param">paletteIndex</em>, <em class="sig-param">colors</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setSecondaryTilesetPalette" title="Permalink to this definition"></a></dt>
<dd><p>Sets a palette in the secondary tileset of the currently-opened map. This will permanently affect the palette and save the palette to disk.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>paletteIndex</strong> (<em>number</em>) the palette index</p></li>
<li><p><strong>colors</strong> (<em>array</em>) array of colors. Each color is a 3-element RGB array</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getSecondaryTilesetPalettes">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getSecondaryTilesetPalettes</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getSecondaryTilesetPalettes" title="Permalink to this definition"></a></dt>
<dd><p>Gets all of the palettes from the secondary tileset of the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns array</dt>
<dd class="field-odd"><p>array of arrays of colors. Each color is a 3-element RGB array</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setSecondaryTilesetPalettes">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setSecondaryTilesetPalettes</code><span class="sig-paren">(</span><em class="sig-param">palettes</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setSecondaryTilesetPalettes" title="Permalink to this definition"></a></dt>
<dd><p>Sets all of the palettes in the secondary tileset of the currently-opened map. This will permanently affect the palettes and save the palettes to disk.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>palettes</strong> (<em>array</em>) array of arrays of colors. Each color is a 3-element RGB array</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.isPrimaryTileset">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">isPrimaryTileset</code><span class="sig-paren">(</span><em class="sig-param">tilesetName</em><span class="sig-paren">)</span><a class="headerlink" href="#map.isPrimaryTileset" title="Permalink to this definition"></a></dt>
<dd><p>Gets whether the specified tileset is a primary tileset.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tilesetName</strong> (<em>string</em>) the tileset name</p></li>
</ul>
</dd>
<dt class="field-even">Returns boolean</dt>
<dd class="field-even"><p>is a primary tileset</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.isSecondaryTileset">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">isSecondaryTileset</code><span class="sig-paren">(</span><em class="sig-param">tilesetName</em><span class="sig-paren">)</span><a class="headerlink" href="#map.isSecondaryTileset" title="Permalink to this definition"></a></dt>
<dd><p>Gets whether the specified tileset is a secondary tileset.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tilesetName</strong> (<em>string</em>) the tileset name</p></li>
</ul>
</dd>
<dt class="field-even">Returns boolean</dt>
<dd class="field-even"><p>is a secondary tileset</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getPrimaryTileset">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getPrimaryTileset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getPrimaryTileset" title="Permalink to this definition"></a></dt>
<dd><p>Gets the name of the primary tileset for the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns string</dt>
<dd class="field-odd"><p>primary tileset name</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setPrimaryTileset">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setPrimaryTileset</code><span class="sig-paren">(</span><em class="sig-param">tileset</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setPrimaryTileset" title="Permalink to this definition"></a></dt>
<dd><p>Sets the primary tileset for the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tileset</strong> (<em>string</em>) the tileset name</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getSecondaryTileset">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getSecondaryTileset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getSecondaryTileset" title="Permalink to this definition"></a></dt>
<dd><p>Gets the name of the secondary tileset for the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns string</dt>
<dd class="field-odd"><p>secondary tileset name</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setSecondaryTileset">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setSecondaryTileset</code><span class="sig-paren">(</span><em class="sig-param">tileset</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setSecondaryTileset" title="Permalink to this definition"></a></dt>
<dd><p>Sets the secondary tileset for the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tileset</strong> (<em>string</em>) the tileset name</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getNumPrimaryTilesetMetatiles">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getNumPrimaryTilesetMetatiles</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getNumPrimaryTilesetMetatiles" title="Permalink to this definition"></a></dt>
<dd><p>Gets the number of metatiles in the primary tileset for the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>number of metatiles</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMaxPrimaryTilesetMetatiles">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMaxPrimaryTilesetMetatiles</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getMaxPrimaryTilesetMetatiles" title="Permalink to this definition"></a></dt>
<dd><p>Gets the maximum number of metatiles allowed in a primary tileset.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>maximum number of metatiles</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getNumSecondaryTilesetMetatiles">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getNumSecondaryTilesetMetatiles</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getNumSecondaryTilesetMetatiles" title="Permalink to this definition"></a></dt>
<dd><p>Gets the number of metatiles in the secondary tileset for the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>number of metatiles</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMaxSecondaryTilesetMetatiles">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMaxSecondaryTilesetMetatiles</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getMaxSecondaryTilesetMetatiles" title="Permalink to this definition"></a></dt>
<dd><p>Gets the maximum number of metatiles allowed in a secondary tileset.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>maximum number of metatiles</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getNumPrimaryTilesetTiles">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getNumPrimaryTilesetTiles</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getNumPrimaryTilesetTiles" title="Permalink to this definition"></a></dt>
<dd><p>Gets the number of tiles in the primary tileset for the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>number of tiles</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMaxPrimaryTilesetTiles">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMaxPrimaryTilesetTiles</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getMaxPrimaryTilesetTiles" title="Permalink to this definition"></a></dt>
<dd><p>Gets the maximum number of tiles allowed in a primary tileset.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>maximum number of tiles</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getNumSecondaryTilesetTiles">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getNumSecondaryTilesetTiles</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getNumSecondaryTilesetTiles" title="Permalink to this definition"></a></dt>
<dd><p>Gets the number of tiles in the secondary tileset for the currently-opened map.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>number of tiles</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMaxSecondaryTilesetTiles">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMaxSecondaryTilesetTiles</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getMaxSecondaryTilesetTiles" title="Permalink to this definition"></a></dt>
<dd><p>Gets the maximum number of tiles allowed in a secondary tileset.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>maximum number of tiles</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getNumTilesInMetatile">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getNumTilesInMetatile</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getNumTilesInMetatile" title="Permalink to this definition"></a></dt>
<dd><p>Gets the number of tiles in a metatile. Will be either <code class="docutils literal notranslate"><span class="pre">8</span></code> or <code class="docutils literal notranslate"><span class="pre">12</span></code> depending on <code class="docutils literal notranslate"><span class="pre">enable_triple_layer_metatiles</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>number of tiles in a metatile</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getNumMetatileLayers">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getNumMetatileLayers</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getNumMetatileLayers" title="Permalink to this definition"></a></dt>
<dd><p>Gets the number of layers in a metatiles. Will be either <code class="docutils literal notranslate"><span class="pre">2</span></code> or <code class="docutils literal notranslate"><span class="pre">3</span></code> depending on <code class="docutils literal notranslate"><span class="pre">enable_triple_layer_metatiles</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>number of layers in a metatile</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileLayerOrder">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileLayerOrder</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileLayerOrder" title="Permalink to this definition"></a></dt>
<dd><p>Gets the order that metatile layers are rendered.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns array</dt>
<dd class="field-odd"><p>array of layers. The bottom layer is represented as 0.</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMetatileLayerOrder">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileLayerOrder</code><span class="sig-paren">(</span><em class="sig-param">order</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMetatileLayerOrder" title="Permalink to this definition"></a></dt>
<dd><p>Sets the order that metatile layers are rendered.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>order</strong> (<em>array</em>) array of layers. The bottom layer is represented as 0.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileLayerOpacity">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileLayerOpacity</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileLayerOpacity" title="Permalink to this definition"></a></dt>
<dd><p>Gets the opacities that metatile layers are rendered with.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns array</dt>
<dd class="field-odd"><p>array of opacities for each layer. The bottom layer is the first element.</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMetatileLayerOpacity">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileLayerOpacity</code><span class="sig-paren">(</span><em class="sig-param">opacities</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMetatileLayerOpacity" title="Permalink to this definition"></a></dt>
<dd><p>Sets the opacities that metatile layers are rendered with.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>opacities</strong> (<em>array</em>) array of opacities for each layer. The bottom layer is the first element.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileLabel">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileLabel</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileLabel" title="Permalink to this definition"></a></dt>
<dd><p>Gets the label for the specified metatile.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
</ul>
</dd>
<dt class="field-even">Returns string</dt>
<dd class="field-even"><p>the label</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMetatileLabel">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileLabel</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em>, <em class="sig-param">label</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMetatileLabel" title="Permalink to this definition"></a></dt>
<dd><p>Sets the label for the specified metatile. A label can only consist of letters, numbers, and underscores.</p>
<p><strong>Warning:</strong> This function writes directly to the project. There is no undo for this.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
<li><p><strong>label</strong> (<em>string</em>) the label</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileLayerType">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileLayerType</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileLayerType" title="Permalink to this definition"></a></dt>
<dd><p>Gets the layer type for the specified metatile. <code class="docutils literal notranslate"><span class="pre">0</span></code>: Middle/Top, <code class="docutils literal notranslate"><span class="pre">1</span></code>: Bottom/Middle, <code class="docutils literal notranslate"><span class="pre">2</span></code>: Bottom/Top.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
</ul>
</dd>
<dt class="field-even">Returns number</dt>
<dd class="field-even"><p>the layer type</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMetatileLayerType">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileLayerType</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em>, <em class="sig-param">layerType</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMetatileLayerType" title="Permalink to this definition"></a></dt>
<dd><p>Sets the layer type for the specified metatile. <code class="docutils literal notranslate"><span class="pre">0</span></code>: Middle/Top, <code class="docutils literal notranslate"><span class="pre">1</span></code>: Bottom/Middle, <code class="docutils literal notranslate"><span class="pre">2</span></code>: Bottom/Top.</p>
<p><strong>Warning:</strong> This function writes directly to the tileset. There is no undo for this.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
<li><p><strong>layerType</strong> (<em>number</em>) the layer type</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileEncounterType">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileEncounterType</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileEncounterType" title="Permalink to this definition"></a></dt>
<dd><p>Gets the encounter type for the specified metatile. <code class="docutils literal notranslate"><span class="pre">0</span></code>: None, <code class="docutils literal notranslate"><span class="pre">1</span></code>: Land, <code class="docutils literal notranslate"><span class="pre">2</span></code>: Water</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
</ul>
</dd>
<dt class="field-even">Returns number</dt>
<dd class="field-even"><p>the encounter type</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMetatileEncounterType">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileEncounterType</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em>, <em class="sig-param">encounterType</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMetatileEncounterType" title="Permalink to this definition"></a></dt>
<dd><p>Sets the encounter type for the specified metatile. <code class="docutils literal notranslate"><span class="pre">0</span></code>: None, <code class="docutils literal notranslate"><span class="pre">1</span></code>: Land, <code class="docutils literal notranslate"><span class="pre">2</span></code>: Water</p>
<p><strong>Warning:</strong> This function writes directly to the tileset. There is no undo for this.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
<li><p><strong>encounterType</strong> (<em>number</em>) the encounter type</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileTerrainType">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileTerrainType</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileTerrainType" title="Permalink to this definition"></a></dt>
<dd><p>Gets the terrain type for the specified metatile. <code class="docutils literal notranslate"><span class="pre">0</span></code>: None, <code class="docutils literal notranslate"><span class="pre">1</span></code>: Grass, <code class="docutils literal notranslate"><span class="pre">2</span></code>: Water, <code class="docutils literal notranslate"><span class="pre">3</span></code>: Waterfall</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
</ul>
</dd>
<dt class="field-even">Returns number</dt>
<dd class="field-even"><p>the terrain type</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMetatileTerrainType">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileTerrainType</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em>, <em class="sig-param">terrainType</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMetatileTerrainType" title="Permalink to this definition"></a></dt>
<dd><p>Sets the terrain type for the specified metatile. <code class="docutils literal notranslate"><span class="pre">0</span></code>: None, <code class="docutils literal notranslate"><span class="pre">1</span></code>: Grass, <code class="docutils literal notranslate"><span class="pre">2</span></code>: Water, <code class="docutils literal notranslate"><span class="pre">3</span></code>: Waterfall</p>
<p><strong>Warning:</strong> This function writes directly to the tileset. There is no undo for this.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
<li><p><strong>terrainType</strong> (<em>number</em>) the terrain type</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileBehavior">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileBehavior</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileBehavior" title="Permalink to this definition"></a></dt>
<dd><p>Gets the behavior for the specified metatile.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
</ul>
</dd>
<dt class="field-even">Returns number</dt>
<dd class="field-even"><p>the behavior</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMetatileBehavior">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileBehavior</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em>, <em class="sig-param">behavior</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMetatileBehavior" title="Permalink to this definition"></a></dt>
<dd><p>Sets the behavior for the specified metatile.</p>
<p><strong>Warning:</strong> This function writes directly to the tileset. There is no undo for this.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
<li><p><strong>behavior</strong> (<em>number</em>) the behavior</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileTile">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileTile</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em>, <em class="sig-param">tileIndex</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileTile" title="Permalink to this definition"></a></dt>
<dd><p>Gets the tile at the specified index of the metatile.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
<li><p><strong>tileIndex</strong> (<em>number</em>) index of the tile to get</p></li>
</ul>
</dd>
<dt class="field-even">Returns {tileId, xflip, yflip, palette}</dt>
<dd class="field-even"><p>the tile</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileTiles">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileTiles</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em>, <em class="sig-param">tileStart = 0</em>, <em class="sig-param">tileEnd = -1</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileTiles" title="Permalink to this definition"></a></dt>
<dd><p>Gets the tiles in the specified range of the metatile.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
<li><p><strong>tileStart</strong> (<em>number</em>) index of the first tile to get. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code> (the first tile)</p></li>
<li><p><strong>tileEnd</strong> (<em>number</em>) index of the last tile to get. Defaults to <code class="docutils literal notranslate"><span class="pre">-1</span></code> (the last tile)</p></li>
</ul>
</dd>
<dt class="field-even">Returns array</dt>
<dd class="field-even"><p>array of tiles in the specified range. Each tile is an object of the form <code class="docutils literal notranslate"><span class="pre">{tileId,</span> <span class="pre">xflip,</span> <span class="pre">yflip,</span> <span class="pre">palette}</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMetatileTile">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileTile</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em>, <em class="sig-param">tileIndex</em>, <em class="sig-param">tileId</em>, <em class="sig-param">xflip</em>, <em class="sig-param">yflip</em>, <em class="sig-param">palette</em>, <em class="sig-param">forceRedraw = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMetatileTile" title="Permalink to this definition"></a></dt>
<dd><p>Sets the tile at the specified index of the metatile.</p>
<p><strong>Warning:</strong> This function writes directly to the tileset. There is no undo for this.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
<li><p><strong>tileIndex</strong> (<em>number</em>) index of the tile to set</p></li>
<li><p><strong>tileId</strong> (<em>number</em>) new tiles value</p></li>
<li><p><strong>xflip</strong> (<em>boolean</em>) whether the new tile is flipped horizontally</p></li>
<li><p><strong>yflip</strong> (<em>boolean</em>) whether the new tile is flipped vertically</p></li>
<li><p><strong>palette</strong> (<em>number</em>) new tiles palette number</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="id1">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileTile</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em>, <em class="sig-param">tileIndex</em>, <em class="sig-param">tile</em>, <em class="sig-param">forceRedraw = true</em><span class="sig-paren">)</span><a class="headerlink" href="#id1" title="Permalink to this definition"></a></dt>
<dd><p>Sets the tile at the specified index of the metatile. This is an overloaded function that takes a single tile as a JavaScript object instead of each of the tiles properties individually.</p>
<p><strong>Warning:</strong> This function writes directly to the tileset. There is no undo for this.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
<li><p><strong>tileIndex</strong> (<em>number</em>) index of the tile to set</p></li>
<li><p><strong>tile</strong> (<em>{tileId,xflip,yflip,palette}</em>) the new tile</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMetatileTiles">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileTiles</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em>, <em class="sig-param">tileId</em>, <em class="sig-param">xflip</em>, <em class="sig-param">yflip</em>, <em class="sig-param">palette</em>, <em class="sig-param">tileStart = 0</em>, <em class="sig-param">tileEnd = -1</em>, <em class="sig-param">forceRedraw = true</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMetatileTiles" title="Permalink to this definition"></a></dt>
<dd><p>Sets the tiles in the specified range of the metatile. All tiles in the specified range will be set using the same given values.</p>
<p><strong>Warning:</strong> This function writes directly to the tileset. There is no undo for this.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
<li><p><strong>tileId</strong> (<em>number</em>) new tiles value</p></li>
<li><p><strong>xflip</strong> (<em>boolean</em>) whether the new tiles are flipped horizontally</p></li>
<li><p><strong>yflip</strong> (<em>boolean</em>) whether the new tiles are flipped vertically</p></li>
<li><p><strong>palette</strong> (<em>number</em>) new tiles palette number</p></li>
<li><p><strong>tileStart</strong> (<em>number</em>) index of the first tile to set. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code> (the first tile)</p></li>
<li><p><strong>tileEnd</strong> (<em>number</em>) index of the last tile to set. Defaults to <code class="docutils literal notranslate"><span class="pre">-1</span></code> (the last tile)</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="id2">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileTiles</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em>, <em class="sig-param">tiles</em>, <em class="sig-param">tileStart = 0</em>, <em class="sig-param">tileEnd = -1</em>, <em class="sig-param">forceRedraw = true</em><span class="sig-paren">)</span><a class="headerlink" href="#id2" title="Permalink to this definition"></a></dt>
<dd><p>Sets the tiles in the specified range of the metatile. This is an overloaded function that takes an array of tiles as JavaScript objects instead of each of the tile properties individually.</p>
<p><strong>Warning:</strong> This function writes directly to the tileset. There is no undo for this.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>metatileId</strong> (<em>number</em>) id of target metatile</p></li>
<li><p><strong>tiles</strong> (<em>array</em>) array of tiles to set. Each tile is an object of the form <code class="docutils literal notranslate"><span class="pre">{tileId,</span> <span class="pre">xflip,</span> <span class="pre">yflip,</span> <span class="pre">palette}</span></code>. If the array does not have sufficient objects to set all the tiles in the specified range then the remaining tiles will be set with all default values.</p></li>
<li><p><strong>tileStart</strong> (<em>number</em>) index of the first tile to set. Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code> (the first tile)</p></li>
<li><p><strong>tileEnd</strong> (<em>number</em>) index of the last tile to set. Defaults to <code class="docutils literal notranslate"><span class="pre">-1</span></code> (the last tile)</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) Force the map view to refresh. Defaults to <code class="docutils literal notranslate"><span class="pre">true</span></code>. Redrawing the map view is expensive, so set to <code class="docutils literal notranslate"><span class="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <code class="docutils literal notranslate"><span class="pre">map.redraw()</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="settings-functions">
<h4>Settings Functions<a class="headerlink" href="#settings-functions" title="Permalink to this headline"></a></h4>
<p>The following functions are related to settings.</p>
<dl class="js function">
<dt id="map.getGridVisibility">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getGridVisibility</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getGridVisibility" title="Permalink to this definition"></a></dt>
<dd><p>Gets the visibility of the map grid overlay.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns boolean</dt>
<dd class="field-odd"><p>grid visibility</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setGridVisibility">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setGridVisibility</code><span class="sig-paren">(</span><em class="sig-param">visible</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setGridVisibility" title="Permalink to this definition"></a></dt>
<dd><p>Sets the visibility of the map grid overlay.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>visible</strong> (<em>boolean</em>) grid visibility</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getBorderVisibility">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getBorderVisibility</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getBorderVisibility" title="Permalink to this definition"></a></dt>
<dd><p>Gets the visibility of the maps border.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns boolean</dt>
<dd class="field-odd"><p>border visibility</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setBorderVisibility">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setBorderVisibility</code><span class="sig-paren">(</span><em class="sig-param">visible</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setBorderVisibility" title="Permalink to this definition"></a></dt>
<dd><p>Sets the visibility of the maps border.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>visible</strong> (<em>boolean</em>) border visibility</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getSmartPathsEnabled">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getSmartPathsEnabled</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getSmartPathsEnabled" title="Permalink to this definition"></a></dt>
<dd><p>Gets the toggle state of smart paths.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns boolean</dt>
<dd class="field-odd"><p>smart paths enabled</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setSmartPathsEnabled">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setSmartPathsEnabled</code><span class="sig-paren">(</span><em class="sig-param">enabled</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setSmartPathsEnabled" title="Permalink to this definition"></a></dt>
<dd><p>Sets the toggle state of smart paths.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>enabled</strong> (<em>boolean</em>) smart paths enabled</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getBaseGameVersion">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getBaseGameVersion</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getBaseGameVersion" title="Permalink to this definition"></a></dt>
<dd><p>Gets the projects base game version.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns string</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">&quot;pokeruby&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">&quot;pokefirered&quot;</span></code>, or <code class="docutils literal notranslate"><span class="pre">&quot;pokeemerald&quot;</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getCustomScripts">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getCustomScripts</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getCustomScripts" title="Permalink to this definition"></a></dt>
<dd><p>Gets the list of paths to custom scripts.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns array</dt>
<dd class="field-odd"><p>string array of custom scripts paths</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMainTab">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMainTab</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getMainTab" title="Permalink to this definition"></a></dt>
<dd><p>Gets the index of the currently selected main tab. Tabs are indexed from left to right, starting at 0 (<code class="docutils literal notranslate"><span class="pre">0</span></code>: Map, <code class="docutils literal notranslate"><span class="pre">1</span></code>: Events, <code class="docutils literal notranslate"><span class="pre">2</span></code>: Header, <code class="docutils literal notranslate"><span class="pre">3</span></code>: Connections, <code class="docutils literal notranslate"><span class="pre">4</span></code>: Wild Pokemon).</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>current main tab index</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMainTab">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMainTab</code><span class="sig-paren">(</span><em class="sig-param">tab</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMainTab" title="Permalink to this definition"></a></dt>
<dd><p>Sets the currently selected main tab. Tabs are indexed from left to right, starting at 0 (<code class="docutils literal notranslate"><span class="pre">0</span></code>: Map, <code class="docutils literal notranslate"><span class="pre">1</span></code>: Events, <code class="docutils literal notranslate"><span class="pre">2</span></code>: Header, <code class="docutils literal notranslate"><span class="pre">3</span></code>: Connections, <code class="docutils literal notranslate"><span class="pre">4</span></code>: Wild Pokemon).</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tab</strong> (<em>number</em>) index of the tab to select</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMapViewTab">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMapViewTab</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getMapViewTab" title="Permalink to this definition"></a></dt>
<dd><p>Gets the index of the currently selected map view tab. Tabs are indexed from left to right, starting at 0 (<code class="docutils literal notranslate"><span class="pre">0</span></code>: Metatiles, <code class="docutils literal notranslate"><span class="pre">1</span></code>: Collision).</p>
<dl class="field-list simple">
<dt class="field-odd">Returns number</dt>
<dd class="field-odd"><p>current map view tab index</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMapViewTab">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMapViewTab</code><span class="sig-paren">(</span><em class="sig-param">tab</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMapViewTab" title="Permalink to this definition"></a></dt>
<dd><p>Sets the currently selected map view tab. Tabs are indexed from left to right, starting at 0 (<code class="docutils literal notranslate"><span class="pre">0</span></code>: Metatiles, <code class="docutils literal notranslate"><span class="pre">1</span></code>: Collision).</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tab</strong> (<em>number</em>) index of the tab to select</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="utility-functions">
<h4>Utility Functions<a class="headerlink" href="#utility-functions" title="Permalink to this headline"></a></h4>
<p>These are some miscellaneous functions that can be very useful when building custom scripts.</p>
<dl class="js function">
<dt id="map.registerAction">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">registerAction</code><span class="sig-paren">(</span><em class="sig-param">functionName</em>, <em class="sig-param">actionName</em>, <em class="sig-param">shortcut = &quot;&quot;</em><span class="sig-paren">)</span><a class="headerlink" href="#map.registerAction" title="Permalink to this definition"></a></dt>
<dd><p>Registers a JavaScript function to an action that can be manually triggered in Porymaps <code class="docutils literal notranslate"><span class="pre">Tools</span></code> menu. Optionally, a keyboard shortcut (e.g. <code class="docutils literal notranslate"><span class="pre">&quot;Ctrl+P&quot;</span></code>) can also be specified, assuming it doesnt collide with any existing shortcuts used by Porymap. The function specified by <code class="docutils literal notranslate"><span class="pre">functionName</span></code> must have the <code class="docutils literal notranslate"><span class="pre">export</span></code> keyword.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>functionName</strong> (<em>string</em>) name of the JavaScript function</p></li>
<li><p><strong>actionName</strong> (<em>string</em>) name of the action that will be displayed in the <code class="docutils literal notranslate"><span class="pre">Tools</span></code> menu</p></li>
<li><p><strong>shortcut</strong> (<em>string</em>) optional keyboard shortcut</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setTimeout">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setTimeout</code><span class="sig-paren">(</span><em class="sig-param">func</em>, <em class="sig-param">delayMs</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setTimeout" title="Permalink to this definition"></a></dt>
<dd><p>This behaves essentially the same as JavaScripts <code class="docutils literal notranslate"><span class="pre">setTimeout()</span></code> that is used in web browsers or NodeJS. The <code class="docutils literal notranslate"><span class="pre">func</span></code> argument is a JavaScript function (NOT the name of a function) which will be executed after a delay. This is useful for creating animations or refreshing the overlay at constant intervals.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>func</strong> (<em>function</em>) a JavaScript function that will be executed later</p></li>
<li><p><strong>delayMs</strong> (<em>number</em>) the number of milliseconds to wait before executing <code class="docutils literal notranslate"><span class="pre">func</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.log">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">log</code><span class="sig-paren">(</span><em class="sig-param">message</em><span class="sig-paren">)</span><a class="headerlink" href="#map.log" title="Permalink to this definition"></a></dt>
<dd><p>Logs a message to the Porymap log file with the prefix <code class="docutils literal notranslate"><span class="pre">[INFO]</span></code>. This is useful for debugging custom scripts.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>message</strong> (<em>string</em>) the message to log</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.warn">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">warn</code><span class="sig-paren">(</span><em class="sig-param">message</em><span class="sig-paren">)</span><a class="headerlink" href="#map.warn" title="Permalink to this definition"></a></dt>
<dd><p>Logs a message to the Porymap log file with the prefix <code class="docutils literal notranslate"><span class="pre">[WARN]</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>message</strong> (<em>string</em>) the message to log</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.error">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">error</code><span class="sig-paren">(</span><em class="sig-param">message</em><span class="sig-paren">)</span><a class="headerlink" href="#map.error" title="Permalink to this definition"></a></dt>
<dd><p>Logs a message to the Porymap log file with the prefix <code class="docutils literal notranslate"><span class="pre">[ERROR]</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>message</strong> (<em>string</em>) the message to log</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="project-files.html" class="btn btn-neutral float-right" title="Project Files" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="region-map-editor.html" class="btn btn-neutral float-left" title="The Region Map Editor" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, huderlem
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>