<spanclass="line"><spanstyle="color:#89DDFF;">}</span></span></code></pre></div><p>This example stores the same persistent data in two locations - <code>flowers.flowers</code> and <code>flowers.job.resource</code>. We can mark the latter usage as a reference by wrapping it in the <ahref="./../../api/modules/game/persistence#nopersist">noPersist</a> utility, so it'd look like <code>resource: noPersist(flowers)</code>. Otherwise, you will encounter an error in the console when the layer is loaded:</p><p><imgsrc="/assets/persistence-error.537e237b.png"alt="Persistence Error"></p><p>Use these console errors to identify save data redundancy that needs correction. It is recommended to run the app and use the errors as a guide rather than trying to identify redundancies manually.</p><p>In addition to obtaining non-persistent refs from your persistent refs, you may need to wrap entire features containing persistent refs. For example, in Kronos, there are seven layers with "Job" features, which are combined into a dictionary in the main layer. This would cause the persistent state to appear in both layers, but you can wrap the dictionary in a noPersist call to bypass serialization, ensuring it only uses the jobs within their respective layers. Here's an example from Kronos:</p><divclass="language-ts"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">ts</span><preclass="shiki material-theme-palenight"><code><spanclass="line"><spanstyle="color:#C792EA;">const</span><spanstyle="color:#A6ACCD;"> jobs </span><spanstyle="color:#89DDFF;">=</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#82AAFF;">noPersist</span><spanstyle="color:#A6ACCD;">(</span><spanstyle="color:#89DDFF;">{</span></span>
<spanclass="line"><spanstyle="color:#89DDFF;">}</span><spanstyle="color:#A6ACCD;">) </span><spanstyle="color:#89DDFF;font-style:italic;">as</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#FFCB6B;">Record</span><spanstyle="color:#89DDFF;"><</span><spanstyle="color:#FFCB6B;">JobKeys</span><spanstyle="color:#89DDFF;">,</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#FFCB6B;">GenericJob</span><spanstyle="color:#89DDFF;">>;</span></span></code></pre></div><p>The time required for this step depends on your project structure. You can use <ahref="https://github.com/thepaperpilot/Kronos/commit/6e8bfc1a78df0a7957de06bacdabf87c688b917c"target="_blank"rel="noreferrer">this commit</a> to see all the changes made for Kronos, which used a utility function for similar features that limited the number of required changes.</p><h2id="breaking-feature-changes"tabindex="-1">Breaking feature changes <aclass="header-anchor"href="#breaking-feature-changes"aria-label="Permalink to "Breaking feature changes""></a></h2><h3id="achievements-and-milestones"tabindex="-1">Achievements and Milestones <aclass="header-anchor"href="#achievements-and-milestones"aria-label="Permalink to "Achievements and Milestones""></a></h3><p>Achievements and milestones have been merged. Any existing achievements should now have the <code>small: true</code> property set to keep the same display as before. Milestones should now use the <code>createAchievement</code> constructor instead of <code>createMilestone</code>, and they will appear and behave as before.</p><h3id="buyables"tabindex="-1">Buyables <aclass="header-anchor"href="#buyables"aria-label="Permalink to "Buyables""></a></h3><p>Buyables have been renamed to "repeatables". To update your code, you'll need to replace all references to buyable with repeatable. Additionally, various properties have been removed or changed to no longer refer to purchases:</p><ul><li><code>canAfford</code> no longer exists, and you should instead add conditions via the requirements system</li><li><code>onPurchase</code> should become <code>onClick</code></li><li><code>purchase()</code> should become <code>click()</code></li></ul><h3id="requirements"tabindex="-1">Requirements <aclass="header-anchor"href="#requirements"aria-label="Permalink to "Requirements""></a></h3><p>Many features now use <code>requirements</code> properties where before they would have a cost or other condition. The <code>requirements</code> property takes a single <code>Requirement</code> object or an array of them. Requirements make it easier to support features requiring multiple currencies or other conditions.</p><p>When coupled with the formulas system, they also allow for scaling requirements that can be calculated efficiently. Here is an example repeatable that starts by costing 100 points and gets 1.05x more expensive with each purchase, compounding. Thanks to formulas the repeatable will be able to immediately increase as many levels as the player can afford at once:</p><divclass="language-ts"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">ts</span><preclass="shiki material-theme-palenight"><code><spanclass="line"><spanstyle="color:#C792EA;">const</span><spanstyle="color:#A6ACCD;"> myRepeatable </span><spanstyle="color:#89DDFF;">=</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#82AAFF;">createRepeatable</span><spanstyle="color:#A6ACCD;">(</span><spanstyle="color:#89DDFF;">()</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#C792EA;">=></span><spanstyle="color:#A6ACCD;"> (</span><spanstyle="color:#89DDFF;">{</span></span>
<spanclass="line"><spanstyle="color:#89DDFF;">}</span><spanstyle="color:#A6ACCD;">))</span><spanstyle="color:#89DDFF;">;</span></span></code></pre></div><p>To update an existing non-scaling cost requirement, wrap your current cost function and resource property as follows:</p><divclass="language-ts"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">ts</span><preclass="shiki material-theme-palenight"><code><spanclass="line"><spanstyle="color:#C792EA;">const</span><spanstyle="color:#A6ACCD;"> upgrade </span><spanstyle="color:#89DDFF;">=</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#82AAFF;">createUpgrade</span><spanstyle="color:#A6ACCD;">(</span><spanstyle="color:#89DDFF;">()</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#C792EA;">=></span><spanstyle="color:#A6ACCD;"> (</span><spanstyle="color:#89DDFF;">{</span></span>
<spanclass="line"><spanstyle="color:#89DDFF;">}</span><spanstyle="color:#A6ACCD;">))</span><spanstyle="color:#89DDFF;">;</span></span></code></pre></div><p>For other conditions, you can use the <code>createBooleanRequirement</code> constructor instead:</p><divclass="language-ts"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">ts</span><preclass="shiki material-theme-palenight"><code><spanclass="line"><spanstyle="color:#C792EA;">const</span><spanstyle="color:#A6ACCD;"> spellExpMilestone </span><spanstyle="color:#89DDFF;">=</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#82AAFF;">createAchievement</span><spanstyle="color:#A6ACCD;">(</span><spanstyle="color:#89DDFF;">()</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#C792EA;">=></span><spanstyle="color:#A6ACCD;"> (</span><spanstyle="color:#89DDFF;">{</span></span>
<spanclass="line"><spanstyle="color:#89DDFF;">}</span><spanstyle="color:#A6ACCD;">))</span><spanstyle="color:#89DDFF;">;</span></span></code></pre></div><p>Learn more about requirements and their capabilities in <ahref="./../important-concepts/requirements">this guide page</a>.</p><h3id="formulas"tabindex="-1">Formulas <aclass="header-anchor"href="#formulas"aria-label="Permalink to "Formulas""></a></h3><p>Formulas are a new feature that allows for scaling cost or effect functions to be inverted or integrated without requiring the developer to code anything beyond the original formula. They can simplify support for "buy max" functionalities and make conversions easier to read and write.</p><p>Any cost requirements can now accept a formula instead of a cost function. The formula system can then handle determining how many purchases can be made at once. To continue the example above, here's how it would be rewritten:</p><divclass="language-ts"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">ts</span><preclass="shiki material-theme-palenight"><code><spanclass="line"><spanstyle="color:#FFCB6B;">requirements</span><spanstyle="color:#89DDFF;">:</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#82AAFF;">createCostRequirement</span><spanstyle="color:#A6ACCD;">(</span><spanstyle="color:#89DDFF;">()</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#C792EA;">=></span><spanstyle="color:#A6ACCD;"> (</span><spanstyle="color:#89DDFF;">{</span></span>
<spanclass="line"><spanstyle="color:#89DDFF;">}</span><spanstyle="color:#A6ACCD;">))</span></span></code></pre></div><p>Conversions work a bit differently. Their scaling function system has been replaced with a <code>formula</code> property that takes a lambda - it provides the input formula variable, representing the base resource, as a parameter, and you return a formula representing the amount of the gain resource that could be converted. For example, if you previously had code like this:</p><divclass="language-ts"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">ts</span><preclass="shiki material-theme-palenight"><code><spanclass="line"><spanstyle="color:#FFCB6B;">scaling</span><spanstyle="color:#89DDFF;">:</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#82AAFF;">addSoftcap</span><spanstyle="color:#A6ACCD;">(</span><spanstyle="color:#82AAFF;">createPolynomialScaling</span><spanstyle="color:#A6ACCD;">(</span><spanstyle="color:#F78C6C;">10</span><spanstyle="color:#89DDFF;">,</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#F78C6C;">0.5</span><spanstyle="color:#A6ACCD;">)</span><spanstyle="color:#89DDFF;">,</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#F78C6C;">1e100</span><spanstyle="color:#89DDFF;">,</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#F78C6C;">0.5</span><spanstyle="color:#A6ACCD;">)</span></span></code></pre></div><p>you can now write this:</p><divclass="language-ts"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">ts</span><preclass="shiki material-theme-palenight"><code><spanclass="line"><spanstyle="color:#FFCB6B;">formula</span><spanstyle="color:#89DDFF;">:</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#A6ACCD;font-style:italic;">x</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#C792EA;">=></span><spanstyle="color:#A6ACCD;"> x</span><spanstyle="color:#89DDFF;">.</span><spanstyle="color:#82AAFF;">div</span><spanstyle="color:#A6ACCD;">(</span><spanstyle="color:#F78C6C;">10</span><spanstyle="color:#A6ACCD;">)</span><spanstyle="color:#89DDFF;">.</span><spanstyle="color:#82AAFF;">sqrt</span><spanstyle="color:#A6ACCD;">()</span><spanstyle="color:#89DDFF;">.</span><spanstyle="color:#82AAFF;">step</span><spanstyle="color:#A6ACCD;">(</span><spanstyle="color:#F78C6C;">1e100</span><spanstyle="color:#89DDFF;">,</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#A6ACCD;font-style:italic;">f</span><spanstyle="color:#A6ACCD;"></span><spanstyle="color:#C792EA;">=></span><spanstyle="color:#A6ACCD;"> f</span><spanstyle="color:#89DDFF;">.</span><spanstyle="color:#82AAFF;">sqrt</span><spanstyle="color:#A6ACCD;">())</span></span></code></pre></div><p>Learn more about formulas and their capabilities in <ahref="./../important-concepts/formulas">this guide page</a>.</p><h3id="modifiers"tabindex="-1">Modifiers <aclass="header-anchor"href="#modifiers"aria-label="Permalink to "Modifiers""></a></h3><p>Modifiers now display negative effects in red. The current implementation assumes any value that reduces the result is negative, and the output being less than the base value is a negative outcome. However, for some modifiers, this may be the opposite of what you want - for example, a cooldown being reduced below its base value is a positive effect. For those modifiers, set the <code>smallerIsBetter</code> property to <code>true</code>. This property also exists when creating collapsible modifier sections.</p><p>Modifiers have renamed their <code>revert</code> property to <code>invert</code> to match the terms used by formulas. Update any custom modifiers you've created accordingly.</p><h3id="custom-features"tabindex="-1">Custom Features <aclass="header-anchor"href="#custom-features"aria-label="Permalink to "Custom Features""></a></h3><p>Lazy proxies now call the options function with the base object as the <code>this</code> argument and the first parameter. Features with <code>options</code> functions are
<spanclass="line"><spanstyle="color:#89DDFF;">}</span></span></code></pre></div><p>This code can now be simplified to:</p><divclass="language-ts"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">ts</span><preclass="shiki material-theme-palenight"><code><spanclass="line"><spanstyle="color:#FFCB6B;">visibility</span><spanstyle="color:#89DDFF;">:</span><spanstyle="color:#A6ACCD;"> spellExpMilestone</span><spanstyle="color:#89DDFF;">.</span><spanstyle="color:#A6ACCD;">earned</span></span></code></pre></div><p>Be aware that using the computed ref directly instead of a function can cause circular dependency issues. If you encounter one while simplifying a visibility property, resolve the issue or continue using a function, returning the computed ref value.</p><h3id="custom-components"tabindex="-1">Custom Components <aclass="header-anchor"href="#custom-components"aria-label="Permalink to "Custom Components""></a></h3><p>If you created any custom features with their own Vue components, you'll need to update them to support booleans for visibility values. This means replacing <strong>ALL</strong> equality checks for specific visibilities with calls to <ahref="./../../api/modules/features/feature#isvisible">isVisible</a> and <ahref="./../../api/modules/features/feature#ishidden">isHidden</a>.</p><p>While updating your component, you may need to cast the component to <ahref="./../../api/modules/features/feature#genericcomponent">GenericComponent</a>.</p></div></div></main><footerclass="VPDocFooter"data-v-c4b0d3cfdata-v-face870a><!--[--><!--]--><divclass="edit-info"data-v-face870a><divclass="edit-link"data-v-face870a><aclass="VPLink link edit-link-button"href="https://github.com/profectus-engine/profectus-docs/edit/main/docs/guide/migrations/0-6.md"target="_blank"rel="noreferrer"data-v-face870adata-v-8f4dc553><!--[--><svgxmlns="http://www.w3.org/2000/svg"viewbox="0 0 24 24"class="edit-link-icon"aria-label="edit icon"data-v-face870a><pathd="M18,23H4c-1.7,0-3-1.3-3-3V6c0-1.7,1.3-3,3-3h7c0.6,0,1,0.4,1,1s-0.4,1-1,1H4C3.4,5,3,5.4,3,6v14c0,0.6,0.4,1,1,1h14c0.6,0,1-0.4,1-1v-7c0-0.6,0.4-1,1-1s1,0.4,1,1v7C21,21.7,19.7,23,18,23z"></path><pathd="M8,17c-0.3,0-0.5-0.1-0.7-0.3C7,16.5,6.9,16.1,7,15.8l1-4c0-0.2,0.1-0.3,0.3-0.5l9.5-9.5c1.2-1.2,3.2-1.2,4.4,0c1.2,1.2,1.2,3.2,0,4.4l-9.5,9.5c-0.1,0.1-0.3,0.2-0.5,0.3l-4,1C8.2,17,8.1,17,8,17zM9.9,12.5l-0.5,2.1l2.1-0.5l9.3-9.3c0.4-0.4,0.4-1.1,0-1.6c-0.4-0.4-1.2-0.4-1.6,0l0,0L9.9,12.5z M18.5,2.5L18.5,2.5L18.5,2.5z"></path></svg> Edit this page<!--]--><!----></a></div><divclass="last-updated"data-v-face870a><pclass="VPLastUpdated"data-v-face870adata-v-7b3ebfe1>Last updated: <timedatetime="2023-04-23T17:47:49.000Z"data-v-7b3ebfe1></time></p></div></div><divclass="prev-next"data-v-face870a><divclass="pager"data-v-face870a><aclass="pager-link prev"href="/guide/advanced-concepts/nodes"data-v-face870a><spanclass="desc"data-v-face870a>Previous page</span><spanclass="title"data-v-face870a>Nodes</span></a></div><divclass="has-prev pager"data-v-face870a><!----></div></div></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>