1
0
Fork 0
mirror of https://github.com/Reuh/ubiquitousse.git synced 2025-10-27 09:09:30 +00:00

Improve documentation

This commit is contained in:
Étienne Fildadut 2021-12-26 18:13:32 +01:00
parent 489d0b4ba7
commit af3bd51cb3
25 changed files with 1468 additions and 725 deletions

View file

@ -2,7 +2,9 @@
Set of various libraries I use for game development, mainly with LÖVE. Nothing that hasn't been done before, but these are tailored to what I need. They can be used independently too. Set of various libraries I use for game development, mainly with LÖVE. Nothing that hasn't been done before, but these are tailored to what I need. They can be used independently too.
Documentation is done in LDoc-like comments in source files, but LDoc doesn't really like how I structure my libraries so you can't really generate documentation with it. I'm currently trying to fix this; some modules already have a working LDoc documentation that you can read [here](https://reuh.github.io/ubiquitousse/index.html) or in the `docs/` directory. You can find the documentation [here](https://reuh.github.io/ubiquitousse/index.html) or in the `docs/` directory.
Documentation is done in LDoc-like comments in source files, but LDoc doesn't really like how I structure my libraries (and the fact I use [Candran](https://github.com/Reuh/candran)) so you will need my [LDoc fork](https://github.com/Reuh/LDoc) if you want to generate the documentation yourself.
Whatever is currently on the master branch should be working and usable. Changelog, including breaking changes, are documented in commit messages. Whatever is currently on the master branch should be working and usable. Changelog, including breaking changes, are documented in commit messages.

View file

