<?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=User%3AImbion%2FSandbox</id>
	<title>User:Imbion/Sandbox - 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=User%3AImbion%2FSandbox"/>
	<link rel="alternate" type="text/html" href="https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=User:Imbion/Sandbox&amp;action=history"/>
	<updated>2026-07-31T14:37:50Z</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=User:Imbion/Sandbox&amp;diff=2712&amp;oldid=prev</id>
		<title>Imbion at 00:35, 18 June 2025</title>
		<link rel="alternate" type="text/html" href="https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=User:Imbion/Sandbox&amp;diff=2712&amp;oldid=prev"/>
		<updated>2025-06-18T00:35:32Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&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: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:35, 18 June 2025&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-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; 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;This is my sandbox. For article draft shenanigans and the like, and also some of my own personal notes on PMDO modding.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; 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;This is my sandbox. For article draft shenanigans and the like, and also some of my own personal notes on PMDO modding.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; 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; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; 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;&#039;&#039;&#039;Subpages:&#039;&#039;&#039; [[User:Imbion/Sandbox/Dungeon Ref|Dungeon Ref]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; 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;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; 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;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; 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;== Exiting Dungeon Segments ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; 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;== Exiting Dungeon Segments ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Imbion</name></author>
	</entry>
	<entry>
		<id>https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=User:Imbion/Sandbox&amp;diff=2703&amp;oldid=prev</id>
		<title>Imbion: Created page with &quot;This is my sandbox. For article draft shenanigans and the like, and also some of my own personal notes on PMDO modding.  == Exiting Dungeon Segments == Once you&#039;ve created a dungeon, you might notice that when you leave a segment the game simply stops execution. This is because we need to tell the game what to do upon exiting a segment through lua scripting.  === Understanding ExitSegment === Contained in the scripting file for your zone, &lt;code&gt;init.lua&lt;/code&gt;, is the Ex...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=User:Imbion/Sandbox&amp;diff=2703&amp;oldid=prev"/>
		<updated>2025-06-04T19:23:06Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;This is my sandbox. For article draft shenanigans and the like, and also some of my own personal notes on PMDO modding.  == Exiting Dungeon Segments == Once you&amp;#039;ve created a dungeon, you might notice that when you leave a segment the game simply stops execution. This is because we need to tell the game what to do upon exiting a segment through lua scripting.  === Understanding ExitSegment === Contained in the scripting file for your zone, &amp;lt;code&amp;gt;init.lua&amp;lt;/code&amp;gt;, is the Ex...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is my sandbox. For article draft shenanigans and the like, and also some of my own personal notes on PMDO modding.&lt;br /&gt;
&lt;br /&gt;
== Exiting Dungeon Segments ==&lt;br /&gt;
Once you&amp;#039;ve created a dungeon, you might notice that when you leave a segment the game simply stops execution. This is because we need to tell the game what to do upon exiting a segment through lua scripting.&lt;br /&gt;
&lt;br /&gt;
=== Understanding ExitSegment ===&lt;br /&gt;
Contained in the scripting file for your zone, &amp;lt;code&amp;gt;init.lua&amp;lt;/code&amp;gt;, is the ExitSegment function. This function is what the game uses to decide what to do when you leave a segment.&lt;br /&gt;
&lt;br /&gt;
This function receives the following information from the game when exiting a segment, storing them in a variable we can reference inside of the function itself:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;zone&amp;lt;/code&amp;gt;: The zone we currently exited.&lt;br /&gt;
* &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;: The outcome of the dungeon exploration - Most relevant, this lets us check whenever the segment was cleared or if the player was defeated.&lt;br /&gt;
* &amp;lt;code&amp;gt;rescue&amp;lt;/code&amp;gt;: Tells us whenever we&amp;#039;re rescuing someone or not. This is true if we are rescuing, and false if we are not.&lt;br /&gt;
* &amp;lt;code&amp;gt;segmentID&amp;lt;/code&amp;gt;: A number that tells us what segment of the dungeon we&amp;#039;re exiting from, based on the ordering in the mod editor. It starts at 0 and counts up by one per next segment. &lt;br /&gt;
* &amp;lt;code&amp;gt;mapID&amp;lt;/code&amp;gt;: Says the map ID that we just exited from. Isn&amp;#039;t referenced most of the time. &lt;br /&gt;
&lt;br /&gt;
In order to tell the game what to do, we need to check if these variables have a certain value.&lt;br /&gt;
&lt;br /&gt;
=== An Example ===&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s take a look at how the &amp;lt;code&amp;gt;ExitSegment&amp;lt;/code&amp;gt; function of &amp;#039;&amp;#039;Faded Trail&amp;#039;&amp;#039; works. We use a &amp;lt;code&amp;gt;if...elseif...else&amp;lt;/code&amp;gt; block in order to branch through our different choices.&lt;br /&gt;
&lt;br /&gt;
First, we want to check if we are in rescue mode, and succeeded on the rescue:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local exited = COMMON.ExitDungeonMissionCheck(result, rescue, zone.ID, segmentID)&lt;br /&gt;
  if exited == true then&lt;br /&gt;
    --do nothing&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You only require this part of the block if your dungeon should support rescues.&lt;br /&gt;
