<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.wesnoth.org/index.php?action=history&amp;feed=atom&amp;title=LuaAPI%2Ftypes%2Fmap</id>
	<title>LuaAPI/types/map - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.wesnoth.org/index.php?action=history&amp;feed=atom&amp;title=LuaAPI%2Ftypes%2Fmap"/>
	<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/map&amp;action=history"/>
	<updated>2026-05-11T05:49:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/map&amp;diff=71927&amp;oldid=prev</id>
		<title>Celtic Minstrel: /* Terrain */ Give a bit more explanation of the replace_if_failed case</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/map&amp;diff=71927&amp;oldid=prev"/>
		<updated>2023-12-17T22:19:55Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Terrain: &lt;/span&gt; Give a bit more explanation of the replace_if_failed case&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 22:19, 17 December 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l14&quot; &gt;Line 14:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The functions '''replace_base''', '''replace_overlay''', and '''replace_both''' simply add or remove a &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt; to get the intended effect, so you don't need to remember the above rules. It's especially useful if the input terrain isn't under your control.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The functions '''replace_base''', '''replace_overlay''', and '''replace_both''' simply add or remove a &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt; to get the intended effect, so you don't need to remember the above rules. It's especially useful if the input terrain isn't under your control.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Assigning terrain using the '''replace_if_failed''' function modifies the behaviour when an invalid combination is produced. In this case you should not use a terrain code that begins or ends with &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt;. The ''mode'' can be either &amp;quot;base&amp;quot; or &amp;quot;overlay&amp;quot;, and if the replacement fails because of an invalid combination, it will replace both layers instead. You can also pass &amp;quot;both&amp;quot; as the mode, though this is not very useful.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Although most overlays are defined to be placeable on any base terrain, there can also be cases where an overlay is only defined to be valid on certain base terrains. This occurs when [[TerrainWML]] is defined for the base+overlay combination instead of for the overlay alone. &lt;/ins&gt;Assigning terrain using the '''replace_if_failed''' function modifies the behaviour when an invalid combination is produced. In this case you should not use a terrain code that begins or ends with &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt;. The ''mode'' can be either &amp;quot;base&amp;quot; or &amp;quot;overlay&amp;quot;, and if the replacement fails because of an invalid combination, it will replace both layers instead. You can also pass &amp;quot;both&amp;quot; as the mode, though this is not very useful.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Celtic Minstrel</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/map&amp;diff=68233&amp;oldid=prev</id>
		<title>Celtic Minstrel: /* Terrain */ Fix formatting</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/map&amp;diff=68233&amp;oldid=prev"/>
		<updated>2021-07-02T06:26:39Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Terrain: &lt;/span&gt; Fix formatting&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 06:26, 2 July 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l8&quot; &gt;Line 8:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* ''map''[''location''] &amp;amp;larr; '''wesnoth.map.replace_overlay'''(''terrain code'')&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* ''map''[''location''] &amp;amp;larr; '''wesnoth.map.replace_overlay'''(''terrain code'')&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* ''map''[''location''] &amp;amp;larr; '''wesnoth.map.replace_both'''(''terrain code'')&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* ''map''[''location''] &amp;amp;larr; '''wesnoth.map.replace_both'''(''terrain code'')&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* ''map''[''location''] &amp;amp;larr; '''wesnoth.map.replace_if_failed(''terrain code'', ''mode'')&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* ''map''[''location''] &amp;amp;larr; '''wesnoth.map.replace_if_failed&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;(''terrain code'', ''mode'')&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Look up or modify the terrain on the given hex. When assigning a terrain code, the replacement method is determined by the &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt; character in the code. If the terrain code starts with &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt;, only the overlay will be replaced. If the code ends with &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt;, only the base will be replaced. If it has &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt; in the middle or does not have &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt; at all, then both layers will be replaced (in the latter case, any existing overlay is removed). If the assignment ends up producing an invalid combination, it will be ignored.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Look up or modify the terrain on the given hex. When assigning a terrain code, the replacement method is determined by the &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt; character in the code. If the terrain code starts with &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt;, only the overlay will be replaced. If the code ends with &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt;, only the base will be replaced. If it has &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt; in the middle or does not have &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt; at all, then both layers will be replaced (in the latter case, any existing overlay is removed). If the assignment ends up producing an invalid combination, it will be ignored.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Celtic Minstrel</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/map&amp;diff=68200&amp;oldid=prev</id>
		<title>Celtic Minstrel: Categorize</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/map&amp;diff=68200&amp;oldid=prev"/>
		<updated>2021-06-30T02:34:55Z</updated>

		<summary type="html">&lt;p&gt;Categorize&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 02:34, 30 June 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l59&quot; &gt;Line 59:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 59:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Convert the map to a string. This is usually needed by map generation scripts to pass the map on to the engine once the generation has completed.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Convert the map to a string. This is usually needed by map generation scripts to pass the map on to the engine once the generation has completed.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Lua Reference]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Celtic Minstrel</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/map&amp;diff=68132&amp;oldid=prev</id>
		<title>Celtic Minstrel: Document the map userdata</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/map&amp;diff=68132&amp;oldid=prev"/>
		<updated>2021-06-24T17:59:21Z</updated>

		<summary type="html">&lt;p&gt;Document the map userdata&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
The '''map''' userdata provides direct access to the Wesnoth map. Functions in the [[LuaAPI/wesnoth/map|map]] module that take a map as the first parameter can also be called as methods on the map userdata.&lt;br /&gt;
&lt;br /&gt;
=== Terrain ===&lt;br /&gt;
&lt;br /&gt;
* ''map''[''location''] &amp;amp;harr; ''terrain code''&lt;br /&gt;
* ''map''[''location''] &amp;amp;larr; '''wesnoth.map.replace_base'''(''terrain code'')&lt;br /&gt;
* ''map''[''location''] &amp;amp;larr; '''wesnoth.map.replace_overlay'''(''terrain code'')&lt;br /&gt;
* ''map''[''location''] &amp;amp;larr; '''wesnoth.map.replace_both'''(''terrain code'')&lt;br /&gt;
* ''map''[''location''] &amp;amp;larr; '''wesnoth.map.replace_if_failed(''terrain code'', ''mode'')&lt;br /&gt;
&lt;br /&gt;
Look up or modify the terrain on the given hex. When assigning a terrain code, the replacement method is determined by the &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt; character in the code. If the terrain code starts with &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt;, only the overlay will be replaced. If the code ends with &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt;, only the base will be replaced. If it has &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt; in the middle or does not have &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt; at all, then both layers will be replaced (in the latter case, any existing overlay is removed). If the assignment ends up producing an invalid combination, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
The functions '''replace_base''', '''replace_overlay''', and '''replace_both''' simply add or remove a &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt; to get the intended effect, so you don't need to remember the above rules. It's especially useful if the input terrain isn't under your control.&lt;br /&gt;
&lt;br /&gt;
Assigning terrain using the '''replace_if_failed''' function modifies the behaviour when an invalid combination is produced. In this case you should not use a terrain code that begins or ends with &amp;lt;tt&amp;gt;^&amp;lt;/tt&amp;gt;. The ''mode'' can be either &amp;quot;base&amp;quot; or &amp;quot;overlay&amp;quot;, and if the replacement fails because of an invalid combination, it will replace both layers instead. You can also pass &amp;quot;both&amp;quot; as the mode, though this is not very useful.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local replacement_terrain = 'Gg^Ve'&lt;br /&gt;
-- On (3,3), replace both layers&lt;br /&gt;
wesnoth.current.map[{3,3}] = wesnoth.map.replace_both(replacement_terrain)&lt;br /&gt;
-- On (4,7), replace only the overlay&lt;br /&gt;
wesnoth.current.map[{4,7}] = wesnoth.map.replace_overlay(replacement_terrain)&lt;br /&gt;
-- On (21,12), replace only the base&lt;br /&gt;
wesnoth.current.map[{21,12}] = wesnoth.map.replace_base(replacement_terrain)&lt;br /&gt;
-- On (15,9), replace only the overlay if possible, otherwise both&lt;br /&gt;
wesnoth.current.map[{15,9}] = wesnoth.map.replace_if_failed(replacement_terrain, 'overlay')&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Map Size ===&lt;br /&gt;
&lt;br /&gt;
* ''map''.'''width''' &amp;amp;rarr; ''size''&lt;br /&gt;
* ''map''.'''height''' &amp;amp;rarr; ''size''&lt;br /&gt;
* ''map''.'''playable_width''' &amp;amp;rarr; ''size''&lt;br /&gt;
* ''map''.'''playable_height''' &amp;amp;rarr; ''size''&lt;br /&gt;
* ''map''.'''border_size''' &amp;amp;rarr; ''size''&lt;br /&gt;
&lt;br /&gt;
Get the size of the map. These satisfy the following identities:&lt;br /&gt;
&lt;br /&gt;
 width = playable_width + 2 * border_size&lt;br /&gt;
 height = playable_height + 2 * border_size&lt;br /&gt;
&lt;br /&gt;
=== Special Locations ===&lt;br /&gt;
&lt;br /&gt;
* ''map''.'''special_locations'''[''id''] &amp;amp;harr; ''location''&lt;br /&gt;
&lt;br /&gt;
This is a table containing all the special locations set in the map data, including side starting locations, indexed by their key. (Side starting locations are indexed by the side number.) It's writable, so you can modify them or add new ones on the fly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
-- Get the starting position of side 3&lt;br /&gt;
local enemy_start = wesnoth.current.map.special_locations[3]&lt;br /&gt;
-- Get a named location, &amp;quot;spire&amp;quot;, from the map data&lt;br /&gt;
local destination = wesnoth.current.map.special_locations.spire&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Map Data ===&lt;br /&gt;
&lt;br /&gt;
* ''map''.'''data''' &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
Convert the map to a string. This is usually needed by map generation scripts to pass the map on to the engine once the generation has completed.&lt;/div&gt;</summary>
		<author><name>Celtic Minstrel</name></author>
		
	</entry>
</feed>