<h1>Scripting Capabilities<aclass="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>
<ulclass="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>
<divclass="section"id="writing-a-custom-script">
<h2>Writing a Custom Script<aclass="headerlink"href="#writing-a-custom-script"title="Permalink to this headline">¶</a></h2>
<p>Let’s write a custom script that will randomize grass patterns when the user is editing the map. This is useful, since it’s 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 <codeclass="docutils literal notranslate"><spanclass="pre">my_script.js</span></code>–place it in the project directory (e.g. <codeclass="docutils literal notranslate"><spanclass="pre">pokefirered/</span></code>).</p>
<p>Next, open the Porymap project config file, <codeclass="docutils literal notranslate"><spanclass="pre">porymap.project.cfg</span></code>, in the project directory. Add the script file to the <codeclass="docutils literal notranslate"><spanclass="pre">custom_scripts</span></code> configuration value. Multiple script files can be loaded by separating the filepaths with a comma.</p>
<p>Now that Porymap is configured to load the script file, let’s 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. We’re interested in the <codeclass="docutils literal notranslate"><spanclass="pre">onBlockChanged()</span></code> callback, since we want our script to take action whenever a user paints a block on the map.</p>
<divclass="highlight-js notranslate"><divclass="highlight"><pre><span></span><spanclass="c1">// Porymap callback when a block is painted.</span>
<p>It’s very <strong>important</strong> to remember to <codeclass="docutils literal notranslate"><spanclass="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, we’ll be using the <codeclass="docutils literal notranslate"><spanclass="pre">map.setMetatileId()</span></code> function. Let’s fill in the rest of the grass-randomizing code.</p>
<p>Let’s 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>
<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 <codeclass="docutils literal notranslate"><spanclass="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>
<spanclass="nx">map</span><spanclass="p">.</span><spanclass="nx">registerAction</span><spanclass="p">(</span><spanclass="s2">"applyNightTint"</span><spanclass="p">,</span><spanclass="s2">"View Night Tint"</span><spanclass="p">,</span><spanclass="s2">"T"</span><spanclass="p">)</span>
<spanclass="p">}</span>
</pre></div>
</div>
<p>Then, to trigger the <codeclass="docutils literal notranslate"><spanclass="pre">applyNightTint()</span></code> function, we could either click <codeclass="docutils literal notranslate"><spanclass="pre">Tools</span><spanclass="pre">-></span><spanclass="pre">View</span><spanclass="pre">Night</span><spanclass="pre">Tint</span></code> or use the <codeclass="docutils literal notranslate"><spanclass="pre">T</span></code> keyboard shortcut.</p>
<p>Now that we have an overview of how to utilize Porymap’s scripting capabilities, the entire scripting API is documented below.</p>
</div>
<divclass="section"id="scripting-api">
<h2>Scripting API<aclass="headerlink"href="#scripting-api"title="Permalink to this headline">¶</a></h2>
<divclass="section"id="callbacks">
<h3>Callbacks<aclass="headerlink"href="#callbacks"title="Permalink to this headline">¶</a></h3>
<codeclass="sig-name descname">onProjectOpened</code><spanclass="sig-paren">(</span><emclass="sig-param">projectPath</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#onProjectOpened"title="Permalink to this definition">¶</a></dt>
<dd><p>Called when Porymap successfully opens a project.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>projectPath</strong> (<em>string</em>) – the directory path of the opened project</p></li>
<codeclass="sig-name descname">onProjectClosed</code><spanclass="sig-paren">(</span><emclass="sig-param">projectPath</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>projectPath</strong> (<em>string</em>) – the directory path of the closed project</p></li>
<codeclass="sig-name descname">onMapOpened</code><spanclass="sig-paren">(</span><emclass="sig-param">mapName</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#onMapOpened"title="Permalink to this definition">¶</a></dt>
<dd><p>Called when a map is opened.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>mapName</strong> (<em>string</em>) – the name of the opened map</p></li>
<codeclass="sig-name descname">onBlockChanged</code><spanclass="sig-paren">(</span><emclass="sig-param">x</em>, <emclass="sig-param">y</em>, <emclass="sig-param">prevBlock</em>, <emclass="sig-param">newBlock</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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 block’s state before it was modified. The object’s shape is <codeclass="docutils literal notranslate"><spanclass="pre">{metatileId,</span><spanclass="pre">collision,</span><spanclass="pre">elevation,</span><spanclass="pre">rawValue}</span></code></p></li>
<li><p><strong>newBlock</strong> (<em>object</em>) – the block’s new state after it was modified. The object’s shape is <codeclass="docutils literal notranslate"><spanclass="pre">{metatileId,</span><spanclass="pre">collision,</span><spanclass="pre">elevation,</span><spanclass="pre">rawValue}</span></code></p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
<divclass="section"id="functions">
<h3>Functions<aclass="headerlink"href="#functions"title="Permalink to this headline">¶</a></h3>
<p>All scripting functions are callable via the global <codeclass="docutils literal notranslate"><spanclass="pre">map</span></code> object.</p>
<divclass="section"id="map-editing-functions">
<h4>Map Editing Functions<aclass="headerlink"href="#map-editing-functions"title="Permalink to this headline">¶</a></h4>
<p>The following functions are related to editing the map’s blocks or retrieving information about them.</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getBlock</code><spanclass="sig-paren">(</span><emclass="sig-param">x</em>, <emclass="sig-param">y</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.getBlock"title="Permalink to this definition">¶</a></dt>
<dd><p>Gets a block in the currently-opened map.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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>forceRedraw</strong> (<em>boolean</em>) – Force the map view to refresh. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. Redrawing the map view is expensive, so set to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <codeclass="docutils literal notranslate"><spanclass="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) – Commit the changes to the map’s edit/undo history. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. When making many related map edits, it can be useful to set this to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code>, and then commit all of them together with <codeclass="docutils literal notranslate"><spanclass="pre">map.commit()</span></code>.</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getMetatileId</code><spanclass="sig-paren">(</span><emclass="sig-param">x</em>, <emclass="sig-param">y</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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>
<dtclass="field-even">Returns number</dt>
<ddclass="field-even"><p>the metatile id of the block</p>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) – Force the map view to refresh. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. Redrawing the map view is expensive, so set to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <codeclass="docutils literal notranslate"><spanclass="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) – Commit the changes to the map’s edit/undo history. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. When making many related map edits, it can be useful to set this to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code>, and then commit all of them together with <codeclass="docutils literal notranslate"><spanclass="pre">map.commit()</span></code>.</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getCollision</code><spanclass="sig-paren">(</span><emclass="sig-param">x</em>, <emclass="sig-param">y</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.getCollision"title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the collision of a block in the currently-opened map. (<codeclass="docutils literal notranslate"><spanclass="pre">0</span></code> = passable, <codeclass="docutils literal notranslate"><spanclass="pre">1</span></code> = impassable)</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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>
<dtclass="field-even">Returns number</dt>
<ddclass="field-even"><p>the collision of the block</p>
<dd><p>Sets the collision of a block in the currently-opened map. (<codeclass="docutils literal notranslate"><spanclass="pre">0</span></code> = passable, <codeclass="docutils literal notranslate"><spanclass="pre">1</span></code> = impassable)</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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 <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. Redrawing the map view is expensive, so set to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <codeclass="docutils literal notranslate"><spanclass="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) – Commit the changes to the map’s edit/undo history. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. When making many related map edits, it can be useful to set this to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code>, and then commit all of them together with <codeclass="docutils literal notranslate"><spanclass="pre">map.commit()</span></code>.</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getElevation</code><spanclass="sig-paren">(</span><emclass="sig-param">x</em>, <emclass="sig-param">y</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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>
<dtclass="field-even">Returns number</dt>
<ddclass="field-even"><p>the elevation of the block</p>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) – Force the map view to refresh. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. Redrawing the map view is expensive, so set to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <codeclass="docutils literal notranslate"><spanclass="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) – Commit the changes to the map’s edit/undo history. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. When making many related map edits, it can be useful to set this to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code>, and then commit all of them together with <codeclass="docutils literal notranslate"><spanclass="pre">map.commit()</span></code>.</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) – Force the map view to refresh. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. Redrawing the map view is expensive, so set to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <codeclass="docutils literal notranslate"><spanclass="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) – Commit the changes to the map’s edit/undo history. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. When making many related map edits, it can be useful to set this to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code>, and then commit all of them together with <codeclass="docutils literal notranslate"><spanclass="pre">map.commit()</span></code>.</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) – Force the map view to refresh. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. Redrawing the map view is expensive, so set to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <codeclass="docutils literal notranslate"><spanclass="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) – Commit the changes to the map’s edit/undo history. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. When making many related map edits, it can be useful to set this to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code>, and then commit all of them together with <codeclass="docutils literal notranslate"><spanclass="pre">map.commit()</span></code>.</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) – Force the map view to refresh. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. Redrawing the map view is expensive, so set to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <codeclass="docutils literal notranslate"><spanclass="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) – Commit the changes to the map’s edit/undo history. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. When making many related map edits, it can be useful to set this to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code>, and then commit all of them together with <codeclass="docutils literal notranslate"><spanclass="pre">map.commit()</span></code>.</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) – Force the map view to refresh. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. Redrawing the map view is expensive, so set to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <codeclass="docutils literal notranslate"><spanclass="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) – Commit the changes to the map’s edit/undo history. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. When making many related map edits, it can be useful to set this to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code>, and then commit all of them together with <codeclass="docutils literal notranslate"><spanclass="pre">map.commit()</span></code>.</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) – Force the map view to refresh. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. Redrawing the map view is expensive, so set to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <codeclass="docutils literal notranslate"><spanclass="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) – Commit the changes to the map’s edit/undo history. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. When making many related map edits, it can be useful to set this to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code>, and then commit all of them together with <codeclass="docutils literal notranslate"><spanclass="pre">map.commit()</span></code>.</p></li>
<li><p><strong>forceRedraw</strong> (<em>boolean</em>) – Force the map view to refresh. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. Redrawing the map view is expensive, so set to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code> when making many consecutive map edits, and then redraw the map once using <codeclass="docutils literal notranslate"><spanclass="pre">map.redraw()</span></code>.</p></li>
<li><p><strong>commitChanges</strong> (<em>boolean</em>) – Commit the changes to the map’s edit/undo history. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>. When making many related map edits, it can be useful to set this to <codeclass="docutils literal notranslate"><spanclass="pre">false</span></code>, and then commit all of them together with <codeclass="docutils literal notranslate"><spanclass="pre">map.commit()</span></code>.</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getDimensions</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.getDimensions"title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the dimensions of the currently-opened map.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns {width, height}</dt>
<ddclass="field-odd"><p>the dimensions of the map</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getWidth</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.getWidth"title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the width of the currently-opened map.</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getHeight</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.getHeight"title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the height of the currently-opened map.</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setDimensions</code><spanclass="sig-paren">(</span><emclass="sig-param">width</em>, <emclass="sig-param">height</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.setDimensions"title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the dimensions of the currently-opened map.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setWidth</code><spanclass="sig-paren">(</span><emclass="sig-param">width</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.setWidth"title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the width of the currently-opened map.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>width</strong> (<em>number</em>) – width in blocks</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setHeight</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.setHeight"title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the height of the currently-opened map.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>height</strong> (<em>number</em>) – height in blocks</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">redraw</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.redraw"title="Permalink to this definition">¶</a></dt>
<dd><p>Redraws the entire map area. Useful when delaying map redraws using <codeclass="docutils literal notranslate"><spanclass="pre">forceRedraw</span><spanclass="pre">=</span><spanclass="pre">false</span></code> in certain map editing functions.</p>
</dd></dl>
<dlclass="js function">
<dtid="map.commit">
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">commit</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.commit"title="Permalink to this definition">¶</a></dt>
<dd><p>Commits any uncommitted changes to the map’s edit/undo history. Useful when delaying commits using <codeclass="docutils literal notranslate"><spanclass="pre">commitChanges</span><spanclass="pre">=</span><spanclass="pre">false</span></code> in certain map editing functions.</p>
<h4>Map Overlay Functions<aclass="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.</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">clearOverlay</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.clearOverlay"title="Permalink to this definition">¶</a></dt>
<dd><p>Clears and erases all overlay items that were previously-added to the map.</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">addRect</code><spanclass="sig-paren">(</span><emclass="sig-param">x</em>, <emclass="sig-param">y</em>, <emclass="sig-param">width</em>, <emclass="sig-param">height</em>, <emclass="sig-param">color = "#000000"</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.addRect"title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a rectangle outline item to the overlay.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>x</strong> (<em>number</em>) – the x pixel coordinate of the rectangle’s top-left corner</p></li>
<li><p><strong>y</strong> (<em>number</em>) – the y pixel coordinate of the rectangle’s top-left corner</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>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">addFilledRect</code><spanclass="sig-paren">(</span><emclass="sig-param">x</em>, <emclass="sig-param">y</em>, <emclass="sig-param">width</em>, <emclass="sig-param">height</em>, <emclass="sig-param">color = "#000000"</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.addFilledRect"title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a filled rectangle item to the overlay.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>x</strong> (<em>number</em>) – the x pixel coordinate of the rectangle’s top-left corner</p></li>
<li><p><strong>y</strong> (<em>number</em>) – the y pixel coordinate of the rectangle’s top-left corner</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>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">addImage</code><spanclass="sig-paren">(</span><emclass="sig-param">x</em>, <emclass="sig-param">y</em>, <emclass="sig-param">filepath</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.addImage"title="Permalink to this definition">¶</a></dt>
<dd><p>Adds an image item to the overlay.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>x</strong> (<em>number</em>) – the x pixel coordinate of the image’s top-left corner</p></li>
<li><p><strong>y</strong> (<em>number</em>) – the y pixel coordinate of the image’s top-left corner</p></li>
<li><p><strong>filepath</strong> (<em>string</em>) – the image’s filepath</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
<divclass="section"id="tileset-functions">
<h4>Tileset Functions<aclass="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 won’t affect the actual tileset colors in the project. A good use of the “preview” palettes would be Day/Night tints, for example.</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getPrimaryTilesetPalettePreview</code><spanclass="sig-paren">(</span><emclass="sig-param">paletteIndex</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>paletteIndex</strong> (<em>number</em>) – the palette index</p></li>
</ul>
</dd>
<dtclass="field-even">Returns array</dt>
<ddclass="field-even"><p>array of colors. Each color is a 3-element RGB array</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setPrimaryTilesetPalettePreview</code><spanclass="sig-paren">(</span><emclass="sig-param">paletteIndex</em>, <emclass="sig-param">colors</em><spanclass="sig-paren">)</span><aclass="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 colors–it only displays these colors in the map-editing area of Porymap.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getPrimaryTilesetPalettesPreview</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Returns array</dt>
<ddclass="field-odd"><p>array of arrays of colors. Each color is a 3-element RGB array</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setPrimaryTilesetPalettesPreview</code><spanclass="sig-paren">(</span><emclass="sig-param">palettes</em><spanclass="sig-paren">)</span><aclass="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 colors–it only displays these colors in the map-editing area of Porymap.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>palettes</strong> (<em>array</em>) – array of arrays of colors. Each color is a 3-element RGB array</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getSecondaryTilesetPalettePreview</code><spanclass="sig-paren">(</span><emclass="sig-param">paletteIndex</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>paletteIndex</strong> (<em>number</em>) – the palette index</p></li>
</ul>
</dd>
<dtclass="field-even">Returns array</dt>
<ddclass="field-even"><p>array of colors. Each color is a 3-element RGB array</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setSecondaryTilesetPalettePreview</code><spanclass="sig-paren">(</span><emclass="sig-param">paletteIndex</em>, <emclass="sig-param">colors</em><spanclass="sig-paren">)</span><aclass="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 colors–it only displays these colors in the map-editing area of Porymap.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getSecondaryTilesetPalettesPreview</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Returns array</dt>
<ddclass="field-odd"><p>array of arrays of colors. Each color is a 3-element RGB array</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setSecondaryTilesetPalettesPreview</code><spanclass="sig-paren">(</span><emclass="sig-param">palettes</em><spanclass="sig-paren">)</span><aclass="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 colors–it only displays these colors in the map-editing area of Porymap.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>palettes</strong> (<em>array</em>) – array of arrays of colors. Each color is a 3-element RGB array</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getPrimaryTilesetPalette</code><spanclass="sig-paren">(</span><emclass="sig-param">paletteIndex</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>paletteIndex</strong> (<em>number</em>) – the palette index</p></li>
</ul>
</dd>
<dtclass="field-even">Returns array</dt>
<ddclass="field-even"><p>array of colors. Each color is a 3-element RGB array</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setPrimaryTilesetPalette</code><spanclass="sig-paren">(</span><emclass="sig-param">paletteIndex</em>, <emclass="sig-param">colors</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getPrimaryTilesetPalettes</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Returns array</dt>
<ddclass="field-odd"><p>array of arrays of colors. Each color is a 3-element RGB array</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setPrimaryTilesetPalettes</code><spanclass="sig-paren">(</span><emclass="sig-param">palettes</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>palettes</strong> (<em>array</em>) – array of arrays of colors. Each color is a 3-element RGB array</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getSecondaryTilesetPalette</code><spanclass="sig-paren">(</span><emclass="sig-param">paletteIndex</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>paletteIndex</strong> (<em>number</em>) – the palette index</p></li>
</ul>
</dd>
<dtclass="field-even">Returns array</dt>
<ddclass="field-even"><p>array of colors. Each color is a 3-element RGB array</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setSecondaryTilesetPalette</code><spanclass="sig-paren">(</span><emclass="sig-param">paletteIndex</em>, <emclass="sig-param">colors</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getSecondaryTilesetPalettes</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Returns array</dt>
<ddclass="field-odd"><p>array of arrays of colors. Each color is a 3-element RGB array</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setSecondaryTilesetPalettes</code><spanclass="sig-paren">(</span><emclass="sig-param">palettes</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>palettes</strong> (<em>array</em>) – array of arrays of colors. Each color is a 3-element RGB array</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getPrimaryTileset</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="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>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setPrimaryTileset</code><spanclass="sig-paren">(</span><emclass="sig-param">tileset</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.setPrimaryTileset"title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the primary tileset for the currently-opened map.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>tileset</strong> (<em>string</em>) – the tileset name</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getSecondaryTileset</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="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>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setSecondaryTileset</code><spanclass="sig-paren">(</span><emclass="sig-param">tileset</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.setSecondaryTileset"title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the secondary tileset for the currently-opened map.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>tileset</strong> (<em>string</em>) – the tileset name</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getMetatileLayerOrder</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.getMetatileLayerOrder"title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the order that metatile layers are rendered.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Return array</dt>
<ddclass="field-odd"><p>array of layers. The bottom layer is represented as 0.</p>
</dd>
</dl>
</dd></dl>
<dlclass="js function">
<dtid="map.setMetatileLayerOrder">
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setMetatileLayerOrder</code><spanclass="sig-paren">(</span><emclass="sig-param">order</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.setMetatileLayerOrder"title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the order that metatile layers are rendered.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>array</strong>– array of layers. The bottom layer is represented as 0.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="js function">
<dtid="map.getMetatileLayerOpacity">
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getMetatileLayerOpacity</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.getMetatileLayerOpacity"title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the opacities that metatile layers are rendered with.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Return array</dt>
<ddclass="field-odd"><p>array of opacities for each layer. The bottom layer is the first element.</p>
</dd>
</dl>
</dd></dl>
<dlclass="js function">
<dtid="map.setMetatileLayerOpacity">
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setMetatileLayerOpacity</code><spanclass="sig-paren">(</span><emclass="sig-param">opacities</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.setMetatileLayerOpacity"title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the opacities that metatile layers are rendered with.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>array</strong>– array of opacities for each layer. The bottom layer is the first element.</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getGridVisibility</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.getGridVisibility"title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the visibility of the map grid overlay.</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setGridVisibility</code><spanclass="sig-paren">(</span><emclass="sig-param">visible</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.setGridVisibility"title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the visibility of the map grid overlay.</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getBorderVisibility</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.getBorderVisibility"title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the visibility of the map’s border.</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setBorderVisibility</code><spanclass="sig-paren">(</span><emclass="sig-param">visible</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.setBorderVisibility"title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the visibility of the map’s border.</p>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">getSmartPathsEnabled</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.getSmartPathsEnabled"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setSmartPathsEnabled</code><spanclass="sig-paren">(</span><emclass="sig-param">enabled</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.setSmartPathsEnabled"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">registerAction</code><spanclass="sig-paren">(</span><emclass="sig-param">functionName</em>, <emclass="sig-param">actionName</em>, <emclass="sig-param">shortcut = ""</em><spanclass="sig-paren">)</span><aclass="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 Porymap’s <codeclass="docutils literal notranslate"><spanclass="pre">Tools</span></code> menu. Optionally, a keyboard shortcut (e.g. <codeclass="docutils literal notranslate"><spanclass="pre">"Ctrl+P"</span></code>) can also be specified, assuming it doesn’t collide with any existing shortcuts used by Porymap.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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 <codeclass="docutils literal notranslate"><spanclass="pre">Tools</span></code> menu</p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">setTimeout</code><spanclass="sig-paren">(</span><emclass="sig-param">func</em>, <emclass="sig-param">delayMs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.setTimeout"title="Permalink to this definition">¶</a></dt>
<dd><p>This behaves essentially the same as JavaScript’s <codeclass="docutils literal notranslate"><spanclass="pre">setTimeout()</span></code> that is used in web browsers or NodeJS. The <codeclass="docutils literal notranslate"><spanclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="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 <codeclass="docutils literal notranslate"><spanclass="pre">func</span></code></p></li>
<codeclass="sig-prename descclassname">map.</code><codeclass="sig-name descname">log</code><spanclass="sig-paren">(</span><emclass="sig-param">message</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#map.log"title="Permalink to this definition">¶</a></dt>
<dd><p>Logs a message to the Porymap log file. This is useful for debugging custom scripts.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Arguments</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>message</strong> (<em>string</em>) – the message to log</p></li>
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.