@ -1,6 +1,6 @@
# ubiquitousse.asset # ubiquitousse.asset
Asset manager library. Asset manager library for Lua.
You can read the documentation [here](https://reuh.github.io/ubiquitousse/modules/asset.html). You can read the documentation [here](https://reuh.github.io/ubiquitousse/modules/asset.html).

View file

@ -1,4 +1,4 @@
--- Asset manager. --- Asset manager for Lua.
-- --
-- Loads asset and cache them. -- Loads asset and cache them.
-- --
@ -8,6 +8,8 @@
-- --
-- No dependencies. -- No dependencies.
-- @module asset -- @module asset
-- @usage
-- TODO
--- Asset manager. --- Asset manager.
-- @type Asset -- @type Asset

View file

@ -65,13 +65,11 @@
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="modules/asset.html">asset</a></td> <td class="name" nowrap><a href="modules/asset.html">asset</a></td>
<td class="summary">Asset manager.</td> <td class="summary">Asset manager for Lua.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="modules/ecs.html">ecs</a></td> <td class="name" nowrap><a href="modules/ecs.html">ecs</a></td>
<td class="summary">ECS (entity compenent system) library</p> <td class="summary">ECS (<a href="https://en.wikipedia.org/wiki/Entity_component_system">entity compenent system</a>) library for Lua.</td>
<p> Entity Component System library, inspired by the excellent tiny-ecs.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="modules/ldtk.html">ldtk</a></td> <td class="name" nowrap><a href="modules/ldtk.html">ldtk</a></td>
@ -79,19 +77,19 @@
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="modules/scene.html">scene</a></td> <td class="name" nowrap><a href="modules/scene.html">scene</a></td>
<td class="summary">Scene management.</td> <td class="summary">Scene management for Lua game development.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="modules/signal.html">signal</a></td> <td class="name" nowrap><a href="modules/signal.html">signal</a></td>
<td class="summary">Signal management.</td> <td class="summary">Signal management for Lua.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="modules/timer.html">timer</a></td> <td class="name" nowrap><a href="modules/timer.html">timer</a></td>
<td class="summary">Time related functions.</td> <td class="summary">Timer management for Lua.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="modules/util.html">util</a></td> <td class="name" nowrap><a href="modules/util.html">util</a></td>
<td class="summary">Various functions useful for game developement.</td> <td class="summary">Various functions useful for Lua game developement.</td>
</tr> </tr>
</table> </table>
<h2>Topics</h2> <h2>Topics</h2>
@ -110,7 +108,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-25 23:19:42 </i> <i style="float:right;">Last updated 2021-12-26 18:13:01 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -60,7 +60,7 @@
<div id="content"> <div id="content">
<h1>Module <code>asset</code></h1> <h1>Module <code>asset</code></h1>
<p>Asset manager.</p> <p>Asset manager for Lua.</p>
<p> Loads asset and cache them.</p> <p> Loads asset and cache them.</p>
<p> This only provides a streamlined way to handle asset, and doesn&rsquo;t handle the actual file loading/object creation itself; you are expected to provide your own asset loaders.</p> <p> This only provides a streamlined way to handle asset, and doesn&rsquo;t handle the actual file loading/object creation itself; you are expected to provide your own asset loaders.</p>
@ -68,6 +68,11 @@
<p> See the <a href="../modules/asset.html#Asset:__call">Asset:__call</a> method for more details on how assets are loaded. Hopefully this will allow you to use asset which are more game-specific than &ldquo;image&rdquo; or &ldquo;audio&rdquo;.</p> <p> See the <a href="../modules/asset.html#Asset:__call">Asset:__call</a> method for more details on how assets are loaded. Hopefully this will allow you to use asset which are more game-specific than &ldquo;image&rdquo; or &ldquo;audio&rdquo;.</p>
<p> No dependencies.</p> <p> No dependencies.</p>
<h3>Usage:</h3>
<ul>
<pre class="example">TODO
</pre>
</ul>
<h2><a href="#Functions">Functions</a></h2> <h2><a href="#Functions">Functions</a></h2>
@ -329,7 +334,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-25 23:19:42 </i> <i style="float:right;">Last updated 2021-12-26 18:13:01 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -60,7 +60,7 @@
<div id="content"> <div id="content">
<h1>Module <code>scene</code></h1> <h1>Module <code>scene</code></h1>
<p>Scene management.</p> <p>Scene management for Lua game development.</p>
<p><p> You can use use scenes to seperate the different states of your game: for example, a menu scene and a game scene. <p><p> You can use use scenes to seperate the different states of your game: for example, a menu scene and a game scene.
This module is fully implemented in Ubiquitousse and is mostly a &ldquo;recommended way&rdquo; of organising an Ubiquitousse-based game. This module is fully implemented in Ubiquitousse and is mostly a &ldquo;recommended way&rdquo; of organising an Ubiquitousse-based game.
However, you don&rsquo;t have to use this if you don&rsquo;t want to. ubiquitousse.scene handles all the differents Ubiquitousse-states and However, you don&rsquo;t have to use this if you don&rsquo;t want to. ubiquitousse.scene handles all the differents Ubiquitousse-states and
@ -93,6 +93,11 @@
</ul> </ul>
</p> </p>
<h3>Usage:</h3>
<ul>
<pre class="example">TODO
</pre>
</ul>
<h2><a href="#Scene_objects">Scene objects </a></h2> <h2><a href="#Scene_objects">Scene objects </a></h2>
@ -103,11 +108,11 @@
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Scene.timer">Scene.timer</a></td> <td class="name" nowrap><a href="#Scene.timer">Scene.timer</a></td>
<td class="summary">Scene-specific TimerRegistry, if uqt.time is available.</td> <td class="summary">Scene-specific <a href="../modules/timer.html#TimerRegistry_objects">timer.TimerRegistry</a>, if uqt.time is available.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Scene.signal">Scene.signal</a></td> <td class="name" nowrap><a href="#Scene.signal">Scene.signal</a></td>
<td class="summary">Scene-specific SignalRegistry, if uqt.signal is available.</td> <td class="summary">Scene-specific <a href="../modules/signal.html#SignalRegistry_objects">signal.SignalRegistry</a>, if uqt.signal is available.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Scene:enter">Scene:enter (...) <sup><em>[callback]</em></sup></a></td> <td class="name" nowrap><a href="#Scene:enter">Scene:enter (...) <sup><em>[callback]</em></sup></a></td>
@ -138,15 +143,15 @@
<table class="function_list"> <table class="function_list">
<tr> <tr>
<td class="name" nowrap><a href="#current">current</a></td> <td class="name" nowrap><a href="#current">current</a></td>
<td class="summary">The current scene object.</td> <td class="summary">The current <a href="../modules/scene.html#Scene_objects">Scene</a> object.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#timer">timer</a></td> <td class="name" nowrap><a href="#timer">timer</a></td>
<td class="summary">Shortcut for scene.current.timer.</td> <td class="summary">Shortcut for scene.current.timer, the current scene <a href="../modules/timer.html#TimerRegistry_objects">timer.TimerRegistry</a>.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#signal">signal</a></td> <td class="name" nowrap><a href="#signal">signal</a></td>
<td class="summary">Shortcut for scene.current.signal.</td> <td class="summary">Shortcut for scene.current.signal, the current scene <code>timer.SignalRegistry</code>.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#stack">stack</a></td> <td class="name" nowrap><a href="#stack">stack</a></td>
@ -204,6 +209,9 @@
The scene name. The scene name.
</ul> </ul>
<h3>Type:</h3>
<ul>
<code>string</code>
</ul> </ul>
</ul> </ul>
</ul> </ul>
@ -219,9 +227,13 @@
<strong>Scene.timer</strong> <strong>Scene.timer</strong>
</dt> </dt>
<dd> <dd>
Scene-specific TimerRegistry, if uqt.time is available. Scene-specific <a href="../modules/timer.html#TimerRegistry_objects">timer.TimerRegistry</a>, if uqt.time is available.
</ul> </ul>
<h3>Type:</h3>
<ul>
<li><code>TimerRegistry</code></li>
<li><code>nil</code> if uqt.time unavailable</li>
</ul> </ul>
</ul> </ul>
</ul> </ul>
@ -237,9 +249,13 @@
<strong>Scene.signal</strong> <strong>Scene.signal</strong>
</dt> </dt>
<dd> <dd>
Scene-specific SignalRegistry, if uqt.signal is available. Scene-specific <a href="../modules/signal.html#SignalRegistry_objects">signal.SignalRegistry</a>, if uqt.signal is available.
</ul> </ul>
<h3>Type:</h3>
<ul>
<li><code>SignalRegistry</code></li>
<li><code>nil</code> if uqt.signal unavailable</li>
</ul> </ul>
</ul> </ul>
</ul> </ul>
@ -265,8 +281,7 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">...</span> <li><span class="parameter">...</span>
additional arguments passed to <a href="../modules/scene.html#switch">scene:switch</a> or <a href="../modules/scene.html#push">scene:push</a>
</li> </li>
</ul> </ul>
@ -344,12 +359,11 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">dt</span> <li><span class="parameter">dt</span>
<span class="types"><span class="type">number</span></span>
the delta time
</li> </li>
<li><span class="parameter">...</span> <li><span class="parameter">...</span>
additional arguments passed to <a href="../modules/scene.html#update">scene:update</a>
</li> </li>
</ul> </ul>
@ -373,8 +387,7 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">...</span> <li><span class="parameter">...</span>
additional arguments passed to <a href="../modules/scene.html#draw">scene:draw</a>
</li> </li>
</ul> </ul>
@ -392,9 +405,12 @@
<strong>current</strong> <strong>current</strong>
</dt> </dt>
<dd> <dd>
The current scene object. The current <a href="../modules/scene.html#Scene_objects">Scene</a> object.
</ul> </ul>
<h3>Type:</h3>
<ul>
<code>Scene</code>
</ul> </ul>
</ul> </ul>
</ul> </ul>
@ -410,9 +426,13 @@
<strong>timer</strong> <strong>timer</strong>
</dt> </dt>
<dd> <dd>
Shortcut for scene.current.timer. Shortcut for scene.current.timer, the current scene <a href="../modules/timer.html#TimerRegistry_objects">timer.TimerRegistry</a>.
</ul> </ul>
<h3>Type:</h3>
<ul>
<li><code>TimerRegistry</code></li>
<li><code>nil</code> if uqt.time unavailable</li>
</ul> </ul>
</ul> </ul>
</ul> </ul>
@ -428,9 +448,13 @@
<strong>signal</strong> <strong>signal</strong>
</dt> </dt>
<dd> <dd>
Shortcut for scene.current.signal. Shortcut for scene.current.signal, the current scene <code>timer.SignalRegistry</code>.
</ul> </ul>
<h3>Type:</h3>
<ul>
<li><code>SignalRegistry</code></li>
<li><code>nil</code> if uqt.signal unavailable</li>
</ul> </ul>
</ul> </ul>
</ul> </ul>
@ -449,6 +473,9 @@
The scene stack: list of scene, from the farest one to the nearest. The scene stack: list of scene, from the farest one to the nearest.
</ul> </ul>
<h3>Type:</h3>
<ul>
<code>{Scene,...}</code>
</ul> </ul>
</ul> </ul>
</ul> </ul>
@ -468,6 +495,9 @@
Will search in the &ldquo;scene&rdquo; directory by default (<code>prefix=&quot;scene.&quot;</code>). Redefine it to fit your own ridiculous filesystem. Will search in the &ldquo;scene&rdquo; directory by default (<code>prefix=&quot;scene.&quot;</code>). Redefine it to fit your own ridiculous filesystem.
</ul> </ul>
<h3>Type:</h3>
<ul>
<code>string</code>
</ul> </ul>
</ul> </ul>
</ul> </ul>
@ -628,7 +658,7 @@
<ul> <ul>
<li><span class="parameter">dt</span> <li><span class="parameter">dt</span>
<span class="types"><span class="type">number</span></span> <span class="types"><span class="type">number</span></span>
the delta-time (milisecond) the delta-time
</li> </li>
<li><span class="parameter">...</span> <li><span class="parameter">...</span>
arguments to pass to the scene&rsquo;s update function after dt arguments to pass to the scene&rsquo;s update function after dt
@ -672,7 +702,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-25 23:19:42 </i> <i style="float:right;">Last updated 2021-12-26 18:13:01 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -60,8 +60,14 @@
<div id="content"> <div id="content">
<h1>Module <code>signal</code></h1> <h1>Module <code>signal</code></h1>
<p>Signal management.</p> <p>Signal management for Lua.</p>
<p> No dependency.</p> <p> No dependency.
Optional dependency: LÖVE to hook into LÖVE events.</p>
<h3>Usage:</h3>
<ul>
<pre class="example">TODO
</pre>
</ul>
<h2><a href="#Module">Module </a></h2> <h2><a href="#Module">Module </a></h2>
@ -72,7 +78,7 @@
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#event">event</a></td> <td class="name" nowrap><a href="#event">event</a></td>
<td class="summary">SignalRegistry which will be used to bind signals that need to be called on game engine event; other ubiquitousse modules may bind to this registry <td class="summary"><a href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a> which will be used to bind signals that need to be called on game engine event; other ubiquitousse modules may bind to this registry
if avaible.</td> if avaible.</td>
</tr> </tr>
<tr> <tr>
@ -149,7 +155,7 @@
<strong>event</strong> <strong>event</strong>
</dt> </dt>
<dd> <dd>
<p>SignalRegistry which will be used to bind signals that need to be called on game engine event; other ubiquitousse modules may bind to this registry <p><a href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a> which will be used to bind signals that need to be called on game engine event; other ubiquitousse modules may bind to this registry
if avaible. </p> if avaible. </p>
<p> For example, every ubiquitousse module with a &ldquo;update&rdquo; function will bind it to the &ldquo;update&rdquo; signal in the registry; <p> For example, every ubiquitousse module with a &ldquo;update&rdquo; function will bind it to the &ldquo;update&rdquo; signal in the registry;
@ -166,6 +172,9 @@
</ul> </ul>
<h3>Type:</h3>
<ul>
<code>SignalRegistry</code>
</ul> </ul>
</ul> </ul>
</ul> </ul>
@ -215,6 +224,9 @@
Map of signals to list of listeners. Map of signals to list of listeners.
</ul> </ul>
<h3>Type:</h3>
<ul>
<code>{["name"]={fn,...}}</code>
</ul> </ul>
</ul> </ul>
</ul> </ul>
@ -240,16 +252,16 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">name</span> <li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
the name of the signal
</li> </li>
<li><span class="parameter">fn</span> <li><span class="parameter">fn</span>
<span class="types"><span class="type">function</span></span>
the function to bind to the signal
</li> </li>
<li><span class="parameter">...</span> <li><span class="parameter">...</span>
<span class="types"><span class="type">function,...</span></span>
other function to bind to the signal
</li> </li>
</ul> </ul>
@ -273,16 +285,16 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">name</span> <li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
the name of the signal
</li> </li>
<li><span class="parameter">fn</span> <li><span class="parameter">fn</span>
<span class="types"><span class="type">function</span></span>
the function to unbind to the signal
</li> </li>
<li><span class="parameter">...</span> <li><span class="parameter">...</span>
<span class="types"><span class="type">function,...</span></span>
other function to unbind to the signal
</li> </li>
</ul> </ul>
@ -306,8 +318,8 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">name</span> <li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
the name of the signal
</li> </li>
</ul> </ul>
@ -331,16 +343,16 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">name</span> <li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
the name of the signal
</li> </li>
<li><span class="parameter">sourceFn</span> <li><span class="parameter">sourceFn</span>
<span class="types"><span class="type">function</span></span>
the function currently bound to the signal
</li> </li>
<li><span class="parameter">destFn</span> <li><span class="parameter">destFn</span>
<span class="types"><span class="type">function</span></span>
the function that will replace the previous one
</li> </li>
</ul> </ul>
@ -382,12 +394,11 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">name</span> <li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
the name of the signal
</li> </li>
<li><span class="parameter">...</span> <li><span class="parameter">...</span>
arguments to pass to the functions bound to this signal
</li> </li>
</ul> </ul>
@ -403,7 +414,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-25 23:19:42 </i> <i style="float:right;">Last updated 2021-12-26 18:13:01 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -62,8 +62,13 @@
<div id="content"> <div id="content">
<h1>Module <code>timer</code></h1> <h1>Module <code>timer</code></h1>
<p>Time related functions.</p> <p>Timer management for Lua.</p>
<p> No dependency.</p> <p> No dependency.</p>
<h3>Usage:</h3>
<ul>
<pre class="example">TODO
</pre>
</ul>
<h2><a href="#Module">Module </a></h2> <h2><a href="#Module">Module </a></h2>
@ -84,19 +89,19 @@
<h2><a href="#Timer_objects">Timer objects </a></h2> <h2><a href="#Timer_objects">Timer objects </a></h2>
<table class="function_list"> <table class="function_list">
<tr> <tr>
<td class="name" nowrap><a href="#Timer:after">Timer:after (time)</a></td> <td class="name" nowrap><a href="#Timer:after">Timer:after ([, time])</a></td>
<td class="summary">Wait time seconds before running the function.</td> <td class="summary">Wait time seconds before running the function.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Timer:every">Timer:every (time)</a></td> <td class="name" nowrap><a href="#Timer:every">Timer:every ([, time])</a></td>
<td class="summary">Run the function every time millisecond.</td> <td class="summary">Run the function every time millisecond.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Timer:times">Timer:times (count)</a></td> <td class="name" nowrap><a href="#Timer:times">Timer:times ([, count])</a></td>
<td class="summary">The function will not execute more than count times.</td> <td class="summary">The function will not execute more than count times.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Timer:during">Timer:during (time)</a></td> <td class="name" nowrap><a href="#Timer:during">Timer:during ([, time])</a></td>
<td class="summary">The timer will be active for a time duration.</td> <td class="summary">The timer will be active for a time duration.</td>
</tr> </tr>
</table> </table>
@ -193,7 +198,7 @@
<h2><a href="#TweenTimer_objects">TweenTimer objects </a></h2> <h2><a href="#TweenTimer_objects">TweenTimer objects </a></h2>
<table class="function_list"> <table class="function_list">
<tr> <tr>
<td class="name" nowrap><a href="#r.chain">r.chain (_, duration_, tbl_, to_, method_)</a></td> <td class="name" nowrap><a href="#r:chain">r:chain (duration, tbl, to[, method="linear"])</a></td>
<td class="summary">Creates another tween which will be initialized when the current one ends.</td> <td class="summary">Creates another tween which will be initialized when the current one ends.</td>
</tr> </tr>
</table> </table>
@ -264,7 +269,7 @@
<ol> <ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span> <span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the object the new timer
</ol> </ol>
@ -326,7 +331,7 @@
<dl class="function"> <dl class="function">
<dt> <dt>
<a name = "Timer:after"></a> <a name = "Timer:after"></a>
<strong>Timer:after (time)</strong> <strong>Timer:after ([, time])</strong>
</dt> </dt>
<dd> <dd>
Wait time seconds before running the function. Wait time seconds before running the function.
@ -340,11 +345,18 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">time</span> <li><span class="parameter">time</span>
<span class="types"><span class="type">number</span></span>
duration to wait
(<em>optional</em>)
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -352,7 +364,7 @@
</dd> </dd>
<dt> <dt>
<a name = "Timer:every"></a> <a name = "Timer:every"></a>
<strong>Timer:every (time)</strong> <strong>Timer:every ([, time])</strong>
</dt> </dt>
<dd> <dd>
Run the function every time millisecond. Run the function every time millisecond.
@ -366,11 +378,18 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">time</span> <li><span class="parameter">time</span>
<span class="types"><span class="type">number</span></span>
duration between execution
(<em>optional</em>)
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -378,7 +397,7 @@
</dd> </dd>
<dt> <dt>
<a name = "Timer:times"></a> <a name = "Timer:times"></a>
<strong>Timer:times (count)</strong> <strong>Timer:times ([, count])</strong>
</dt> </dt>
<dd> <dd>
The function will not execute more than count times. The function will not execute more than count times.
@ -392,11 +411,18 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">count</span> <li><span class="parameter">count</span>
<span class="types"><span class="type">number</span></span>
number of times
(<em>optional</em>)
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -404,7 +430,7 @@
</dd> </dd>
<dt> <dt>
<a name = "Timer:during"></a> <a name = "Timer:during"></a>
<strong>Timer:during (time)</strong> <strong>Timer:during ([, time])</strong>
</dt> </dt>
<dd> <dd>
The timer will be active for a time duration. The timer will be active for a time duration.
@ -418,11 +444,18 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">time</span> <li><span class="parameter">time</span>
<span class="types"><span class="type">number</span></span>
duration of execution
(<em>optional</em>)
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -464,11 +497,17 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">func</span> <li><span class="parameter">func</span>
<span class="types"><span class="type">function</span></span>
function that returns true if condition is verified
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -490,11 +529,17 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">func</span> <li><span class="parameter">func</span>
<span class="types"><span class="type">function</span></span>
function that returns true if condition is verified
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -517,11 +562,17 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">func</span> <li><span class="parameter">func</span>
<span class="types"><span class="type">function</span></span>
function that returns true if condition is verified
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -543,11 +594,17 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">func</span> <li><span class="parameter">func</span>
<span class="types"><span class="type">function</span></span>
function that returns true if condition is verified
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -585,6 +642,12 @@
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -603,6 +666,12 @@
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -621,6 +690,12 @@
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -641,11 +716,17 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">time</span> <li><span class="parameter">time</span>
<span class="types"><span class="type">number</span></span>
duration to skip
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -685,11 +766,17 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">func</span> <li><span class="parameter">func</span>
<span class="types"><span class="type">function</span></span>
function to call when timer start
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -710,11 +797,17 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">func</span> <li><span class="parameter">func</span>
<span class="types"><span class="type">function</span></span>
function to call at each timer update
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -735,11 +828,17 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">func</span> <li><span class="parameter">func</span>
<span class="types"><span class="type">function</span></span>
function to call when timer ends
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the same timer, for chaining method calls
</ol>
@ -780,8 +879,8 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">func</span> <li><span class="parameter">func</span>
<span class="types"><span class="type">function</span></span>
function called by the chained timer
</li> </li>
</ul> </ul>
@ -789,8 +888,7 @@
<ol> <ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span> <span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the new timer
</ol> </ol>
@ -917,11 +1015,17 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">func</span> <li><span class="parameter">func</span>
<span class="types"><span class="type">function</span></span>
function called by the timer
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#Timer_objects">Timer</a></span>
the new timer
</ol>
@ -960,6 +1064,12 @@
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/timer.html#TweenTimer_objects">TweenTimer</a></span>
the new timer
</ol>
@ -991,13 +1101,13 @@
</div> </div>
<dl class="function"> <dl class="function">
<dt> <dt>
<a name = "r.chain"></a> <a name = "r:chain"></a>
<strong>r.chain (_, duration_, tbl_, to_, method_)</strong> <strong>r:chain (duration, tbl, to[, method="linear"])</strong>
</dt> </dt>
<dd> <dd>
Creates another tween which will be initialized when the current one ends. Creates another tween which will be initialized when the current one ends.
If tbl<em> and/or method</em> are not specified, the values from the current tween will be used. If tbl<em> and/or method</em> are not specified, the values from the current tween will be used.
Returns the new tween. Returns the new tween timer.
</ul> </ul>
</ul> </ul>
@ -1006,25 +1116,22 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">_</span> <li><span class="parameter">duration</span>
<span class="types"><span class="type">number</span></span>
tween duration (seconds)
</li> </li>
<li><span class="parameter">duration_</span> <li><span class="parameter">tbl</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
the table containing the values to tween
</li> </li>
<li><span class="parameter">tbl_</span> <li><span class="parameter">to</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
the new values
</li> </li>
<li><span class="parameter">to_</span> <li><span class="parameter">method</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string/function</a></span>
tweening method (string name or the actual function(time, start, change, duration))
</li> (<em>default</em> "linear")
<li><span class="parameter">method_</span>
</li> </li>
</ul> </ul>
@ -1032,8 +1139,7 @@
<ol> <ol>
<span class="types"><a class="type" href="../modules/timer.html#TweenTimer_objects">TweenTimer</a></span> <span class="types"><a class="type" href="../modules/timer.html#TweenTimer_objects">TweenTimer</a></span>
the new timer
</ol> </ol>
@ -1047,7 +1153,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-25 23:19:42 </i> <i style="float:right;">Last updated 2021-12-26 18:13:01 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -103,12 +103,9 @@
</ul> </ul>
<p> Regarding the documentation: Ubiquitousse used LDoc/LuaDoc styled-comments, but since LDoc hates me and my code, the <p> Regarding the documentation: Ubiquitousse uses LDoc/LuaDoc styled-comments, but since LDoc hates me and my code, the
generated result is complete garbage, so please read the documentation directly in the comments here until fix this. generated result is mostly garbage, so to generate the documentation you will need to use my <a href="https://github.com/Reuh/LDoc">LDoc fork</a>
Stuff you're interested in starts with triple &ndash; (e.g., &ldquo;&mdash;&ndash; This functions saves the world&rdquo;).</p> which I modified to force LDoc to like me.</p>
<p> <em>UPDATE</em>: I give up, currently in the process of admitting defat to LDoc and progressively porting all my documentation to it.
Though I had to modify a few things to get LDoc to like me, so the documentation is generated using <a href="https://github.com/Reuh/LDoc">my LDoc fork</a>.</p>
<h3>Usage:</h3> <h3>Usage:</h3>
<ul> <ul>
<pre class="example">local ubiquitousse = require(&quot;ubiquitousse&quot;) <pre class="example">local ubiquitousse = require(&quot;ubiquitousse&quot;)
@ -364,7 +361,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-25 23:19:42 </i> <i style="float:right;">Last updated 2021-12-26 18:13:01 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -59,8 +59,13 @@
<div id="content"> <div id="content">
<h1>Module <code>util</code></h1> <h1>Module <code>util</code></h1>
<p>Various functions useful for game developement.</p> <p>Various functions useful for Lua game developement.</p>
<p> No dependency.</p> <p> No dependency.</p>
<h3>Usage:</h3>
<ul>
<pre class="example">TODO
</pre>
</ul>
<h2><a href="#Functions">Functions </a></h2> <h2><a href="#Functions">Functions </a></h2>
@ -779,7 +784,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-25 23:19:42 </i> <i style="float:right;">Last updated 2021-12-26 18:13:01 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -64,7 +64,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-25 23:19:42 </i> <i style="float:right;">Last updated 2021-12-26 18:13:01 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -58,7 +58,9 @@
<p>Set of various libraries I use for game development, mainly with LÖVE. Nothing that hasn&rsquo;t been done before, but these are tailored to what I need. They can be used independently too.</p> <p>Set of various libraries I use for game development, mainly with LÖVE. Nothing that hasn&rsquo;t been done before, but these are tailored to what I need. They can be used independently too.</p>
<p>Documentation is done in LDoc-like comments in source files, but LDoc doesn&rsquo;t really like how I structure my libraries so you can&rsquo;t really generate documentation with it. I'm currently trying to fix this; some modules already have a working LDoc documentation that you can read <a href="https://reuh.github.io/ubiquitousse/index.html">here</a> or in the <code>docs/</code> directory.</p> <p>You can find the documentation <a href="https://reuh.github.io/ubiquitousse/index.html">here</a> or in the <code>docs/</code> directory.</p>
<p>Documentation is done in LDoc-like comments in source files, but LDoc doesn&rsquo;t really like how I structure my libraries (and the fact I use <a href="https://github.com/Reuh/candran">Candran</a>) so you will need my <a href="https://github.com/Reuh/LDoc">LDoc fork</a> if you want to generate the documentation yourself.</p>
<p>Whatever is currently on the master branch should be working and usable. Changelog, including breaking changes, are documented in commit messages.</p> <p>Whatever is currently on the master branch should be working and usable. Changelog, including breaking changes, are documented in commit messages.</p>
@ -69,7 +71,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-25 23:19:42 </i> <i style="float:right;">Last updated 2021-12-26 18:13:01 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -1,6 +1,6 @@
# ubiquitousse.ecs # ubiquitousse.ecs
ECS (entity compenent system) library. ECS (entity compenent system) library for Lua.
You can read the documentation [here](https://reuh.github.io/ubiquitousse/modules/ecs.html). You can read the documentation [here](https://reuh.github.io/ubiquitousse/modules/ecs.html).

View file

@ -38,12 +38,9 @@
-- * CamelCase for class names. -- * CamelCase for class names.
-- * lowerCamelCase is expected for everything else. -- * lowerCamelCase is expected for everything else.
-- --
-- Regarding the documentation: Ubiquitousse used LDoc/LuaDoc styled-comments, but since LDoc hates me and my code, the -- Regarding the documentation: Ubiquitousse uses LDoc/LuaDoc styled-comments, but since LDoc hates me and my code, the
-- generated result is complete garbage, so please read the documentation directly in the comments here until fix this. -- generated result is mostly garbage, so to generate the documentation you will need to use my [LDoc fork](https://github.com/Reuh/LDoc)
-- Stuff you're interested in starts with triple - (e.g., "--- This functions saves the world"). -- which I modified to force LDoc to like me.
--
-- *UPDATE*: I give up, currently in the process of admitting defat to LDoc and progressively porting all my documentation to it.
-- Though I had to modify a few things to get LDoc to like me, so the documentation is generated using [my LDoc fork](https://github.com/Reuh/LDoc).
-- --
-- @module ubiquitousse -- @module ubiquitousse
-- @usage local ubiquitousse = require("ubiquitousse") -- @usage local ubiquitousse = require("ubiquitousse")

View file

@ -191,39 +191,58 @@ let layer_mt = {
_init = (layer, level, order, callbacks) _init = (layer, level, order, callbacks)
let gridSize = layer.__gridSize let gridSize = layer.__gridSize
let t = { let t = {
--- @{Level} this layer belongs to. --- `Level` this layer belongs to.
-- @ftype Level
level = level, level = level,
--- The layer name. --- The layer name.
-- @ftype string
identifier = layer.__identifier, identifier = layer.__identifier,
--- Type of layer: IntGrid, Entities, Tiles or AutoLayer (string). --- Type of layer: IntGrid, Entities, Tiles or AutoLayer.
-- @ftype string
type = layer.__type, type = layer.__type,
--- Whether the layer is visible or not. --- Whether the layer is visible or not.
-- @ftype boolean
visible = layer.visible, visible = layer.visible,
--- The layer opacity (0-1). --- The layer opacity (0-1).
-- @ftype number
opacity = layer.opacity, opacity = layer.opacity,
--- The layer order: smaller order means it is on top. --- The layer order: smaller order means it is on top.
-- @ftype number
order = order, order = order,
--- X position of the layer relative to the level. --- X position of the layer relative to the level.
-- @ftype number
offsetX = layer.__pxTotalOffsetX, offsetX = layer.__pxTotalOffsetX,
--- Y position of the layer relative to the level. --- Y position of the layer relative to the level.
-- @ftype number
offsetY = layer.__pxTotalOffsetY, offsetY = layer.__pxTotalOffsetY,
--- Size of the grid on this layer. --- Size of the grid on this layer.
-- @ftype number
gridSize = gridSize, gridSize = gridSize,
--- Width of the layer, in grid units. --- Width of the layer, in grid units.
-- @ftype number
gridWidth = layer.__cWid, gridWidth = layer.__cWid,
--- Height of the layer, in grid units. --- Height of the layer, in grid units.
-- @ftype number
gridHeight = layer.__cHei, gridHeight = layer.__cHei,
--- _(Entities layer only)_ List of @{Entity} in the layer. --- _(Entities layer only)_ List of `Entity` in the layer.
-- @ftype {Entity,...}
entities = nil, entities = nil,
--- _(Tiles, AutoLayer, or IntGrid with AutoLayer rules layers only)_ List of @{Tile}s in the layer. --- _(Tiles, AutoLayer, or IntGrid with AutoLayer rules layers only)_ List of `Tile`s in the layer.
-- @ftype {Tile,...}
-- @ftype nil if not applicable
tiles = nil, tiles = nil,
--- _(Tiles, AutoLayer, or IntGrid with AutoLayer rules layers only)_ @{Tileset} object associated with the layer. --- _(Tiles, AutoLayer, or IntGrid with AutoLayer rules layers only)_ `Tileset` object associated with the layer.
-- @ftype Tileset
-- @ftype nil if not applicable
tileset = nil, tileset = nil,
--- _(Tiles, AutoLayer, or IntGrid with AutoLayer rules layers only)_ [LÖVE SpriteBatch](https://love2d.org/wiki/SpriteBatch) containing the layer. --- _(Tiles, AutoLayer, or IntGrid with AutoLayer rules layers only)_ [LÖVE SpriteBatch](https://love2d.org/wiki/SpriteBatch) containing the layer.
-- nil if LÖVE not available. -- @ftype SpriteBatch
-- @ftype nil if LÖVE not available.
-- @require love -- @require love
spritebatch = nil, spritebatch = nil,
--- _(IntGrid without AutoLayer rules layer only)_ list of @{IntTile}s in the layer. --- _(IntGrid without AutoLayer rules layer only)_ list of `IntTile`s in the layer.
-- @ftype {IntTile,...}
-- @ftype nil if not applicable
intTiles = nil, intTiles = nil,
} }
-- Layers with an associated tileset (otherwise ignore as there is nothing to draw) (Tiles, AutoLayer & IntGrid with AutoLayer rules) -- Layers with an associated tileset (otherwise ignore as there is nothing to draw) (Tiles, AutoLayer & IntGrid with AutoLayer rules)
@ -242,26 +261,34 @@ let layer_mt = {
-- --
-- This represent the tiles from a Tiles, AutoLayer or IntGrid with AutoLayer rules layer. -- This represent the tiles from a Tiles, AutoLayer or IntGrid with AutoLayer rules layer.
-- --
-- Can be retrived from the @{tiles} list or `onAddTile` level load callback. -- Can be retrived from the `Layer.tiles` list or `onAddTile` level load callback.
-- --
-- @type Tile -- @type Tile
let tile = { let tile = {
--- Layer the tile belongs to. --- `Layer` the tile belongs to.
-- @ftype Layer
layer = t, layer = t,
--- X position of the tile relative to the layer. --- X position of the tile relative to the layer.
-- @ftype number
x = x, x = x,
--- Y position of the tile relative to the layer. --- Y position of the tile relative to the layer.
-- @ftype number
y = y, y = y,
--- Whether the tile is flipped horizontally. --- Whether the tile is flipped horizontally.
-- @ftype boolean
flipX = false, flipX = false,
--- Whether the tile is flipped vertically. --- Whether the tile is flipped vertically.
-- @ftype boolean
flipY = false, flipY = false,
--- Tags associated with the tile: can be used either as a list of tags or a map of activated tags tags[name] == true. --- Tags associated with the tile: can be used either as a list of tags or a map of activated tags tags[name] == true.
-- @ftype {"tag",["tag"]=true,...}
tags = tilesetData[tl.t].tags, tags = tilesetData[tl.t].tags,
--- Custom data associated with the tile, if any. --- Custom data associated with the tile, if any.
-- @ftype string
data = tilesetData[tl.t].data, data = tilesetData[tl.t].data,
--- Quad associated with the tile (relative to the layer's tileset). --- Quad associated with the tile (relative to the layer's tileset).
-- LÖVE Quad if LÖVE is available, otherwise a table `{ x, y, width, height }`. -- @ftype LÖVE Quad if LÖVE is available
-- @ftype table { x, y, width, height } if LÖVE not available
quad = quad quad = quad
} }
if tl.f == 1 or tl.f == 3 then if tl.f == 1 or tl.f == 3 then
@ -295,17 +322,23 @@ let layer_mt = {
-- --
-- @type IntTile -- @type IntTile
let tile = { let tile = {
--- Layer the IntTile belongs to. --- `Layer` the IntTile belongs to.
-- @ftype Layer
layer = t, layer = t,
--- X position of the IntTile relative to the layer. --- X position of the IntTile relative to the layer.
-- @ftype number
x = x, x = x,
--- Y position of the IntTile relative to the layer. --- Y position of the IntTile relative to the layer.
-- @ftype number
y = y, y = y,
--- Name of the IntTile. --- Name of the IntTile.
-- @ftype string
identifier = values[tl].identifier, identifier = values[tl].identifier,
--- Integer value of the IntTile. --- Integer value of the IntTile.
-- @ftype number
value = tl, value = tl,
--- Color of the IntTile. --- Color of the IntTile.
-- @ftype table {r,g,b} with r,g,b in [0-1]
color = values[tl].color color = values[tl].color
} }
table.insert(t.intTiles, tile) table.insert(t.intTiles, tile)
@ -327,32 +360,45 @@ let layer_mt = {
-- --
-- @type Entity -- @type Entity
let entity = { let entity = {
--- @{Layer} this entity belongs to. --- `Layer` this entity belongs to.
-- @ftype Layer
layer = t, layer = t,
--- The entity name. --- The entity name.
-- @ftype string
identifier = e.__identifier, identifier = e.__identifier,
--- X position of the entity relative to the layer. --- X position of the entity relative to the layer.
-- @ftype number
x = e.px[1], x = e.px[1],
--- Y position of the entity relative to the layer. --- Y position of the entity relative to the layer.
-- @ftype number
y = e.px[2], y = e.px[2],
--- The entity width. --- The entity width.
-- @ftype number
width = e.width, width = e.width,
--- The entity height. --- The entity height.
-- @ftype number
height = e.height, height = e.height,
--- Scale factor on x axis relative to original entity size. --- Scale factor on x axis relative to original entity size.
-- @ftype number
sx = e.width / entityDef.width, sx = e.width / entityDef.width,
--- Scale factor on y axis relative to original entity size. --- Scale factor on y axis relative to original entity size.
-- @ftype number
sy = e.height / entityDef.height, sy = e.height / entityDef.height,
--- The entity pivot point x position relative to the entity. --- The entity pivot point x position relative to the entity.
-- @ftype number
pivotX = e.__pivot[1] * e.width, pivotX = e.__pivot[1] * e.width,
--- The entity pivot point x position relative to the entity. --- The entity pivot point x position relative to the entity.
-- @ftype number
pivotY = e.__pivot[2] * e.height, pivotY = e.__pivot[2] * e.height,
--- Entity color. --- Entity color.
-- @ftype table {r,g,b} with r,g,b in [0-1]
color = entityDef.color, color = entityDef.color,
--- Tile associated with the entity, if any. Is a table { tileset = associated tileset object, quad = associated quad }. --- Tile associated with the entity, if any. Is a table { tileset = associated tileset object, quad = associated quad }.
-- `quad` is a LÖVE Quad if LÖVE is available, otherwise a table `{ x, y, width, height }`. -- `quad` is a LÖVE Quad if LÖVE is available, otherwise a table `{ x, y, width, height }`.
-- @ftype table
tile = nil, tile = nil,
--- Map of custom fields of the entity. --- Map of `CustomFields` of the entity.
-- @ftype CustomFields
fields = getFields(e.fieldInstances), fields = getFields(e.fieldInstances),
--- Called for the entity when drawing the associated entity layer (you will likely want to redefine it). --- Called for the entity when drawing the associated entity layer (you will likely want to redefine it).
-- --
@ -489,30 +535,39 @@ let level_mt = {
_init = (level, project) _init = (level, project)
let t = { let t = {
--- @{Project} this level belongs to. --- `Project` this level belongs to.
-- @ftype Project
project = project, project = project,
--- Whether this level is currently loaded or not (boolean). --- Whether this level is currently loaded or not.
-- @ftype boolean
loaded = false, loaded = false,
--- The level name (string). --- The level name.
-- @ftype string
identifier = level.identifier, identifier = level.identifier,
--- The level x position (number). --- The level x position.
-- @ftype number
x = level.worldX, x = level.worldX,
--- The level y position (number). --- The level y position.
-- @ftype number
y = level.worldY, y = level.worldY,
--- The level width (number). --- The level width.
-- @ftype number
width = level.pxWid, width = level.pxWid,
--- The level height (number). --- The level height.
-- @ftype number
height = level.pxHei, height = level.pxHei,
--- Map of custom fields of the level (table). --- Map of `CustomFields` of the level (table).
-- @ftype CustomFields
fields = getFields(level.fieldInstances), fields = getFields(level.fieldInstances),
--- List of @{Layer}s in the level (table). --- List of `Layer`s in the level (table).
-- @ftype {Layer,...}
layers = nil, layers = nil,
--- Level background. --- Level background.
-- --
-- If there is a background image, `background.image` contains a table `{image=image, x=number, y=number, sx=number, sy=number}` -- If there is a background image, `background.image` contains a table `{image=image, x=number, y=number, sx=number, sy=number}`
-- where `image` is the LÖVE image (or image filepath if LÖVE not available) `x` and `y` are the top-left position, -- where `image` is the LÖVE image (or image filepath if LÖVE not available) `x` and `y` are the top-left position,
-- and `sx` and `sy` the horizontal and vertical scale factors. -- and `sx` and `sy` the horizontal and vertical scale factors.
-- @field color backrgound color -- @field color backrgound color {r,g,b} with r,g,b in [0-1]
-- @field image backrgound image information, if any -- @field image backrgound image information, if any
background = { background = {
color = parseColor(level.__bgColor), color = parseColor(level.__bgColor),
@ -536,7 +591,8 @@ let project_mt = {
_init = (project, directory) _init = (project, directory)
assert(project.jsonVersion == "0.9.3", "map made for LDtk version %s":format(project.jsonVersion)) assert(project.jsonVersion == "0.9.3", "map made for LDtk version %s":format(project.jsonVersion))
let t = { let t = {
--- List of @{Level}s in this project. --- List of `Level`s in this project.
-- @ftype {Level,...}
levels = nil, levels = nil,
-- private -- private
@ -608,9 +664,26 @@ let project_mt = {
} }
project_mt.__index = project_mt project_mt.__index = project_mt
--- Custom fields. --- Custom fields: map of each field name to its value.
-- TODO --
-- @section fields -- LDtk allows to defined custom fields in some places (`Entity.fields`, `Level.fields`). This library allows you to access them in a table that
-- map each field name to its value `{["fieldName"]=value,...}`.
--
-- @type CustomFields
--- Type conversion.
--
-- Here is how the values are converted to Lua values:
--
-- * Integers, Floats are converted into a Lua number.
-- * Booleans are converted into a Lua boolean.
-- * Strings, Multilines are converted in a Lua string.
-- * Enum are converted into a Lua string giving the currently selected enum value.
-- * Filepath are converted into a Lua string giving the file path.
-- * Arrays are converted into a Lua table with the elements in it as a list.
-- * Points are converted into a Lua table with the fields `x` and `y`: `{ x=number, y=number }`.
-- * Colors are converted into a Lua table with the red, green and blue components in [0-1] as a list: `{r,g,b}`.
-- @doc conversion
--- LDtk module. --- LDtk module.
-- `ubiquitousse.ldtk` returns a single function, @{LDtk}. -- `ubiquitousse.ldtk` returns a single function, @{LDtk}.

View file

@ -1,6 +1,6 @@
# ubiquitousse.scene # ubiquitousse.scene
Scene management library. Scene management library for Lua game development.
You can read the documentation [here](https://reuh.github.io/ubiquitousse/modules/scene.html). You can read the documentation [here](https://reuh.github.io/ubiquitousse/modules/scene.html).

View file

@ -1,4 +1,4 @@
--- Scene management. --- Scene management for Lua game development.
-- --
-- You can use use scenes to seperate the different states of your game: for example, a menu scene and a game scene. -- You can use use scenes to seperate the different states of your game: for example, a menu scene and a game scene.
-- This module is fully implemented in Ubiquitousse and is mostly a "recommended way" of organising an Ubiquitousse-based game. -- This module is fully implemented in Ubiquitousse and is mostly a "recommended way" of organising an Ubiquitousse-based game.
@ -23,6 +23,8 @@
-- * ubiquitousse.timer (to provide each scene a timer registry). -- * ubiquitousse.timer (to provide each scene a timer registry).
-- * ubiquitousse.signal (to bind to update and draw signal in signal.event). -- * ubiquitousse.signal (to bind to update and draw signal in signal.event).
-- @module scene -- @module scene
-- @usage
-- TODO
local loaded, signal = pcall(require, (...):match("^(.-)scene").."signal") local loaded, signal = pcall(require, (...):match("^(.-)scene").."signal")
if not loaded then signal = nil end if not loaded then signal = nil end
local loaded, timer = pcall(require, (...):match("^(.-)scene").."timer") local loaded, timer = pcall(require, (...):match("^(.-)scene").."timer")
@ -32,12 +34,18 @@ if not loaded then timer = nil end
-- @type Scene -- @type Scene
local _ = { local _ = {
--- The scene name. --- The scene name.
-- @ftype string
name = name or "unamed", name = name or "unamed",
--- Scene-specific TimerRegistry, if uqt.time is available. --- Scene-specific `timer.TimerRegistry`, if uqt.time is available.
-- @ftype TimerRegistry
-- @ftype nil if uqt.time unavailable
timer = timer and timer.new(), timer = timer and timer.new(),
--- Scene-specific SignalRegistry, if uqt.signal is available. --- Scene-specific `signal.SignalRegistry`, if uqt.signal is available.
-- @ftype SignalRegistry
-- @ftype nil if uqt.signal unavailable
signal = signal and signal.new(), signal = signal and signal.new(),
--- Called when entering a scene. --- Called when entering a scene.
-- @param ... additional arguments passed to `scene:switch` or `scene:push`
-- @callback -- @callback
enter = function(self, ...) end, enter = function(self, ...) end,
--- Called when exiting a scene, and not expecting to come back (scene may be unloaded). --- Called when exiting a scene, and not expecting to come back (scene may be unloaded).
@ -50,9 +58,12 @@ local _ = {
-- @callback -- @callback
resume = function(self) end, resume = function(self) end,
--- Called on each update on the current scene. --- Called on each update on the current scene.
-- @tparam number dt the delta time
-- @param ... additional arguments passed to `scene:update`
-- @callback -- @callback
update = function(self, dt, ...) end, update = function(self, dt, ...) end,
--- Called on each draw on the current scene. --- Called on each draw on the current scene.
-- @param ... additional arguments passed to `scene:draw`
-- @callback -- @callback
draw = function(self, ...) end draw = function(self, ...) end
} }
@ -62,19 +73,26 @@ local _ = {
local scene local scene
scene = { scene = {
--- The current scene object. --- The current `Scene` object.
-- @ftype Scene
current = nil, current = nil,
--- Shortcut for scene.current.timer. --- Shortcut for scene.current.timer, the current scene `timer.TimerRegistry`.
-- @ftype TimerRegistry
-- @ftype nil if uqt.time unavailable
timer = nil, timer = nil,
--- Shortcut for scene.current.signal. --- Shortcut for scene.current.signal, the current scene `timer.SignalRegistry`.
-- @ftype SignalRegistry
-- @ftype nil if uqt.signal unavailable
signal = nil, signal = nil,
--- The scene stack: list of scene, from the farest one to the nearest. --- The scene stack: list of scene, from the farest one to the nearest.
-- @ftype {Scene,...}
stack = {}, stack = {},
--- A prefix for scene modules names. --- A prefix for scene modules names.
-- Will search in the "scene" directory by default (`prefix="scene."`). Redefine it to fit your own ridiculous filesystem. -- Will search in the "scene" directory by default (`prefix="scene."`). Redefine it to fit your own ridiculous filesystem.
-- @ftype string
prefix = "scene.", prefix = "scene.",
--- Creates and returns a new Scene object. --- Creates and returns a new Scene object.
@ -156,7 +174,7 @@ scene = {
--- Update the current scene. --- Update the current scene.
-- Should be called at every game update. If ubiquitousse.signal is available, will be bound to the "update" signal in signal.event. -- Should be called at every game update. If ubiquitousse.signal is available, will be bound to the "update" signal in signal.event.
-- @tparam number dt the delta-time (milisecond) -- @tparam number dt the delta-time
-- @param ... arguments to pass to the scene's update function after dt -- @param ... arguments to pass to the scene's update function after dt
update = function(dt, ...) update = function(dt, ...)
if scene.current then if scene.current then

View file

@ -1,6 +1,6 @@
# ubiquitousse.signal # ubiquitousse.signal
Signal management library. Signal management library for Lua.
You can read the documentation [here](https://reuh.github.io/ubiquitousse/modules/signal.html). You can read the documentation [here](https://reuh.github.io/ubiquitousse/modules/signal.html).

View file

@ -1,7 +1,10 @@
--- Signal management. --- Signal management for Lua.
-- --
-- No dependency. -- No dependency.
-- Optional dependency: LÖVE to hook into LÖVE events.
-- @module signal -- @module signal
-- @usage
-- TODO
--- Signal registry. --- Signal registry.
-- --
@ -9,20 +12,27 @@
-- @type SignalRegistry -- @type SignalRegistry
let registry_mt = { let registry_mt = {
--- Map of signals to list of listeners. --- Map of signals to list of listeners.
-- @ftype {["name"]={fn,...}}
signals = {}, signals = {},
--- Bind one or several functions to a signal name. --- Bind one or several functions to a signal name.
-- @tparam string name the name of the signal
-- @tparam function fn the function to bind to the signal
-- @tparam function,... ... other function to bind to the signal
bind = :(name, fn, ...) bind = :(name, fn, ...)
if not @signals[name] then if not @signals[name] then
@signals[name] = {} @signals[name] = {}
end end
table.insert(@signals[name], fn) table.insert(@signals[name], fn)
if ... then if ... then
return @bind(name, ...) @bind(name, ...)
end end
end, end,
--- Unbind one or several functions to a signal name. --- Unbind one or several functions to a signal name.
-- @tparam string name the name of the signal
-- @tparam function fn the function to unbind to the signal
-- @tparam function,... ... other function to unbind to the signal
unbind = :(name, fn, ...) unbind = :(name, fn, ...)
if not @signals[name] then if not @signals[name] then
return return
@ -33,16 +43,20 @@ let registry_mt = {
end end
end end
if ... then if ... then
return @unbind(name, ...) @unbind(name, ...)
end end
end, end,
--- Remove every bound function to a signal name. --- Remove every bound function to a signal name.
-- @tparam string name the name of the signal
unbindAll = :(name) unbindAll = :(name)
@signals[name] = nil @signals[name] = nil
end, end,
--- Replace a bound function with another function. --- Replace a bound function with another function.
-- @tparam string name the name of the signal
-- @tparam function sourceFn the function currently bound to the signal
-- @tparam function destFn the function that will replace the previous one
replace = :(name, sourceFn, destFn) replace = :(name, sourceFn, destFn)
if not @signals[name] then if not @signals[name] then
@signals[name] = {} @signals[name] = {}
@ -61,6 +75,8 @@ let registry_mt = {
end, end,
--- Emit a signal, i.e. call every function bound to it, with the given arguments. --- Emit a signal, i.e. call every function bound to it, with the given arguments.
-- @tparam string name the name of the signal
-- @param ... arguments to pass to the functions bound to this signal
emit = :(name, ...) emit = :(name, ...)
if @signals[name] then if @signals[name] then
for _, fn in ipairs(@signals[name]) do for _, fn in ipairs(@signals[name]) do
@ -105,7 +121,7 @@ let signal = {
return registry_mt.emit(signal, ...) return registry_mt.emit(signal, ...)
end, end,
--- SignalRegistry which will be used to bind signals that need to be called on game engine event; other ubiquitousse modules may bind to this registry --- `SignalRegistry` which will be used to bind signals that need to be called on game engine event; other ubiquitousse modules may bind to this registry
-- if avaible. -- if avaible.
-- --
-- For example, every ubiquitousse module with a "update" function will bind it to the "update" signal in the registry; -- For example, every ubiquitousse module with a "update" function will bind it to the "update" signal in the registry;
@ -116,6 +132,7 @@ let signal = {
-- * `update(dt)`, should be called on every game update -- * `update(dt)`, should be called on every game update
-- * `draw()`, should be called on every game draw -- * `draw()`, should be called on every game draw
-- * for LÖVE, there are callbacks for every LÖVE callback function that need to be called on their corresponding LÖVE callback -- * for LÖVE, there are callbacks for every LÖVE callback function that need to be called on their corresponding LÖVE callback
-- @ftype SignalRegistry
event = nil, event = nil,
--- Call this function to hook `signal.event` signals to LÖVE events. --- Call this function to hook `signal.event` signals to LÖVE events.

View file

@ -1,6 +1,6 @@
# ubiquitousse.timer # ubiquitousse.timer
Timer and time related functions. Timer management for Lua.
You can read the documentation [here](https://reuh.github.io/ubiquitousse/modules/timer.html). You can read the documentation [here](https://reuh.github.io/ubiquitousse/modules/timer.html).

View file

@ -1,7 +1,9 @@
--- Time related functions. --- Timer management for Lua.
-- --
-- No dependency. -- No dependency.
-- @module timer -- @module timer
-- @usage
-- TODO
local ease = require((...):match("^.-timer")..".easing") local ease = require((...):match("^.-timer")..".easing")
local timer_module local timer_module
@ -33,24 +35,32 @@ local timer_mt = {
--- Wait time seconds before running the function. --- Wait time seconds before running the function.
-- Specify no time to remove condition. -- Specify no time to remove condition.
-- @tparam[opt] number time duration to wait
-- @treturn Timer the same timer, for chaining method calls
after = function(self, time) after = function(self, time)
self.t.after = time self.t.after = time
return self return self
end, end,
--- Run the function every time millisecond. --- Run the function every time millisecond.
-- Specify no time to remove condition. -- Specify no time to remove condition.
-- @tparam[opt] number time duration between execution
-- @treturn Timer the same timer, for chaining method calls
every = function(self, time) every = function(self, time)
self.t.every = time self.t.every = time
return self return self
end, end,
--- The function will not execute more than count times. --- The function will not execute more than count times.
-- Specify no time to remove condition. -- Specify no time to remove condition.
-- @tparam[opt] number count number of times
-- @treturn Timer the same timer, for chaining method calls
times = function(self, count) times = function(self, count)
self.t.times = count or -1 self.t.times = count or -1
return self return self
end, end,
--- The timer will be active for a time duration. --- The timer will be active for a time duration.
-- Specify no time to remove condition. -- Specify no time to remove condition.
-- @tparam[opt] number time duration of execution
-- @treturn Timer the same timer, for chaining method calls
during = function(self, time) during = function(self, time)
self.t.during = time self.t.during = time
return self return self
@ -62,12 +72,16 @@ local timer_mt = {
--- Starts the function execution when func() returns true. Checked before the "after" condition, --- Starts the function execution when func() returns true. Checked before the "after" condition,
-- meaning the "after" countdown starts when func() returns true. -- meaning the "after" countdown starts when func() returns true.
-- If multiple init functions are added, init will trigger only when all of them returns true. -- If multiple init functions are added, init will trigger only when all of them returns true.
-- @tparam function func function that returns true if condition is verified
-- @treturn Timer the same timer, for chaining method calls
initWhen = function(self, func) initWhen = function(self, func)
table.insert(self.t.initWhen, func) table.insert(self.t.initWhen, func)
return self return self
end, end,
--- Starts the function execution when func() returns true. Checked after the "after" condition. --- Starts the function execution when func() returns true. Checked after the "after" condition.
-- If multiple start functions are added, start will trigger only when all of them returns true. -- If multiple start functions are added, start will trigger only when all of them returns true.
-- @tparam function func function that returns true if condition is verified
-- @treturn Timer the same timer, for chaining method calls
startWhen = function(self, func) startWhen = function(self, func)
table.insert(self.t.startWhen, func) table.insert(self.t.startWhen, func)
return self return self
@ -75,12 +89,16 @@ local timer_mt = {
--- When the functions ends, the execution won't stop and will repeat as long as func() returns true. --- When the functions ends, the execution won't stop and will repeat as long as func() returns true.
-- Will cancel timed repeat conditions if false but needs other timed repeat conditions to be true to create a new repeat. -- Will cancel timed repeat conditions if false but needs other timed repeat conditions to be true to create a new repeat.
-- If multiple repeat functions are added, a repeat will trigger only when all of them returns true. -- If multiple repeat functions are added, a repeat will trigger only when all of them returns true.
-- @tparam function func function that returns true if condition is verified
-- @treturn Timer the same timer, for chaining method calls
repeatWhile = function(self, func) repeatWhile = function(self, func)
table.insert(self.t.repeatWhile, func) table.insert(self.t.repeatWhile, func)
return self return self
end, end,
--- Stops the function execution when func() returns true. Checked before all timed conditions. --- Stops the function execution when func() returns true. Checked before all timed conditions.
-- If multiple stop functions are added, stop will trigger only when all of them returns true. -- If multiple stop functions are added, stop will trigger only when all of them returns true.
-- @tparam function func function that returns true if condition is verified
-- @treturn Timer the same timer, for chaining method calls
stopWhen = function(self, func) stopWhen = function(self, func)
table.insert(self.t.stopWhen, func) table.insert(self.t.stopWhen, func)
return self return self
@ -90,39 +108,51 @@ local timer_mt = {
-- @doc conditionoverride -- @doc conditionoverride
--- Force the function to start its execution. --- Force the function to start its execution.
-- @treturn Timer the same timer, for chaining method calls
start = function(self) start = function(self)
self.t.forceStart = true self.t.forceStart = true
return self return self
end, end,
--- Force the function to stop its execution. --- Force the function to stop its execution.
-- @treturn Timer the same timer, for chaining method calls
stop = function(self) stop = function(self)
self.t.forceStop = true self.t.forceStop = true
return self return self
end, end,
--- Force the function to stop immediately. Won't trigger onEnd or other callbacks. --- Force the function to stop immediately. Won't trigger onEnd or other callbacks.
-- @treturn Timer the same timer, for chaining method calls
abort = function(self) abort = function(self)
self.t.abort = true self.t.abort = true
return self return self
end, end,
--- Skip some amount of time. --- Skip some amount of time.
-- @tparam number time duration to skip
-- @treturn Timer the same timer, for chaining method calls
skip = function(self, time) skip = function(self, time)
self.t.skip = (self.t.skip or 0) + time self.t.skip = (self.t.skip or 0) + time
return self
end, end,
--- Callbacks functions --- Callbacks functions
-- @doc callbacks -- @doc callbacks
--- Add a function to the start callback: will execute func(self, lag) when the function execution start. --- Add a function to the start callback: will execute func(self, lag) when the function execution start.
-- @tparam function func function to call when timer start
-- @treturn Timer the same timer, for chaining method calls
onStart = function(self, func) onStart = function(self, func)
table.insert(self.t.onStart, func) table.insert(self.t.onStart, func)
return self return self
end, end,
--- Add a function to the update callback: will execute func(self, lag) each frame the main function is run. --- Add a function to the update callback: will execute func(self, lag) each frame the main function is run.
-- @tparam function func function to call at each timer update
-- @treturn Timer the same timer, for chaining method calls
onUpdate = function(self, func) onUpdate = function(self, func)
table.insert(self.t.onUpdate, func) table.insert(self.t.onUpdate, func)
return self return self
end, end,
--- Add a function to the end callback: will execute func(self, lag) when the function execution end. --- Add a function to the end callback: will execute func(self, lag) when the function execution end.
-- @tparam function func function to call when timer ends
-- @treturn Timer the same timer, for chaining method calls
onEnd = function(self, func) onEnd = function(self, func)
table.insert(self.t.onEnd, func) table.insert(self.t.onEnd, func)
return self return self
@ -133,7 +163,8 @@ local timer_mt = {
--- Creates another timer which will be replace the current one when it ends. --- Creates another timer which will be replace the current one when it ends.
-- Returns the new timer (and not the original one!). -- Returns the new timer (and not the original one!).
-- @treturn Timer -- @tparam function func function called by the chained timer
-- @treturn Timer the new timer
chain = function(self, func) chain = function(self, func)
local fn = timer_module.run(func) local fn = timer_module.run(func)
self:onEnd(function(self, lag) self:onEnd(function(self, lag)
@ -242,6 +273,8 @@ local registry_mt = {
--- Create a new timer and add it to the registry. --- Create a new timer and add it to the registry.
-- Same as timer_module.run, but add it to the registry. -- Same as timer_module.run, but add it to the registry.
-- @tparam function func function called by the timer
-- @treturn Timer the new timer
run = function(self, func) run = function(self, func)
local r = timer_module.run(func) local r = timer_module.run(func)
table.insert(self.timers, r) table.insert(self.timers, r)
@ -250,6 +283,7 @@ local registry_mt = {
--- Create a new tween timer and add it to the registry. --- Create a new tween timer and add it to the registry.
-- Same as timer_module.tween, but add it to the registry. -- Same as timer_module.tween, but add it to the registry.
-- @treturn TweenTimer the new timer
tween = function(self, duration, tbl, to, method) tween = function(self, duration, tbl, to, method)
local r = timer_module.tween(duration, tbl, to, method) local r = timer_module.tween(duration, tbl, to, method)
table.insert(self.timers, r) table.insert(self.timers, r)
@ -289,7 +323,7 @@ timer_module = {
-- You will need to call the :update(dt) method on the timer object every frame to make it do something, or create the timer from a timer registry if you -- You will need to call the :update(dt) method on the timer object every frame to make it do something, or create the timer from a timer registry if you
-- don't want to handle your timers manually. -- don't want to handle your timers manually.
-- @tparam[opt] function func the function to schedule -- @tparam[opt] function func the function to schedule
-- @treturn Timer the object -- @treturn Timer the new timer
run = function(func) run = function(func)
local r = setmetatable({ local r = setmetatable({
t = { t = {
@ -323,8 +357,6 @@ timer_module = {
--- Create a timer that will tween some numeric values. --- Create a timer that will tween some numeric values.
-- You will need to call the :update(dt) method on the timer object every frame to make it do something, or create the timer from a timer registry if you -- You will need to call the :update(dt) method on the timer object every frame to make it do something, or create the timer from a timer registry if you
-- don't want to handle your timers manually. -- don't want to handle your timers manually.
--
--
-- @tparam number duration tween duration (seconds) -- @tparam number duration tween duration (seconds)
-- @tparam table tbl the table containing the values to tween -- @tparam table tbl the table containing the values to tween
-- @tparam table to the new values -- @tparam table to the new values
@ -374,9 +406,13 @@ timer_module = {
--- Creates another tween which will be initialized when the current one ends. --- Creates another tween which will be initialized when the current one ends.
-- If tbl_ and/or method_ are not specified, the values from the current tween will be used. -- If tbl_ and/or method_ are not specified, the values from the current tween will be used.
-- Returns the new tween. -- Returns the new tween timer.
-- @treturn TweenTimer -- @tparam number duration tween duration (seconds)
r.chain = function(_, duration_, tbl_, to_, method_) -- @tparam table tbl the table containing the values to tween
-- @tparam table to the new values
-- @tparam[opt="linear"] string/function method tweening method (string name or the actual function(time, start, change, duration))
-- @treturn TweenTimer the new timer
function r:chain(duration_, tbl_, to_, method_)
if not method_ and to_ then if not method_ and to_ then
if type(to_) == "string" then if type(to_) == "string" then
tbl_, to_, method_ = tbl, tbl_, to_ tbl_, to_, method_ = tbl, tbl_, to_

View file

@ -1,6 +1,6 @@
# ubiquitousse.util # ubiquitousse.util
Various functions useful for game developement. Various functions useful for Lua game developement.
You can read the documentation [here](https://reuh.github.io/ubiquitousse/modules/util.html). You can read the documentation [here](https://reuh.github.io/ubiquitousse/modules/util.html).

View file

@ -1,7 +1,9 @@
--- Various functions useful for game developement. --- Various functions useful for Lua game developement.
-- --
-- No dependency. -- No dependency.
-- @module util -- @module util
-- @usage
-- TODO
--- Functions --- Functions
-- @section Functions -- @section Functions