</svg></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><buttontype="button"class="VPNavBarHamburger hamburger"aria-label="mobile navigation"aria-expanded="false"aria-controls="VPNavScreen"data-v-a0fd61f4data-v-e5dd9c1c><spanclass="container"data-v-e5dd9c1c><spanclass="top"data-v-e5dd9c1c></span><spanclass="middle"data-v-e5dd9c1c></span><spanclass="bottom"data-v-e5dd9c1c></span></span></button></div></div></div></div><!----></header><divclass="VPLocalNav fixed reached-top"data-v-5a346dfedata-v-79c8c1df><!----><divclass="VPLocalNavOutlineDropdown"style="--vp-vh:0px;"data-v-79c8c1dfdata-v-1c15a60a><buttondata-v-1c15a60a>Return to top</button><!----></div></div><!----><divclass="VPContent"id="VPContent"data-v-5a346dfedata-v-669faec9><divclass="VPDoc has-aside"data-v-669faec9data-v-6b87e69f><!--[--><!--]--><divclass="container"data-v-6b87e69f><divclass="aside"data-v-6b87e69f><divclass="aside-curtain"data-v-6b87e69f></div><divclass="aside-container"data-v-6b87e69f><divclass="aside-content"data-v-6b87e69f><divclass="VPDocAside"data-v-6b87e69fdata-v-3f215769><!--[--><!--]--><!--[--><!--]--><divclass="VPDocAsideOutline"role="navigation"data-v-3f215769data-v-d330b1bb><divclass="content"data-v-d330b1bb><divclass="outline-marker"data-v-d330b1bb></div><divclass="outline-title"role="heading"aria-level="2"data-v-d330b1bb>On this page</div><navaria-labelledby="doc-outline-aria-label"data-v-d330b1bb><spanclass="visually-hidden"id="doc-outline-aria-label"data-v-d330b1bb> Table of Contents for current page </span><ulclass="root"data-v-d330b1bbdata-v-d0ee3533><!--[--><!--]--></ul></nav></div></div><!--[--><!--]--><divclass="spacer"data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><divclass="content"data-v-6b87e69f><divclass="content-container"data-v-6b87e69f><!--[--><!--]--><!----><mainclass="main"data-v-6b87e69f><divstyle="position:relative;"class="vp-doc _public_gamedevtree_docs_layer-features"data-v-6b87e69f><div><h1id="layer-features"tabindex="-1">Layer Features <aclass="header-anchor"href="#layer-features"aria-label="Permalink to "Layer Features""></a></h1><p>This is a more comprehensive list of established features to add to layers. You can add more freely, if you want to have other functions or values associated with your layer. These have special functionality, though.</p><p>You can make almost any value dynamic by using a function in its place, including all display strings and styling/color features.</p><p>Key:</p><ul><li>No label: This is required and the game will crash if it isn't included.</li><li><strong>sometimes required</strong>: This is may be required, depending on other things in the layer.</li><li><strong>optional</strong>: You can leave this out if you don't intend to use that feature for the layer.</li></ul><h2id="layer-definition-features"tabindex="-1">Layer Definition features <aclass="header-anchor"href="#layer-definition-features"aria-label="Permalink to "Layer Definition features""></a></h2><ul><li><p>layer: <strong>Assigned automagically</strong>. It's the same value as the name of this layer, so you can do player[this.layer].points or similar to access the save value. It makes copying code to new layers easier. It is also assigned to all upgrades and buyables and such.</p></li><li><p>name: <strong>Optional</strong>, used in reset confirmations (and maybe other places). If absent, it just uses the layer's id.</p></li><li><p>startData(): A function to return the default save data for this layer. Add any variables you have to it. Any nonstandard Decimal variables need to be added to convertToDecimal as well. Standard values: Required: unlocked: a bool determining if this layer is unlocked or not points: a Decimal, the main currency for the layer Optional: total: A Decimal, tracks total amount of main prestige currency best: A Decimal, tracks highest amount of main prestige currency unlockOrder: used to keep
and statistics). Side layers are not affected by resets unless you add a doReset to them.
</code></pre></li><li><p>resource: Name of the main currency you gain by resetting on this layer.</p></li><li><p>effect(): <strong>optional</strong>, A function that calculates and returns the current values of any bonuses inherent to the main currency. Can return a value or an object containing multiple values. <em>You will also have to implement the effect where it is applied.</em></p></li><li><p>effectDescription: <strong>optional</strong>, A function that returns a description of this effect. If the text stays constant, it can just be a string.</p></li><li><p>layerShown(): A function returning a bool which determines if this layer's node should be visible on the tree. It can also return "ghost", which will hide the layer, but its node will still take up space in the tree.</p></li><li><p>hotkeys: <strong>optional</strong>, An array containing information on any hotkeys associated with this layer:</p><divclass="language-js vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">js</span><preclass="shiki github-dark vp-code-dark"><code><spanclass="line"><spanstyle="color:#B392F0;">hotkeys</span><spanstyle="color:#E1E4E8;">: [</span></span>
<spanclass="line"><spanstyle="color:#E1E4E8;"> {key: </span><spanstyle="color:#9ECBFF;">"p"</span><spanstyle="color:#E1E4E8;">, </span><spanstyle="color:#6A737D;">// What the hotkey button is. Use uppercase if it's combined with shift, or "ctrl+x" if ctrl is.</span></span>
<spanclass="line"><spanstyle="color:#E1E4E8;"> desc: </span><spanstyle="color:#9ECBFF;">"p: reset your points for prestige points"</span><spanstyle="color:#E1E4E8;">, </span><spanstyle="color:#6A737D;">// The description of the hotkey used in the How To Play</span></span>
<spanclass="line"><spanstyle="color:#E1E4E8;"></span><spanstyle="color:#B392F0;">onPress</span><spanstyle="color:#E1E4E8;">(){</span><spanstyle="color:#F97583;">if</span><spanstyle="color:#E1E4E8;"> (player.p.unlocked) </span><spanstyle="color:#B392F0;">doReset</span><spanstyle="color:#E1E4E8;">(</span><spanstyle="color:#9ECBFF;">"p"</span><spanstyle="color:#E1E4E8;">)}}, </span><spanstyle="color:#6A737D;">// This function is called when the hotkey is pressed.</span></span>
<spanclass="line"><spanstyle="color:#24292E;"> {key: </span><spanstyle="color:#032F62;">"p"</span><spanstyle="color:#24292E;">, </span><spanstyle="color:#6A737D;">// What the hotkey button is. Use uppercase if it's combined with shift, or "ctrl+x" if ctrl is.</span></span>
<spanclass="line"><spanstyle="color:#24292E;"> desc: </span><spanstyle="color:#032F62;">"p: reset your points for prestige points"</span><spanstyle="color:#24292E;">, </span><spanstyle="color:#6A737D;">// The description of the hotkey used in the How To Play</span></span>
<spanclass="line"><spanstyle="color:#24292E;"></span><spanstyle="color:#6F42C1;">onPress</span><spanstyle="color:#24292E;">(){</span><spanstyle="color:#D73A49;">if</span><spanstyle="color:#24292E;"> (player.p.unlocked) </span><spanstyle="color:#6F42C1;">doReset</span><spanstyle="color:#24292E;">(</span><spanstyle="color:#032F62;">"p"</span><spanstyle="color:#24292E;">)}}, </span><spanstyle="color:#6A737D;">// This function is called when the hotkey is pressed.</span></span>
<spanclass="line"><spanstyle="color:#24292E;">],</span></span></code></pre></div></li><li><p>style: <strong>optional</strong>, a "CSS object" where the keys are CSS attributes ,containing any CSS that should affect this layer's entire tab.</p></li><li><p>tabFormat: <strong>optional</strong>, use this if you want to add extra things to your tab or change the layout. <ahref="./custom-tab-layouts">See here for more info.</a></p></li><li><p>midsection: <strong>optional</strong>, an alternative to tabFormat, which is inserted in between Milestones and Buyables in the standard tab layout. (cannot do subtabs)</p></li></ul><h2id="big-features-all-optional"tabindex="-1">Big features (all optional) <aclass="header-anchor"href="#big-features-all-optional"aria-label="Permalink to "Big features (all optional)""></a></h2><ul><li><p>upgrades: A grid of one-time purchases which can have unique upgrade conditions, currency costs, and bonuses. <ahref="./upgrades">Explanations are in a separate file.</a></p></li><li><p>milestones: A list of bonuses gained upon reaching certain thresholds of a resource. Often used for automation/QOL. <ahref="./milestones">Explanations are in a separate file.</a></p></li><li><p>challenges: The player can enter challenges, which make the game harder. If they reach a goal and beat the challenge, they recieve a bonus. <ahref="./challenges">Explanations are in a separate file.</a></p></li><li><p>buyables: Effectively upgrades that can be bought multiple times, and are optionally respeccable. Many uses. <ahref="./buyables">Explanations are in a separate file.</a></p></li><li><p>clickables: Extremely versatile and generalized buttons which can only be clicked sometimes. <ahref="./clickables">Explanations are in a separate file.</a></p></li><li><p>microtabs: An area that functions like a set of subtabs, with buttons at the top changing the content within. (Advanced) <ahref="./subtabs-and-microtabs">Explanations are in a separate file.</a></p></li><li><p>bars: Display some information as a progress bar, gague, or similar. They are highly customizable, and can be vertical as well. <ahref="./bars">Explanations are in a separate file.</a></p></li><li><p>achievements: Kind of like milestones, but with a different display style and some other differences. Extra features are on the way at a later date! <ahref="./achievements">Explanations are in a separate file.</a></p></li><li><p>infoboxes: Displays some text in a box that can be shown or hidden. <ahref="./infoboxes">Explanations are in a separate file.</a></p></li></ul><h2id="prestige-formula-features"tabindex="-1">Prestige formula features <aclass="header-anchor"href="#prestige-formula-features"aria-label="Permalink to "Prestige formula features""></a></h2><ul><li><p>type: <strong>optional</strong>, Determines which prestige formula you use. Defaults to "none". "normal": The amount of currency you gain is independent of its current amount (like Prestige). formula before bonuses is based on <code>baseResource^exponent</code>"static": The cost is dependent on your total after reset. formula before bonuses is based on <code>base^(x^exponent)</code>"custom": You can define everything, from the calculations to the text on the button, yourself. (See more at the bottom) "none": This layer does not prestige, and therefore does not need any of the other features in this section.</p></li><li><p>baseResource: The name of the resource that determines how much of the main currency you gain on reset.</p></li><li><p>baseAmount(): A function that gets the current value of the base resource.</p></li><li><p>requires: A Decimal, the amount of the base needed to gain 1 of the prestige currency. Also the amount required to unlock the layer. You can instead make this a function, to make it harder if another layer was unlocked first (based on unlockOrder).</p></li><li><p>exponent: Used as described above.</p></li><li><p>base: <strong>sometimes required</strong>, required for &qu
resetLayerData(layer, keep), where layer is this layer, and keep is an array of the names of things to keep.
It can include things like "points", "best", "total" (for this layer's prestige currency), "upgrades",
any unique variables like "generatorPower", etc.
If you want to only keep specific upgrades or something like that, save them in a separate variable, then
call layerDataReset, and then set player[layer].upgrades to the saved upgrades.
</code></pre></li><li><p>update(diff): <strong>optional</strong>, this function is called every game tick. Use it for any passive resource production or time-based things. diff is the time since the last tick. Suggestion: use addPoints(layer, gain) when generating points to automatically update the best and total amounts.</p></li><li><p>automate(): <strong>optional</strong>, this function is called every game tick, after production. Use it to activate any autobuyers or auto-resets or similar on this layer, if appropriate.</p></li><li><p>resetsNothing: <strong>optional</strong>, returns true if this layer shouldn't trigger any resets when you prestige.</p></li><li><p>increaseUnlockOrder: <strong>optional</strong>, an array of layer ids. When this layer is unlocked for the first time, the unlockOrder value for any not-yet-unlocked layers in this list increases. This can be used to make them harder to unlock.</p></li><li><p>shouldNotify: <strong>optional</strong>, a function to return true if this layer should be highlighted in the tree. The layer will automatically be highlighted if you can buy an upgrade whether you have this or not.</p></li><li><p>componentStyles: <strong>optional</strong>, An object that contains a set of functions returning CSS objects. Each of these will be applied to any components on the layer with the type of its id. Example:</p></li></ul><divclass="language-js vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">js</span><preclass="shiki github-dark vp-code-dark"><code><spanclass="line"><spanstyle="color:#E1E4E8;"></span><spanstyle="color:#B392F0;">componentStyles</span><spanstyle="color:#E1E4E8;">: {</span></span>
<spanclass="line"><spanstyle="color:#24292E;"> },</span></span></code></pre></div><h2id="custom-prestige-type"tabindex="-1">Custom Prestige type <aclass="header-anchor"href="#custom-prestige-type"aria-label="Permalink to "Custom Prestige type""></a></h2><ul><li><p>getResetGain(): <strong>For custom prestige type</strong>, Returns how many points you should get if you reset now. You can call getResetGain(this.layer, useType = "static") or similar to calculate what your gain would be under another prestige type (provided you have all of the required features in the layer.)</p></li><li><p>getNextAt(canMax=false): <strong>For custom prestige type</strong>, Returns how many of the base currency you need to get to the next point. canMax is an optional variable used with Static-ish layers to differentiate between if it's looking for the first point you can reset at, or the requirement for any gain at all. (Supporting both is good). You can also call getNextAt(this.layer, canMax=false, useType = "static") or similar to calculate what your next at would be under another prestige type (provided you have all of the required features in the layer.)</p></li><li><p>canReset(): <strong>For custom prestige type</strong>, return true only if you have the resources required to do a prestige here.</p></li></ul></div></div></main><footerclass="VPDocFooter"data-v-6b87e69fdata-v-ef5dee53><!--[--><!--]--><divclass="edit-info"data-v-ef5dee53><!----><divclass="last-updated"data-v-ef5dee53><pclass="VPLastUpdated"data-v-ef5dee53data-v-7e05ebdb>Last updated: <timedatetime="2023-11-28T02:07:21.000Z"data-v-7e05ebdb></time></p></div></div><!----></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>