2 lines
3.4 KiB
JavaScript
2 lines
3.4 KiB
JavaScript
import{_ as e,c as a,o as t,a as n}from"./app.54d5a277.js";const f='{"title":"Project Entry","description":"","frontmatter":{},"headers":[{"level":2,"title":"Required Exports","slug":"required-exports"},{"level":3,"title":"getInitialLayers","slug":"getinitiallayers"},{"level":3,"title":"hasWon","slug":"haswon"},{"level":3,"title":"fixOldSave","slug":"fixoldsave"}],"relativePath":"guide/project-entry.md"}',s={},o=n(`<h1 id="project-entry" tabindex="-1">Project Entry <a class="header-anchor" href="#project-entry" aria-hidden="true">#</a></h1><p>This is a TypeScript file containing the non-static parts of your project, and acts as the entry point for it.</p><p>It is stored at <code>/src/data/projEntry.jsx</code>.</p><p>This file has 3 things it must export, but beyond that can export anything the creator wants it to. Typically in addition to the required 3, the initial/"main" layer will be exported. Typically utilites belong in <code>common.tsx</code>, which exists next to <code>projEntry.tsx</code>.</p><h2 id="required-exports" tabindex="-1">Required Exports <a class="header-anchor" href="#required-exports" aria-hidden="true">#</a></h2><h3 id="getinitiallayers" tabindex="-1">getInitialLayers <a class="header-anchor" href="#getinitiallayers" aria-hidden="true">#</a></h3><ul><li>Type: <code>(player: Partial<PlayerData>) => GenericLayer[]</code></li></ul><p>A function that is given a player save data object currently being loaded, and returns a list of layers that should be active for that player. If a project does not have dynamic layers, this should always return a list of all layers.</p><h3 id="haswon" tabindex="-1">hasWon <a class="header-anchor" href="#haswon" aria-hidden="true">#</a></h3><ul><li>Type: <code>ComputedRef<boolean></code></li></ul><p>A computed ref whose value is true whenever the game is over.</p><p>For example, in a game where the goal is to have a resource reach 10:</p><div class="language-ts"><pre><code><span class="token keyword">export</span> <span class="token keyword">const</span> hasWon <span class="token operator">=</span> <span class="token function">computed</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> Decimal<span class="token punctuation">.</span><span class="token function">gte</span><span class="token punctuation">(</span>resource<span class="token punctuation">.</span>value<span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
</code></pre></div><h3 id="fixoldsave" tabindex="-1">fixOldSave <a class="header-anchor" href="#fixoldsave" aria-hidden="true">#</a></h3><ul><li>Type: <code>(oldVersion: string | undefined, player: Partial<PlayerData>) => void</code></li></ul><p>This function will be run whenever a save is loaded that has a different version than the one in <a href="./project-info.html#versionnumber">project info</a>. It will be given the old version number, and the player save data object currently being loaded.</p><p>The purpose of this function is to perform any necessary migrations, such as capping a resource that accidentally inflated in a previous version of the project. By default it will do nothing.</p>`,17),r=[o];function i(l,p,c,d,h,u){return t(),a("div",null,r)}var g=e(s,[["render",i]]);export{f as __pageData,g as default};
|