10 lines
5.4 KiB
JavaScript
10 lines
5.4 KiB
JavaScript
import{_ as e,c as s,o as a,a as t}from"./app.e9531dc8.js";const b=JSON.parse('{"title":"Clickables","description":"","frontmatter":{},"headers":[],"relativePath":"public/lit/docs/clickables.md","lastUpdated":null}'),l={name:"public/lit/docs/clickables.md"},n=t(`<h1 id="clickables" tabindex="-1">Clickables <a class="header-anchor" href="#clickables" aria-hidden="true">#</a></h1><p>Clickables are any kind of thing that you can click for an effect. They're a more generalized version of Buyables.</p><p>DO NOT USE THESE TO MAKE THINGS THAT YOU CLICK REPEATEDLY FOR A BONUS BECAUSE THOSE ARE AWFUL.</p><p>There are several differences between the two. One is that a buyable's saved data is its amount as a <code>Decimal</code>, while Clickables store a "state" which can be a number or string, but not <code>Decimal</code>, array, or object). Buyables have a number of extra features which you can see on their page. Clickables also have a smaller default size.</p><p>Useful functions for dealing with achievements and implementing their effects:</p><ul><li>getClickableState(layer, id): get the state of the clickable the player has</li><li>setClickableState(layer, id, state): set the state of the buyable the player has</li><li>clickableEffect(layer, id): Returns the current effects of the clickable, if any.</li></ul><p>Clickables should be formatted like this:</p><div class="language-js"><button class="copy"></button><span class="lang">js</span><pre><code><span class="line"><span style="color:#FFCB6B;">clickables</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>
|
|
<span class="line"><span style="color:#F07178;"> </span><span style="color:#FFCB6B;">rows</span><span style="color:#89DDFF;">:</span><span style="color:#F07178;"> # </span><span style="color:#89DDFF;">of</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">rows</span><span style="color:#89DDFF;">,</span></span>
|
|
<span class="line"><span style="color:#F07178;"> </span><span style="color:#FFCB6B;">cols</span><span style="color:#89DDFF;">:</span><span style="color:#F07178;"> # </span><span style="color:#89DDFF;">of</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">columns</span><span style="color:#89DDFF;">,</span></span>
|
|
<span class="line"><span style="color:#F07178;"> </span><span style="color:#F78C6C;">11</span><span style="color:#F07178;">: </span><span style="color:#89DDFF;">{</span></span>
|
|
<span class="line"><span style="color:#F07178;"> display</span><span style="color:#89DDFF;">()</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">{</span><span style="color:#89DDFF;">return</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">"</span><span style="color:#C3E88D;">Blah</span><span style="color:#89DDFF;">"</span><span style="color:#89DDFF;">},</span></span>
|
|
<span class="line"><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">etc</span></span>
|
|
<span class="line"><span style="color:#F07178;"> </span><span style="color:#89DDFF;">}</span></span>
|
|
<span class="line"><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">etc</span></span>
|
|
<span class="line"><span style="color:#89DDFF;">}</span></span>
|
|
<span class="line"></span></code></pre></div><p>Features:</p><ul><li><p>title: <strong>optional</strong>. displayed at the top in a larger font. It can also be a function that returns updating text.</p></li><li><p>effect(): <strong>optional</strong>. A function that calculates and returns the current values of bonuses of this clickable. Can return a value or an object containing multiple values.</p></li><li><p>display(): A function returning everything that should be displayed on the clickable after the title, likely changing based on its state. Can use basic HTML.</p></li><li><p>unlocked(): <strong>optional</strong>. A function returning a bool to determine if the clickable is visible or not. Default is unlocked.</p></li><li><p>canClick(): A function returning a bool to determine if you can click the clickable.</p></li><li><p>onClick(): A function that implements clicking one of the clickable.</p></li><li><p>style: <strong>optional</strong>. Applies CSS to this clickable, in the form of an object where the keys are CSS attributes, and the values are the values for those attributes (both as strings).</p></li><li><p>layer: <strong>assigned automagically</strong>. It's the same value as the name of this layer, so you can do <code>player[this.layer].points</code> or similar.</p></li><li><p>id: <strong>assigned automagically</strong>. It's the "key" which the clickable was stored under, for convenient access. The clickable in the example's id is 11.</p></li></ul><p>You can also use these features on the clickables object to add a button above all the clickables, for implementing a respec button or similar.</p><ul><li><p>masterButtonPress(): <strong>optional</strong>. If present, an additional button will appear above the clickables. Pressing it will call this function.</p></li><li><p>masterButtonText: <strong>optional</strong>. Text to display on the Master Button.</p></li><li><p>showMasterButton(): <strong>optional</strong>. A function determining whether or not to show the button. Defaults to true if absent.</p></li></ul>`,12),o=[n];function i(c,p,r,u,h,y){return a(),s("div",null,o)}const f=e(l,[["render",i]]);export{b as __pageData,f as default};
|