&lt;br /&gt;
If exited is false, then we continue along the statement. This branch is taken if the dungeon was not cleared.:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  elseif result ~= RogueEssence.Data.GameProgress.ResultType.Cleared then&lt;br /&gt;
    COMMON.EndDungeonDay(result, SV.checkpoint.Zone, SV.checkpoint.Segment, SV.checkpoint.Map, SV.checkpoint.Entry)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The dungeon day is ended, and the player is sent back to their last checkpoint with punishments applied.&lt;br /&gt;
&lt;br /&gt;
If the above is false, then we enter into a branch that holds the results if we cleared the dungeon. So, all other results under this one else assume the player has cleared the dungeon.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Faded Trail&amp;#039;&amp;#039; is a dungeon with an alternative dungeon segment that the player can take. We would like to do something different if the player clears the alternative segment. The default segment, &amp;#039;&amp;#039;Faded Trail&amp;#039;&amp;#039;, is segment 0, while the alternative segment, &amp;#039;&amp;#039;Hidden Trail&amp;#039;&amp;#039;, is segment 1.&lt;br /&gt;
&lt;br /&gt;
For segment 0, we just want to send the player to the forest camp:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    if segmentID == 0 then&lt;br /&gt;
      COMMON.EndDungeonDay(result, &amp;#039;guildmaster_island&amp;#039;, -1, 4, 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For segment 1, we want the player to go back to the island entrance and unlock a new dungeon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    elseif segmentID == 1 then&lt;br /&gt;
      COMMON.UnlockWithFanfare(&amp;#039;faultline_ridge&amp;#039;, true)&lt;br /&gt;
      COMMON.EndDungeonDay(result, &amp;#039;guildmaster_island&amp;#039;, -1, 1, 3)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we make our last else be a fallback function that sends the player to their last checkpoint:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    else&lt;br /&gt;
      PrintInfo(&amp;quot;No exit procedure found!&amp;quot;)&lt;br /&gt;
	  COMMON.EndDungeonDay(result, SV.checkpoint.Zone, SV.checkpoint.Segment, SV.checkpoint.Map, SV.checkpoint.Entry)&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Blueprint ===&lt;br /&gt;
Putting it together, we get this psuedocode blueprint of what occurs while running &amp;lt;code&amp;gt;ExitSegment&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  --first check for rescue flag; if we&amp;#039;re in rescue mode then take a different path&lt;br /&gt;
  local exited = COMMON.ExitDungeonMissionCheck(result, rescue, zone.ID, segmentID) --check if we cleared while doing a rescue&lt;br /&gt;
  if exited == true then&lt;br /&gt;
        --do nothing; this is a dummy branch to stop us from going through the other branches&lt;br /&gt;
   elseif result ~= RogueEssence.Data.GameProgress.ResultType.Cleared then -- resolves true if the dungeon was not cleared&lt;br /&gt;
        --end the dungeon day by sending the player back to their last checkpoint, since they didn&amp;#039;t clear the dungeon&lt;br /&gt;
         COMMON.EndDungeonDay(result, SV.checkpoint.Zone, SV.checkpoint.Segment, SV.checkpoint.Map, SV.checkpoint.Entry)&lt;br /&gt;
   else -- we didn&amp;#039;t resolve true for being in rescue or losing the dungeon, so we must have cleared the dungeon&lt;br /&gt;
         -- now we will check what segment we took, so we can make the game do what we want to depending on the segment&lt;br /&gt;
         if segmentID == 0 then&lt;br /&gt;
            -- do things for exiting on segment 0&lt;br /&gt;
         elseif segmentID == 1 then&lt;br /&gt;
            -- do things for exiting on segment 1&lt;br /&gt;
         elseif .... -- continue checking likewise for all the segments we have&lt;br /&gt;
         else -- this is a fallback branch, in case we went through all of the branches and hit nothing (which should not happen!)&lt;br /&gt;
                 PrintInfo(&amp;quot;No exit procedure found!&amp;quot;)&lt;br /&gt;
                 -- just send the player to their last checkpoint&lt;br /&gt;
	             COMMON.EndDungeonDay(result, SV.checkpoint.Zone, SV.checkpoint.Segment, SV.checkpoint.Map, SV.checkpoint.Entry)&lt;br /&gt;
         end&lt;br /&gt;
   end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Imbion</name></author>
	</entry>
</feed>