Files
Basalt2/docs/.vitepress/dist/assets/references_main.md._6xfbQ0_.js
2025-09-16 17:41:40 +02:00

2 lines
18 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as a,a as t,b as r,ag as s}from"./chunks/framework.BcrMLAmg.js";const m=JSON.parse('{"title":"basalt","description":"","frontmatter":{},"headers":[],"relativePath":"references/main.md","filePath":"references/main.md","lastUpdated":1757840145000}'),l={name:"references/main.md"};function i(n,e,o,d,h,c){return r(),t("div",null,e[0]||(e[0]=[s('<h1 id="basalt" tabindex="-1">basalt <a class="header-anchor" href="#basalt" aria-label="Permalink to &quot;basalt&quot;"></a></h1><p><em>This is the UI Manager and the starting point for your project. The following functions allow you to influence the default behavior of Basalt.</em></p><p><em>Before you can access Basalt, you need to add the following code on top of your file:</em><em>What this code does is it loads basalt into the project, and you can access it by using the variable defined as &quot;basalt&quot;.</em></p><h2 id="functions" tabindex="-1">Functions <a class="header-anchor" href="#functions" aria-label="Permalink to &quot;Functions&quot;"></a></h2><table tabindex="0"><thead><tr><th>Method</th><th>Returns</th><th>Description</th></tr></thead><tbody><tr><td><a href="#basalt-create-type-properties">basalt.create</a></td><td>table</td><td>Creates a new UI element</td></tr><tr><td><a href="#basalt-createframe">basalt.createFrame</a></td><td>BaseFrame</td><td>Creates a new BaseFrame</td></tr><tr><td><a href="#basalt-getelementmanager">basalt.getElementManager</a></td><td>table</td><td>Returns the element manager</td></tr><tr><td><a href="#basalt-geterrormanager">basalt.getErrorManager</a></td><td>table</td><td>Returns the error manager</td></tr><tr><td><a href="#basalt-getmainframe">basalt.getMainFrame</a></td><td>BaseFrame</td><td>Gets or creates the main frame</td></tr><tr><td><a href="#basalt-setactiveframe-frame-setactive">basalt.setActiveFrame</a></td><td>-</td><td>Sets the active frame</td></tr><tr><td><a href="#basalt-getactiveframe-t">basalt.getActiveFrame</a></td><td>BaseFrame</td><td>Returns the active frame</td></tr><tr><td><a href="#basalt-setfocus-frame">basalt.setFocus</a></td><td>-</td><td>Sets a frame as focused</td></tr><tr><td><a href="#basalt-getfocus">basalt.getFocus</a></td><td>BaseFrame</td><td>Returns the focused frame</td></tr><tr><td><a href="#basalt-schedule-func">basalt.schedule</a></td><td>thread</td><td>Schedules a function to run in a coroutine</td></tr><tr><td><a href="#basalt-removeschedule-func">basalt.removeSchedule</a></td><td>boolean</td><td>Removes a scheduled update</td></tr><tr><td><a href="#basalt-update">basalt.update</a></td><td>-</td><td>Runs basalt once</td></tr><tr><td><a href="#basalt-stop">basalt.stop</a></td><td>-</td><td>Stops the Basalt runtime</td></tr><tr><td><a href="#basalt-run-isactive">basalt.run</a></td><td>-</td><td>Starts the Basalt runtime</td></tr><tr><td><a href="#basalt-getelementclass-name">basalt.getElementClass</a></td><td>table</td><td>Returns an element class</td></tr><tr><td><a href="#basalt-getapi-name">basalt.getAPI</a></td><td>table</td><td>Returns a Plugin API</td></tr><tr><td><a href="#basalt-onevent-eventname-callback">basalt.onEvent</a></td><td>-</td><td>Registers an event callback</td></tr><tr><td><a href="#basalt-removeevent-eventname-callback">basalt.removeEvent</a></td><td>boolean</td><td>Removes an event callback</td></tr><tr><td><a href="#basalt-triggerevent-eventname">basalt.triggerEvent</a></td><td>-</td><td>Triggers a custom event</td></tr></tbody></table><h2 id="basalt-create-type-properties" tabindex="-1">basalt.create(type, properties?) <a class="header-anchor" href="#basalt-create-type-properties" aria-label="Permalink to &quot;basalt.create(type, properties?)&quot;"></a></h2><p>Creates and returns a new UI element of the specified type.</p><h3 id="parameters" tabindex="-1">Parameters <a class="header-anchor" href="#parameters" aria-label="Permalink to &quot;Parameters&quot;"></a></h3><ul><li><code>type</code> <code>string</code> The type of element to create (e.g. &quot;Button&quot;, &quot;Label&quot;, &quot;BaseFrame&quot;)</li><li><code>properties</code> <em>(optional)</em> <code>string|table</code> Optional name for the element or a table with properties to initialize the element with</li></ul><h3 id="returns" tabindex="-1">Returns <a class="header-anchor" href="#returns" aria-label="Permalink to &quot;Returns&quot;"></a></h3><ul><li><code>table</code> <code>element</code> The created element instance</li></ul><h3 id="usage" tabindex="-1">Usage <a class="header-anchor" href="#usage" aria-label="Permalink to &quot;Usage&quot;"></a></h3><div class="language-lua vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">lua</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">local</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> button </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> basalt.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">create</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Button&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div><h2 id="basalt-createframe" tabindex="-1">basalt.createFrame() <a class="header-anchor" href="#basalt-createframe" aria-label="Permalink to &quot;basalt.createFrame()&quot;"></a></h2><p>Creates and returns a new BaseFrame</p><h3 id="returns-1" tabindex="-1">Returns <a class="header-anchor" href="#returns-1" aria-label="Permalink to &quot;Returns&quot;"></a></h3><ul><li><code>BaseFrame</code> <code>BaseFrame</code> The created frame instance</li></ul><h2 id="basalt-getelementmanager" tabindex="-1">basalt.getElementManager() <a class="header-anchor" href="#basalt-getelementmanager" aria-label="Permalink to &quot;basalt.getElementManager()&quot;"></a></h2><p>Returns the element manager instance</p><h3 id="returns-2" tabindex="-1">Returns <a class="header-anchor" href="#returns-2" aria-label="Permalink to &quot;Returns&quot;"></a></h3><ul><li><code>table</code> <code>ElementManager</code> The element manager</li></ul><h2 id="basalt-geterrormanager" tabindex="-1">basalt.getErrorManager() <a class="header-anchor" href="#basalt-geterrormanager" aria-label="Permalink to &quot;basalt.getErrorManager()&quot;"></a></h2><p>Returns the error manager instance</p><h3 id="returns-3" tabindex="-1">Returns <a class="header-anchor" href="#returns-3" aria-label="Permalink to &quot;Returns&quot;"></a></h3><ul><li><code>table</code> <code>ErrorManager</code> The error manager</li></ul><h2 id="basalt-getmainframe" tabindex="-1">basalt.getMainFrame() <a class="header-anchor" href="#basalt-getmainframe" aria-label="Permalink to &quot;basalt.getMainFrame()&quot;"></a></h2><p>Gets or creates the main frame</p><h3 id="returns-4" tabindex="-1">Returns <a class="header-anchor" href="#returns-4" aria-label="Permalink to &quot;Returns&quot;"></a></h3><ul><li><code>BaseFrame</code> <code>BaseFrame</code> The main frame instance</li></ul><h2 id="basalt-setactiveframe-frame-setactive" tabindex="-1">basalt.setActiveFrame(frame, setActive?) <a class="header-anchor" href="#basalt-setactiveframe-frame-setactive" aria-label="Permalink to &quot;basalt.setActiveFrame(frame, setActive?)&quot;"></a></h2><p>Sets the active frame</p><h3 id="parameters-1" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-1" aria-label="Permalink to &quot;Parameters&quot;"></a></h3><ul><li><code>frame</code> <code>BaseFrame</code> The frame to set as active</li><li><code>setActive</code> <em>(optional)</em> <code>boolean</code> Whether to set the frame as active (default: true)</li></ul><h2 id="basalt-getactiveframe-t" tabindex="-1">basalt.getActiveFrame(t?) <a class="header-anchor" href="#basalt-getactiveframe-t" aria-label="Permalink to &quot;basalt.getActiveFrame(t?)&quot;"></a></h2><p>Returns the active frame</p><h3 id="parameters-2" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-2" aria-label="Permalink to &quot;Parameters&quot;"></a></h3><ul><li><code>t</code> <em>(optional)</em> <code>term</code> The term to get the active frame for (default: current term)</li></ul><h3 id="returns-5" tabindex="-1">Returns <a class="header-anchor" href="#returns-5" aria-label="Permalink to &quot;Returns&quot;"></a></h3><ul><li><code>BaseFrame</code> <code>The</code> frame to set as active</li></ul><h2 id="basalt-setfocus-frame" tabindex="-1">basalt.setFocus(frame) <a class="header-anchor" href="#basalt-setfocus-frame" aria-label="Permalink to &quot;basalt.setFocus(frame)&quot;"></a></h2><p>Sets a frame as focused</p><h3 id="parameters-3" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-3" aria-label="Permalink to &quot;Parameters&quot;"></a></h3><ul><li><code>frame</code> <code>BaseFrame</code> The frame to set as focused</li></ul><h2 id="basalt-getfocus" tabindex="-1">basalt.getFocus() <a class="header-anchor" href="#basalt-getfocus" aria-label="Permalink to &quot;basalt.getFocus()&quot;"></a></h2><p>Returns the focused frame</p><h3 id="returns-6" tabindex="-1">Returns <a class="header-anchor" href="#returns-6" aria-label="Permalink to &quot;Returns&quot;"></a></h3><ul><li><code>BaseFrame</code> <code>The</code> focused frame</li></ul><h2 id="basalt-schedule-func" tabindex="-1">basalt.schedule(func) <a class="header-anchor" href="#basalt-schedule-func" aria-label="Permalink to &quot;basalt.schedule(func)&quot;"></a></h2><p>Schedules a function to run in a coroutine</p><h3 id="parameters-4" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-4" aria-label="Permalink to &quot;Parameters&quot;"></a></h3><ul><li><code>func</code> <code>function</code> The function to schedule</li></ul><h3 id="returns-7" tabindex="-1">Returns <a class="header-anchor" href="#returns-7" aria-label="Permalink to &quot;Returns&quot;"></a></h3><ul><li><code>thread</code> <code>func</code> The scheduled function</li></ul><h2 id="basalt-removeschedule-func" tabindex="-1">basalt.removeSchedule(func) <a class="header-anchor" href="#basalt-removeschedule-func" aria-label="Permalink to &quot;basalt.removeSchedule(func)&quot;"></a></h2><p>Removes a scheduled update</p><h3 id="parameters-5" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-5" aria-label="Permalink to &quot;Parameters&quot;"></a></h3><ul><li><code>func</code> <code>thread</code> The scheduled function to remove</li></ul><h3 id="returns-8" tabindex="-1">Returns <a class="header-anchor" href="#returns-8" aria-label="Permalink to &quot;Returns&quot;"></a></h3><ul><li><code>boolean</code> <code>success</code> Whether the scheduled function was removed</li></ul><h2 id="basalt-update" tabindex="-1">basalt.update() <a class="header-anchor" href="#basalt-update" aria-label="Permalink to &quot;basalt.update()&quot;"></a></h2><p>Runs basalt once, can be used to update the UI manually, but you have to feed it the events</p><h2 id="basalt-stop" tabindex="-1">basalt.stop() <a class="header-anchor" href="#basalt-stop" aria-label="Permalink to &quot;basalt.stop()&quot;"></a></h2><p>Stops the Basalt runtime</p><h2 id="basalt-run-isactive" tabindex="-1">basalt.run(isActive?) <a class="header-anchor" href="#basalt-run-isactive" aria-label="Permalink to &quot;basalt.run(isActive?)&quot;"></a></h2><p>Starts the Basalt runtime</p><h3 id="parameters-6" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-6" aria-label="Permalink to &quot;Parameters&quot;"></a></h3><ul><li><code>isActive</code> <em>(optional)</em> <code>boolean</code> Whether to start active (default: true)</li></ul><h2 id="basalt-getelementclass-name" tabindex="-1">basalt.getElementClass(name) <a class="header-anchor" href="#basalt-getelementclass-name" aria-label="Permalink to &quot;basalt.getElementClass(name)&quot;"></a></h2><p>Returns an element&#39;s class without creating a instance</p><h3 id="parameters-7" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-7" aria-label="Permalink to &quot;Parameters&quot;"></a></h3><ul><li><code>name</code> <code>string</code> The name of the element</li></ul><h3 id="returns-9" tabindex="-1">Returns <a class="header-anchor" href="#returns-9" aria-label="Permalink to &quot;Returns&quot;"></a></h3><ul><li><code>table</code> <code>Element</code> The element class</li></ul><h2 id="basalt-getapi-name" tabindex="-1">basalt.getAPI(name) <a class="header-anchor" href="#basalt-getapi-name" aria-label="Permalink to &quot;basalt.getAPI(name)&quot;"></a></h2><p>Returns a Plugin API</p><h3 id="parameters-8" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-8" aria-label="Permalink to &quot;Parameters&quot;"></a></h3><ul><li><code>name</code> <code>string</code> The name of the plugin</li></ul><h3 id="returns-10" tabindex="-1">Returns <a class="header-anchor" href="#returns-10" aria-label="Permalink to &quot;Returns&quot;"></a></h3><ul><li><code>table</code> <code>Plugin</code> The plugin API</li></ul><h2 id="basalt-onevent-eventname-callback" tabindex="-1">basalt.onEvent(eventName, callback) <a class="header-anchor" href="#basalt-onevent-eventname-callback" aria-label="Permalink to &quot;basalt.onEvent(eventName, callback)&quot;"></a></h2><p>Registers a callback function for a specific event</p><h3 id="parameters-9" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-9" aria-label="Permalink to &quot;Parameters&quot;"></a></h3><ul><li><code>eventName</code> <code>string</code> The name of the event to listen for (e.g. &quot;mouse_click&quot;, &quot;key&quot;, &quot;timer&quot;)</li><li><code>callback</code> <code>function</code> The callback function to execute when the event occurs</li></ul><h3 id="usage-1" tabindex="-1">Usage <a class="header-anchor" href="#usage-1" aria-label="Permalink to &quot;Usage&quot;"></a></h3><div class="language-lua vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">lua</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">basalt.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">onEvent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;mouse_click&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">function</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(button, x, y) basalt.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">debug</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Clicked at&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, x, y) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">end</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div><h2 id="basalt-removeevent-eventname-callback" tabindex="-1">basalt.removeEvent(eventName, callback) <a class="header-anchor" href="#basalt-removeevent-eventname-callback" aria-label="Permalink to &quot;basalt.removeEvent(eventName, callback)&quot;"></a></h2><p>Removes a callback function for a specific event</p><h3 id="parameters-10" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-10" aria-label="Permalink to &quot;Parameters&quot;"></a></h3><ul><li><code>eventName</code> <code>string</code> The name of the event</li><li><code>callback</code> <code>function</code> The callback function to remove</li></ul><h3 id="returns-11" tabindex="-1">Returns <a class="header-anchor" href="#returns-11" aria-label="Permalink to &quot;Returns&quot;"></a></h3><ul><li><code>boolean</code> <code>success</code> Whether the callback was found and removed</li></ul><h2 id="basalt-triggerevent-eventname" tabindex="-1">basalt.triggerEvent(eventName) <a class="header-anchor" href="#basalt-triggerevent-eventname" aria-label="Permalink to &quot;basalt.triggerEvent(eventName)&quot;"></a></h2><p>Triggers a custom event and calls all registered callbacks</p><h3 id="parameters-11" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-11" aria-label="Permalink to &quot;Parameters&quot;"></a></h3><ul><li><code>eventName</code> <code>string</code> The name of the event to trigger</li></ul><h3 id="usage-2" tabindex="-1">Usage <a class="header-anchor" href="#usage-2" aria-label="Permalink to &quot;Usage&quot;"></a></h3><div class="language-lua vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">lua</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">basalt.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">triggerEvent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;custom_event&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;data1&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;data2&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div>',97)]))}const b=a(l,[["render",i]]);export{m as __pageData,b as default};