<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pmdo.pmdcollab.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Tutorial%3APatching_Ground_Map_Scripts</id>
	<title>Tutorial:Patching Ground Map Scripts - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pmdo.pmdcollab.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Tutorial%3APatching_Ground_Map_Scripts"/>
	<link rel="alternate" type="text/html" href="https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=Tutorial:Patching_Ground_Map_Scripts&amp;action=history"/>
	<updated>2026-07-31T13:44:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=Tutorial:Patching_Ground_Map_Scripts&amp;diff=4747&amp;oldid=prev</id>
		<title>Shitpost Sunkern: Shitpost Sunkern moved page Patching Ground Map Scripts to Tutorial:Patching Ground Map Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=Tutorial:Patching_Ground_Map_Scripts&amp;diff=4747&amp;oldid=prev"/>
		<updated>2025-10-20T18:52:46Z</updated>

		<summary type="html">&lt;p&gt;Shitpost Sunkern moved page &lt;a href=&quot;/Patching_Ground_Map_Scripts&quot; class=&quot;mw-redirect&quot; title=&quot;Patching Ground Map Scripts&quot;&gt;Patching Ground Map Scripts&lt;/a&gt; to &lt;a href=&quot;/Tutorial:Patching_Ground_Map_Scripts&quot; title=&quot;Tutorial:Patching Ground Map Scripts&quot;&gt;Tutorial:Patching Ground Map Scripts&lt;/a&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:52, 20 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Shitpost Sunkern</name></author>
	</entry>
	<entry>
		<id>https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=Tutorial:Patching_Ground_Map_Scripts&amp;diff=3993&amp;oldid=prev</id>
		<title>Imbion: Created page with &quot;A guide on how to patch the scripts of ground maps with a mod without overriding the entire script. == First Steps == To begin the process of adding changes, a new &lt;code&gt;init.lua&lt;/code&gt; file for the ground map must be created in the mod&#039;s script folder. From the root folder of the mod, this file is placed in &lt;code&gt;Data/Script/[dungeonNamespace]/ground/[groundMap]&lt;/code&gt;.  In this file, create a new table to store the mod functions in. This is similar to the table tha...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=Tutorial:Patching_Ground_Map_Scripts&amp;diff=3993&amp;oldid=prev"/>
		<updated>2025-08-24T20:38:23Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;A guide on how to patch the scripts of ground maps with a &lt;a href=&quot;/Mod&quot; title=&quot;Mod&quot;&gt;mod&lt;/a&gt; without overriding the entire script. == First Steps == To begin the process of adding changes, a new &amp;lt;code&amp;gt;init.lua&amp;lt;/code&amp;gt; file for the ground map must be created in the mod&amp;#039;s script folder. From the root folder of the mod, this file is placed in &amp;lt;code&amp;gt;Data/Script/[dungeonNamespace]/ground/[groundMap]&amp;lt;/code&amp;gt;.  In this file, create a new table to store the mod functions in. This is similar to the table tha...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A guide on how to patch the scripts of ground maps with a [[mod]] without overriding the entire script.&lt;br /&gt;
== First Steps ==&lt;br /&gt;
To begin the process of adding changes, a new &amp;lt;code&amp;gt;init.lua&amp;lt;/code&amp;gt; file for the ground map must be created in the mod&amp;#039;s script folder. From the root folder of the mod, this file is placed in &amp;lt;code&amp;gt;Data/Script/[dungeonNamespace]/ground/[groundMap]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In this file, create a new table to store the mod functions in. This is similar to the table that exists in the vanilla ground script files, in that it will be referenced to call the functions. The typical naming convention is to name them first the base name of the ground map, then a name referencing the mod. &lt;br /&gt;
&lt;br /&gt;
This is how &amp;lt;code&amp;gt;enable_mission_board&amp;lt;/code&amp;gt; initalizes its namespace:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
local base_camp_2_bulletin = {}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a final step, make sure to write &amp;lt;code&amp;gt;return (namespace)&amp;lt;/code&amp;gt; as the last line of the file, or otherwise the changes won&amp;#039;t work!&lt;br /&gt;
&lt;br /&gt;
== Adding New Scripts ==&lt;br /&gt;
To add new scripts, a function is added to the namespace defined in the function table. These scripts are set up in the same way that scripts are added to ground maps.&lt;br /&gt;
&lt;br /&gt;
Here is how &amp;lt;code&amp;gt;enable_mission_board&amp;lt;/code&amp;gt; adds an action to the &amp;lt;code&amp;gt;Mission_Board&amp;lt;/code&amp;gt; ground object:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
function base_camp_2_bulletin.Mission_Board_Action(obj, activator)&lt;br /&gt;
  DEBUG.EnableDbgCoro() --Enable debugging this coroutine&lt;br /&gt;
&lt;br /&gt;
  local dungeons_needed = 3 --Number of dungeons needed to unlock the Mission Board&lt;br /&gt;
&lt;br /&gt;
  local hero = CH(&amp;#039;PLAYER&amp;#039;)&lt;br /&gt;
  GROUND:CharSetAnim(hero, &amp;#039;None&amp;#039;, true)&lt;br /&gt;
&lt;br /&gt;
  if SV.MissionPrereq.NumDungeonsCompleted &amp;gt;= dungeons_needed then&lt;br /&gt;
    local menu = BoardSelectionMenu:new(COMMON.MISSION_BOARD_MISSION)&lt;br /&gt;
    UI:SetCustomMenu(menu.menu)&lt;br /&gt;
    UI:WaitForChoice()&lt;br /&gt;
  else&lt;br /&gt;
    UI:ResetSpeaker()&lt;br /&gt;
    UI:WaitShowDialogue(STRINGS:Format(MapStrings[&amp;#039;Mission_Board_Locked&amp;#039;]))&lt;br /&gt;
    UI:WaitShowDialogue(STRINGS:Format(MapStrings[&amp;#039;Mission_Board_Locked_2&amp;#039;], dungeons_needed - SV.MissionPrereq.NumDungeonsCompleted))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  GROUND:CharEndAnim(hero)&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Changing Base Scripts ==&lt;br /&gt;
In order to properly modify base scripts, &amp;lt;code&amp;gt;CURMAPSCR&amp;lt;/code&amp;gt; is used as a placeholder. This allows the mod to capture the base function that is run in the map, and then execute it after making its own changes. &lt;br /&gt;
&lt;br /&gt;
As an example, this is how &amp;lt;code&amp;gt;enable_mission_board&amp;lt;/code&amp;gt; injects some new code to run when entering the map:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
local base_enter = CURMAPSCR.Enter&lt;br /&gt;
function base_camp_2_bulletin.Enter(map)&lt;br /&gt;
    DEBUG.EnableDbgCoro() --Enable debugging this coroutine&lt;br /&gt;
&lt;br /&gt;
    if SV.MissionsEnabled == true then&lt;br /&gt;
        GROUND:Unhide(&amp;quot;Mission_Board&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if SV.TemporaryFlags.MissionCompleted then&lt;br /&gt;
        base_camp_2_bulletin.Hand_In_Missions()&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
  base_enter(map)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Here CURMAPSCR is used to store the original base camp enter function. The mod runs its own code first, and then when done runs the function from the base game in order to execute the regular code.&lt;br /&gt;
&lt;br /&gt;
[[Category:Modding]]&lt;/div&gt;</summary>
		<author><name>Imbion</name></author>
	</entry>
</feed>