porymap/docs/manual/scripting-capabilities.html
2020-05-16 17:06:05 -04:00

1280 lines
No EOL
86 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>
<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#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#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#adding-deleting-events">Adding &amp; Deleting Events</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>
</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="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><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#fixed">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id1">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#id2">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#id3">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id4">3.0.1 - 2020-03-04</a><ul>
<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">3.0.0 - 2020-03-04</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id7">Breaking Changes</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id8">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id9">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id10">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id11">2.0.0 - 2019-10-16</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id12">Breaking Changes</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id13">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id14">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id15">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id16">1.2.2 - 2019-05-16</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id17">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id18">Changed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id19">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id20">1.2.1 - 2019-02-16</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id21">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id22">Fixed</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../reference/changelog.html#id23">1.2.0 - 2019-02-04</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id24">Breaking Changes</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id25">Added</a></li>
<li class="toctree-l3"><a class="reference internal" href="../reference/changelog.html#id26">Changed</a></li>
<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">1.1.0 - 2018-12-27</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">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="id1">
<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="#id1" 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="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>
</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.</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><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 that were previously-added to the map.</p>
</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><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 overlay.</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</p></li>
<li><p><strong>y</strong> (<em>number</em>) the y pixel coordinate of the text</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>
</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><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 overlay.</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</p></li>
<li><p><strong>y</strong> (<em>number</em>) the y pixel coordinate of the rectangles 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>
</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><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 overlay.</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</p></li>
<li><p><strong>y</strong> (<em>number</em>) the y pixel coordinate of the rectangles 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>
</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><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 overlay.</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</p></li>
<li><p><strong>y</strong> (<em>number</em>) the y pixel coordinate of the images top-left corner</p></li>
<li><p><strong>filepath</strong> (<em>string</em>) the images filepath</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 their palettes. 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.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>
</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>
</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.</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. 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>
</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>