<?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%3AAvoiding_Desyncs</id>
	<title>Tutorial:Avoiding Desyncs - 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%3AAvoiding_Desyncs"/>
	<link rel="alternate" type="text/html" href="https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=Tutorial:Avoiding_Desyncs&amp;action=history"/>
	<updated>2026-07-31T08:16:57Z</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:Avoiding_Desyncs&amp;diff=4616&amp;oldid=prev</id>
		<title>Imbion: Imbion moved page Avoiding Desyncs to Tutorial:Avoiding Desyncs</title>
		<link rel="alternate" type="text/html" href="https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=Tutorial:Avoiding_Desyncs&amp;diff=4616&amp;oldid=prev"/>
		<updated>2025-10-16T15:46:07Z</updated>

		<summary type="html">&lt;p&gt;Imbion moved page &lt;a href=&quot;/Avoiding_Desyncs&quot; class=&quot;mw-redirect&quot; title=&quot;Avoiding Desyncs&quot;&gt;Avoiding Desyncs&lt;/a&gt; to &lt;a href=&quot;/Tutorial:Avoiding_Desyncs&quot; title=&quot;Tutorial:Avoiding Desyncs&quot;&gt;Tutorial:Avoiding Desyncs&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 15:46, 16 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>Imbion</name></author>
	</entry>
	<entry>
		<id>https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=Tutorial:Avoiding_Desyncs&amp;diff=1956&amp;oldid=prev</id>
		<title>IDK: best practices troubleshooting split</title>
		<link rel="alternate" type="text/html" href="https://wiki.pmdo.pmdcollab.org/wiki/index.php?title=Tutorial:Avoiding_Desyncs&amp;diff=1956&amp;oldid=prev"/>
		<updated>2024-03-01T00:38:22Z</updated>

		<summary type="html">&lt;p&gt;best practices troubleshooting split&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;When you watch a replay, the game loads up your adventure from how it originally started, and plays back every move you made.  Because the game is recreated down to the random seed in that adventure, the same sequence of moves will play out exactly like how you originally played it.  However, sometimes the replay will desync, because some detail of the game is different in the replay than it is when you originally played it.  Usually, this is because you upgraded the game.  But sometimes, this happens witin a version. This is a major problem, as quicksaves use replays to get you back to where you were.  This page outlines the best practices for avoiding and troubleshooting desyncs.&lt;br /&gt;
&lt;br /&gt;
= Best Practices =&lt;br /&gt;
&lt;br /&gt;
* In scripted battle events, especially those involving talking to NPCs, it is preferred to cancel the turn with &amp;lt;code&amp;gt;context.CancelState.Cancel = true&amp;lt;/code&amp;gt; if the NPC had nothing noteworthy to say.  However, if talking to that NPC would result in a meaningful state change (such as joining the party, completing a mission, giving an item, etc), you should not cancel the turn.  However, you may want to cancel the turn completion so that talking to NPCs doesn&amp;#039;t waste your turn.  Use &amp;lt;code&amp;gt;context.TurnCancel.Cancel = true&amp;lt;/code&amp;gt; to do this.&lt;br /&gt;
* Do not iterate dictionaries using &amp;lt;code&amp;gt;pair&amp;lt;/code&amp;gt;.  Dictionary tables in lua are NON-DETERMINISTIC, which means they can&amp;#039;t be trusted from replay to replay!  Instead, sort all keys in the lua table and iterate in key order. The function &amp;lt;code&amp;gt;COMMON.GetSortedKeys(dict)&amp;lt;/code&amp;gt; can do this for you.&lt;br /&gt;
* Avoid using [[Random Number Generators| non-repeatable random number generators]].&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
&lt;br /&gt;
* If you are having trouble narrowing down the issue, print the state of &amp;lt;code&amp;gt;_DATA:Save.Rand:ToString()&amp;lt;/code&amp;gt; on every turn or close to the point of desync.  The RNG&amp;#039;s state is usually the first thing to derail when a desync occurs.&lt;br /&gt;
* You can turn a replay into a quicksave using the dev mode.  This allows you to replay the game from a certain point to retrigger the desync and observe both the live play and the desynced replay to compare.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>IDK</name></author>
	</entry>
</feed>