~jadedctrl/gem-xwx-moe
~jadedctrl/gem-xwx-moe/gemujo_ludo/mods.niaj/fasado/subtitles/doc/modules/util.html
~jadedctrl/gem-xwx-moe/gemujo_ludo/mods.niaj/fasado/subtitles/doc/modules/util.html
0 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
1 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
2 | <html> |
3 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
4 | <head> |
5 | <title>Subtitles API Reference</title> |
6 | <link rel="stylesheet" href="../ldoc.css" type="text/css" /> |
7 | </head> |
8 | <body> |
9 |
|
10 | <div id="container"> |
11 |
|
12 | <div id="product"> |
13 | <div id="product_logo"></div> |
14 | <div id="product_name"><big><b></b></big></div> |
15 | <div id="product_description"></div> |
16 | </div> <!-- id="product" --> |
17 |
|
18 |
|
19 | <div id="main"> |
20 |
|
21 |
|
22 | <!-- Menu --> |
23 |
|
24 | <div id="navigation"> |
25 | <br/> |
26 | <h1>ldoc</h1> |
27 |
|
28 | <ul> |
29 | <li><a href="../index.html">Index</a></li> |
30 | </ul> |
31 |
|
32 | <h2>Contents</h2> |
33 | <ul> |
34 | <li><a href="#Functions">Functions</a></li> |
35 | <li><a href="#Tables">Tables</a></li> |
36 | </ul> |
37 |
|
38 |
|
39 | <h2>Modules</h2> |
40 | <ul class="nowrap"> |
41 | <li><a href="../modules/Agent.html">Agent</a></li> |
42 | <li><a href="../modules/BaseTextSubtitleDisplay.html">BaseTextSubtitleDisplay</a></li> |
43 | <li><a href="../modules/ChatSubtitleDisplay.html">ChatSubtitleDisplay</a></li> |
44 | <li><a href="../modules/ClassicSubtitleDisplay.html">ClassicSubtitleDisplay</a></li> |
45 | <li><a href="../modules/CornerSubtitleDisplay.html">CornerSubtitleDisplay</a></li> |
46 | <li><a href="../modules/Sound.html">Sound</a></li> |
47 | <li><a href="../modules/SubtitleDisplay.html">SubtitleDisplay</a></li> |
48 | <li><a href="../modules/WaypointSubtitleDisplay.html">WaypointSubtitleDisplay</a></li> |
49 | <li><a href="../modules/api.html">api</a></li> |
50 | <li><a href="../modules/chatcommands.html">chatcommands</a></li> |
51 | <li><a href="../modules/descriptions.html">descriptions</a></li> |
52 | <li><a href="../modules/init.html">init</a></li> |
53 | <li><a href="../modules/listeners.html">listeners</a></li> |
54 | <li><a href="../modules/menu.html">menu</a></li> |
55 | <li><strong>util</strong></li> |
56 | </ul> |
57 |
|
58 | </div> |
59 |
|
60 | <div id="content"> |
61 |
|
62 | <h1>Module <code>util</code></h1> |
63 | <p>Generic utility functions.</p> |
64 | <p></p> |
65 |
|
66 |
|
67 | <h2><a href="#Functions">Functions</a></h2> |
68 | <table class="function_list"> |
69 | <tr> |
70 | <td class="name" nowrap><a href="#subtitles.util.get_node_sound">subtitles.util.get_node_sound (name, keys)</a></td> |
71 | <td class="summary">Returns the sound spec for a particular action on a node.</td> |
72 | </tr> |
73 | <tr> |
74 | <td class="name" nowrap><a href="#subtitles.util.get_dig_sound_for_groups">subtitles.util.get_dig_sound_for_groups (groups)</a></td> |
75 | <td class="summary">Decides which sounds to use for a node with the specified groups.</td> |
76 | </tr> |
77 | <tr> |
78 | <td class="name" nowrap><a href="#subtitles.util.describe_damage">subtitles.util.describe_damage (reason)</a></td> |
79 | <td class="summary">Describes how a player was damaged.</td> |
80 | </tr> |
81 | <tr> |
82 | <td class="name" nowrap><a href="#subtitles.util.update">subtitles.util.update (tbl, ...)</a></td> |
83 | <td class="summary">Updates a table, overriding existing keys.</td> |
84 | </tr> |
85 | <tr> |
86 | <td class="name" nowrap><a href="#subtitles.util.object_is_walking">subtitles.util.object_is_walking (objref)</a></td> |
87 | <td class="summary">Checks if a player or entity is moving at walking speed.</td> |
88 | </tr> |
89 | <tr> |
90 | <td class="name" nowrap><a href="#subtitles.util.get_feet_pos">subtitles.util.get_feet_pos (objref)</a></td> |
91 | <td class="summary">Returns the position of an object's feet based on its collision box.</td> |
92 | </tr> |
93 | <tr> |
94 | <td class="name" nowrap><a href="#subtitles.util.update_hud">subtitles.util.update_hud (player, hud_id, old_def, new_def)</a></td> |
95 | <td class="summary">Updates a HUD, only settings attributes that have changed.</td> |
96 | </tr> |
97 | <tr> |
98 | <td class="name" nowrap><a href="#subtitles.util.clamp">subtitles.util.clamp (value, min, max)</a></td> |
99 | <td class="summary">Clamps a number to within a specified range.</td> |
100 | </tr> |
101 | <tr> |
102 | <td class="name" nowrap><a href="#subtitles.util.get_meta_bool">subtitles.util.get_meta_bool (meta, key, default)</a></td> |
103 | <td class="summary">Reads a boolean value from metadata.</td> |
104 | </tr> |
105 | <tr> |
106 | <td class="name" nowrap><a href="#subtitles.util.set_meta_bool">subtitles.util.set_meta_bool (meta, key, value)</a></td> |
107 | <td class="summary">Writes a boolean value to metadata.</td> |
108 | </tr> |
109 | <tr> |
110 | <td class="name" nowrap><a href="#subtitles.util.rgb_to_number">subtitles.util.rgb_to_number (red, green, blue)</a></td> |
111 | <td class="summary">Converts a colour from RGB to a number for HUDs.</td> |
112 | </tr> |
113 | </table> |
114 | <h2><a href="#Tables">Tables</a></h2> |
115 | <table class="function_list"> |
116 | <tr> |
117 | <td class="name" nowrap><a href="#subtitles.util.HUDDirection">subtitles.util.HUDDirection</a></td> |
118 | <td class="summary">An enumerator of HUD directions.</td> |
119 | </tr> |
120 | <tr> |
121 | <td class="name" nowrap><a href="#subtitles.util.TextStyle">subtitles.util.TextStyle</a></td> |
122 | <td class="summary">A bitfield of HUD text styles.</td> |
123 | </tr> |
124 | </table> |
125 |
|
126 | <br/> |
127 | <br/> |
128 |
|
129 |
|
130 | <h2 class="section-header "><a name="Functions"></a>Functions</h2> |
131 |
|
132 | <dl class="function"> |
133 | <dt> |
134 | <a name = "subtitles.util.get_node_sound"></a> |
135 | <strong>subtitles.util.get_node_sound (name, keys)</strong> |
136 | </dt> |
137 | <dd> |
138 | Returns the sound spec for a particular action on a node. |
139 |
|
140 |
|
141 | <h3>Parameters:</h3> |
142 | <ul> |
143 | <li><span class="parameter">name</span> |
144 | The name of the node. |
145 | </li> |
146 | <li><span class="parameter">keys</span> |
147 | A key in the sounds table, such as 'dig' or 'footstep', or a list of such keys. |
148 | </li> |
149 | </ul> |
150 |
|
151 | <h3>Returns:</h3> |
152 | <ol> |
153 |
|
154 | A SimpleSoundSpec or `nil`. |
155 | </ol> |
156 |
|
157 |
|
158 |
|
159 |
|
160 | </dd> |
161 | <dt> |
162 | <a name = "subtitles.util.get_dig_sound_for_groups"></a> |
163 | <strong>subtitles.util.get_dig_sound_for_groups (groups)</strong> |
164 | </dt> |
165 | <dd> |
166 | Decides which sounds to use for a node with the specified groups. |
167 |
|
168 |
|
169 | <h3>Parameters:</h3> |
170 | <ul> |
171 | <li><span class="parameter">groups</span> |
172 | A group table. |
173 | </li> |
174 | </ul> |
175 |
|
176 | <h3>Returns:</h3> |
177 | <ol> |
178 |
|
179 | A SimpleSoundSpec or `nil`. |
180 | </ol> |
181 |
|
182 |
|
183 |
|
184 |
|
185 | </dd> |
186 | <dt> |
187 | <a name = "subtitles.util.describe_damage"></a> |
188 | <strong>subtitles.util.describe_damage (reason)</strong> |
189 | </dt> |
190 | <dd> |
191 | Describes how a player was damaged. |
192 |
|
193 |
|
194 | <h3>Parameters:</h3> |
195 | <ul> |
196 | <li><span class="parameter">reason</span> |
197 | A damage reason table, as passed to on_player_hp_change callbacks. |
198 | </li> |
199 | </ul> |
200 |
|
201 | <h3>Returns:</h3> |
202 | <ol> |
203 |
|
204 | A human-readabable description |
205 | </ol> |
206 |
|
207 |
|
208 |
|
209 |
|
210 | </dd> |
211 | <dt> |
212 | <a name = "subtitles.util.update"></a> |
213 | <strong>subtitles.util.update (tbl, ...)</strong> |
214 | </dt> |
215 | <dd> |
216 | Updates a table, overriding existing keys. |
217 |
|
218 |
|
219 | <h3>Parameters:</h3> |
220 | <ul> |
221 | <li><span class="parameter">tbl</span> |
222 | The table to update. |
223 | </li> |
224 | <li><span class="parameter">...</span> |
225 | Any number of additional tables to update from. |
226 | </li> |
227 | </ul> |
228 |
|
229 | <h3>Returns:</h3> |
230 | <ol> |
231 |
|
232 | A reference to the original table. |
233 | </ol> |
234 |
|
235 |
|
236 |
|
237 |
|
238 | </dd> |
239 | <dt> |
240 | <a name = "subtitles.util.object_is_walking"></a> |
241 | <strong>subtitles.util.object_is_walking (objref)</strong> |
242 | </dt> |
243 | <dd> |
244 | Checks if a player or entity is moving at walking speed. |
245 | This function does not check if the object is on ground. |
246 |
|
247 |
|
248 | <h3>Parameters:</h3> |
249 | <ul> |
250 | <li><span class="parameter">objref</span> |
251 | An ObjectRef. |
252 | </li> |
253 | </ul> |
254 |
|
255 | <h3>Returns:</h3> |
256 | <ol> |
257 |
|
258 | true if the object is moving at walking speed. |
259 | </ol> |
260 |
|
261 |
|
262 |
|
263 |
|
264 | </dd> |
265 | <dt> |
266 | <a name = "subtitles.util.get_feet_pos"></a> |
267 | <strong>subtitles.util.get_feet_pos (objref)</strong> |
268 | </dt> |
269 | <dd> |
270 | Returns the position of an object's feet based on its collision box. |
271 |
|
272 |
|
273 | <h3>Parameters:</h3> |
274 | <ul> |
275 | <li><span class="parameter">objref</span> |
276 | A player or entity. |
277 | </li> |
278 | </ul> |
279 |
|
280 | <h3>Returns:</h3> |
281 | <ol> |
282 |
|
283 | An absolute position vector. |
284 | </ol> |
285 |
|
286 |
|
287 |
|
288 |
|
289 | </dd> |
290 | <dt> |
291 | <a name = "subtitles.util.update_hud"></a> |
292 | <strong>subtitles.util.update_hud (player, hud_id, old_def, new_def)</strong> |
293 | </dt> |
294 | <dd> |
295 | Updates a HUD, only settings attributes that have changed. |
296 |
|
297 |
|
298 | <h3>Parameters:</h3> |
299 | <ul> |
300 | <li><span class="parameter">player</span> |
301 | A player ObjectRef. |
302 | </li> |
303 | <li><span class="parameter">hud_id</span> |
304 | The id of the HUD to update. |
305 | </li> |
306 | <li><span class="parameter">old_def</span> |
307 | The old HUD definition table. |
308 | </li> |
309 | <li><span class="parameter">new_def</span> |
310 | The new HUD definition table. |
311 | </li> |
312 | </ul> |
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 | </dd> |
319 | <dt> |
320 | <a name = "subtitles.util.clamp"></a> |
321 | <strong>subtitles.util.clamp (value, min, max)</strong> |
322 | </dt> |
323 | <dd> |
324 | Clamps a number to within a specified range. |
325 |
|
326 |
|
327 | <h3>Parameters:</h3> |
328 | <ul> |
329 | <li><span class="parameter">value</span> |
330 | The value to clamp. |
331 | </li> |
332 | <li><span class="parameter">min</span> |
333 | The lower bound. |
334 | </li> |
335 | <li><span class="parameter">max</span> |
336 | The upper bound. |
337 | </li> |
338 | </ul> |
339 |
|
340 | <h3>Returns:</h3> |
341 | <ol> |
342 |
|
343 | min, max, or value. |
344 | </ol> |
345 |
|
346 |
|
347 |
|
348 |
|
349 | </dd> |
350 | <dt> |
351 | <a name = "subtitles.util.get_meta_bool"></a> |
352 | <strong>subtitles.util.get_meta_bool (meta, key, default)</strong> |
353 | </dt> |
354 | <dd> |
355 | Reads a boolean value from metadata. |
356 |
|
357 |
|
358 | <h3>Parameters:</h3> |
359 | <ul> |
360 | <li><span class="parameter">meta</span> |
361 | The MetaDataRef to read from. |
362 | </li> |
363 | <li><span class="parameter">key</span> |
364 | The name of the metadata entry to read. |
365 | </li> |
366 | <li><span class="parameter">default</span> |
367 | The default value. Not necessarily a boolean. |
368 | </li> |
369 | </ul> |
370 |
|
371 | <h3>Returns:</h3> |
372 | <ol> |
373 |
|
374 | A boolean value or the default. |
375 | </ol> |
376 |
|
377 |
|
378 |
|
379 |
|
380 | </dd> |
381 | <dt> |
382 | <a name = "subtitles.util.set_meta_bool"></a> |
383 | <strong>subtitles.util.set_meta_bool (meta, key, value)</strong> |
384 | </dt> |
385 | <dd> |
386 | Writes a boolean value to metadata. |
387 |
|
388 |
|
389 | <h3>Parameters:</h3> |
390 | <ul> |
391 | <li><span class="parameter">meta</span> |
392 | The MetaDataRef to write to. |
393 | </li> |
394 | <li><span class="parameter">key</span> |
395 | The name of the metadata entry to write. |
396 | </li> |
397 | <li><span class="parameter">value</span> |
398 | The boolean value to write. |
399 | </li> |
400 | </ul> |
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 | </dd> |
407 | <dt> |
408 | <a name = "subtitles.util.rgb_to_number"></a> |
409 | <strong>subtitles.util.rgb_to_number (red, green, blue)</strong> |
410 | </dt> |
411 | <dd> |
412 | Converts a colour from RGB to a number for HUDs. |
413 |
|
414 |
|
415 | <h3>Parameters:</h3> |
416 | <ul> |
417 | <li><span class="parameter">red</span> |
418 | The red component, from 0 to 255. |
419 | </li> |
420 | <li><span class="parameter">green</span> |
421 | The green component, from 0 to 255. |
422 | </li> |
423 | <li><span class="parameter">blue</span> |
424 | The blue component, from 0 to 255. |
425 | </li> |
426 | </ul> |
427 |
|
428 | <h3>Returns:</h3> |
429 | <ol> |
430 |
|
431 | An integer in the form 0xRRGGBB. |
432 | </ol> |
433 |
|
434 |
|
435 |
|
436 |
|
437 | </dd> |
438 | </dl> |
439 | <h2 class="section-header "><a name="Tables"></a>Tables</h2> |
440 |
|
441 | <dl class="function"> |
442 | <dt> |
443 | <a name = "subtitles.util.HUDDirection"></a> |
444 | <strong>subtitles.util.HUDDirection</strong> |
445 | </dt> |
446 | <dd> |
447 | An enumerator of HUD directions. |
448 |
|
449 |
|
450 | <h3>Fields:</h3> |
451 | <ul> |
452 | <li><span class="parameter">LEFT_TO_RIGHT</span> |
453 |
|
454 | </li> |
455 | <li><span class="parameter">RIGHT_TO_LEFT</span> |
456 |
|
457 | </li> |
458 | <li><span class="parameter">TOP_TO_BOTTOM</span> |
459 |
|
460 | </li> |
461 | <li><span class="parameter">BOTTOM_TO_TOP</span> |
462 |
|
463 | </li> |
464 | </ul> |
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 | </dd> |
471 | <dt> |
472 | <a name = "subtitles.util.TextStyle"></a> |
473 | <strong>subtitles.util.TextStyle</strong> |
474 | </dt> |
475 | <dd> |
476 | A bitfield of HUD text styles. |
477 |
|
478 |
|
479 | <h3>Fields:</h3> |
480 | <ul> |
481 | <li><span class="parameter">REGULAR</span> |
482 |
|
483 | </li> |
484 | <li><span class="parameter">BOLD</span> |
485 |
|
486 | </li> |
487 | <li><span class="parameter">ITALIC</span> |
488 |
|
489 | </li> |
490 | <li><span class="parameter">MONOSPACE</span> |
491 |
|
492 | </li> |
493 | </ul> |
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 | </dd> |
500 | </dl> |
501 |
|
502 |
|
503 | </div> <!-- id="content" --> |
504 | </div> <!-- id="main" --> |
505 | <div id="about"> |
506 | <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> |
507 | <i style="float:right;">Last updated 2023-01-14 06:51:17 </i> |
508 | </div> <!-- id="about" --> |
509 | </div> <!-- id="container" --> |
510 | </body> |
511 | </html> |