From 69e19a215feb1bcdc62c3100972eb706a643710b Mon Sep 17 00:00:00 2001 From: mcb2003 Date: Tue, 27 Feb 2024 22:38:42 +0000 Subject: [PATCH] deploy: 572b64247adb5a38a1d98989aa7c7c2b9294f995 --- .nojekyll | 0 examples/enums.lua.html | 108 ++++++++ examples/hello_world.c.html | 99 ++++++++ examples/logging.lua.html | 99 ++++++++ examples/preload.c.html | 113 +++++++++ examples/readonly_tables..lua.html | 99 ++++++++ examples/strict_structs.lua.html | 109 ++++++++ examples/using_strict.lua.html | 94 +++++++ examples/weak_tables.lua.html | 90 +++++++ index.html | 159 ++++++++++++ ldoc.css | 304 ++++++++++++++++++++++ modules/lege.c_libs.html | 130 ++++++++++ modules/lege.enum.html | 321 ++++++++++++++++++++++++ modules/lege.log.html | 390 +++++++++++++++++++++++++++++ modules/lege.readonly.html | 180 +++++++++++++ modules/lege.strict.html | 107 ++++++++ modules/lege.struct.html | 325 ++++++++++++++++++++++++ modules/lege.weak.html | 246 ++++++++++++++++++ modules/lib.util.html | 89 +++++++ topics/README.md.html | 185 ++++++++++++++ 20 files changed, 3247 insertions(+) create mode 100644 .nojekyll create mode 100644 examples/enums.lua.html create mode 100644 examples/hello_world.c.html create mode 100644 examples/logging.lua.html create mode 100644 examples/preload.c.html create mode 100644 examples/readonly_tables..lua.html create mode 100644 examples/strict_structs.lua.html create mode 100644 examples/using_strict.lua.html create mode 100644 examples/weak_tables.lua.html create mode 100644 index.html create mode 100644 ldoc.css create mode 100644 modules/lege.c_libs.html create mode 100644 modules/lege.enum.html create mode 100644 modules/lege.log.html create mode 100644 modules/lege.readonly.html create mode 100644 modules/lege.strict.html create mode 100644 modules/lege.struct.html create mode 100644 modules/lege.weak.html create mode 100644 modules/lib.util.html create mode 100644 topics/README.md.html diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/examples/enums.lua.html b/examples/enums.lua.html new file mode 100644 index 0000000..ce90677 --- /dev/null +++ b/examples/enums.lua.html @@ -0,0 +1,108 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

enums.lua

+
+--- Demonstrates the lege.enum module.
+-- Enums are useful when you need to store a pre-defined set of values or options.
+
+local enum = require "lege.enum"
+
+-- Define an enum
+local Color = enum 'Color' {
+    -- Strings with numeric keys define enum values
+    "red",
+    "green",
+    "blue",
+    -- String keys allow you to define a different value
+    dark_orange = "red",
+    -- Values don't have to be strings, but keys do
+    black = 0,
+}
+
+print(Color) --> enum Color: 0xdeadbeaf
+
+assert(Color.red == "red")
+assert(Color.green == "green")
+assert(Color.blue == "blue")
+assert(Color.dark_orange == "red")
+assert(Color.black == 0)
+
+-- Trying to access an undefined enum value is an error
+-- print(Color.white) --> Error: no value 'white' on enum 'Color'
+-- Likewise trying to set a value is an error
+-- Color.White = 255 --> Error: attempt to set value 'White' on enum 'Color'
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/examples/hello_world.c.html b/examples/hello_world.c.html new file mode 100644 index 0000000..5ae9e19 --- /dev/null +++ b/examples/hello_world.c.html @@ -0,0 +1,99 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

hello_world.c

+
+/**
+ * Shows how to initialize a LEGE engine and load some Lua code into it.
+ */
+
+#include <lege.h>
+#include <stdio.h>
+
+int main(void) {
+  lege_engine_t engine = lege_engine_new();
+  if (!engine) {
+    perror("Failed to create engine");
+    return 1;
+  }
+  lege_engine_set_string(engine, LEGE_OPTION_APP_NAME, "Hello World");
+  lege_engine_set_string(engine, LEGE_OPTION_ORG_NAME, "lower-elements");
+  lege_engine_load_literal(engine, "print('Hello, world!')", "init.lua");
+  lege_engine_run(engine);
+  lege_engine_free(engine);
+  return 0;
+}
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/examples/logging.lua.html b/examples/logging.lua.html new file mode 100644 index 0000000..09c0f2c --- /dev/null +++ b/examples/logging.lua.html @@ -0,0 +1,99 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

logging.lua

+
+--- Example of LEGE's logging facilities via the lege.log module
+-- Logging can be useful when debugging your application, or to provide the user with information they can use when
+-- filing a bug report.
+
+local log = require "lege.log"
+
+log.info("Log priority is currently set to " .. log.get_priority())
+log.verbose("So you won't see this")
+log.set_priority("verbose")
+log.info("Log priority is now set to " .. log.get_priority())
+
+log.verbose("The game's still running")
+log.debug("Starting frobnication process ...")
+log.info("Logged in as xx_DankMemer69_xx")
+log.warn("That username is stupid")
+log.error("The server rejected your username, as it is too stupid")
+log.critical("Cannot continue with a user this stupid")
+
+local msg_type = "info"
+log.message(msg_type, "Yes, we're talking about *you*")
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/examples/preload.c.html b/examples/preload.c.html new file mode 100644 index 0000000..49700f6 --- /dev/null +++ b/examples/preload.c.html @@ -0,0 +1,113 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

preload.c

+
+/**
+ * Shows how to preload Lua modules into a LEGE engine.
+ */
+
+#include <lege.h>
+#include <stdio.h>
+
+static const char module[] = "\
+                              print('Test module loaded')\
+                              return {\
+                                  x = 5,\
+                                      y = 10,\
+                              }\
+                              ";
+
+static const char entrypoint[] = "\
+                                   local mod = require('test_module')\
+                                   print(mod.x + mod.y)\
+                                   ";
+
+int main(void) {
+  lege_engine_t engine = lege_engine_new();
+  if (!engine) {
+    perror("Failed to create engine");
+    return 1;
+  }
+  lege_engine_set_string(engine, LEGE_OPTION_APP_NAME, "Hello World");
+  lege_engine_set_string(engine, LEGE_OPTION_ORG_NAME, "lower-elements");
+  lege_engine_preload_literal(engine, module, "test_module");
+  lege_engine_load_literal(engine, entrypoint, "init.lua");
+  lege_engine_run(engine);
+  lege_engine_free(engine);
+  return 0;
+}
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/examples/readonly_tables..lua.html b/examples/readonly_tables..lua.html new file mode 100644 index 0000000..27513c9 --- /dev/null +++ b/examples/readonly_tables..lua.html @@ -0,0 +1,99 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

readonly_tables..lua

+
+--- Demonstrates the lege.readonly module, to make tables readonly.
+-- Readonly tables can be useful for constant values, to prevent code from accidentally modifying them.
+
+local readonly = require "lege.readonly"
+
+local consts = readonly {1, 2, 3; a=42, b=1337}
+
+-- Accessing values works as normal
+print("The value of consts.b is " .. consts.b)
+--> The value of b is 1337
+
+-- But changing them is an error
+-- consts.b = 100
+--> Error: attempt to modify readonly table
+
+-- You also can't get or set the table's metatable
+print("consts' metatable is " .. tostring(getmetatable(consts)))
+--> consts' metatable is false
+-- setmetatable(consts, {})
+--> Error: cannot change a protected metatable
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/examples/strict_structs.lua.html b/examples/strict_structs.lua.html new file mode 100644 index 0000000..f3e2a43 --- /dev/null +++ b/examples/strict_structs.lua.html @@ -0,0 +1,109 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

strict_structs.lua

+
+--- Demonstrates the creation of strict structs with the lege.struct module
+-- Strict structs have predefined fields, and trying to access undefined fields is an error.
+
+local struct = require "lege.struct"
+
+-- Define a Point struct, to hold x and y coordinates
+local Point = struct 'Point' {
+    x = 0,
+    y = 0,
+}
+
+-- Create a Point
+local p = Point {
+    x = 10,
+    y = 20,
+}
+print(p) --> struct Point: 0xdeadbeaf
+assert(p.x == 10)
+assert(p.y == 20)
+-- Trying to access or modify an undefined field is an error
+-- print(p.z) --> Error: no field 'z' on struct Point
+
+-- When constructing a new struct, unspecified fields get their default values
+p = Point {x=1}
+assert(p.x == 1)
+assert(p.y == 0)
+
+-- Struct fields can be modified as you'd expect, but don't set them to nil!
+p.y = 42
+assert(p.y == 42)
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/examples/using_strict.lua.html b/examples/using_strict.lua.html new file mode 100644 index 0000000..ac66b37 --- /dev/null +++ b/examples/using_strict.lua.html @@ -0,0 +1,94 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

using_strict.lua

+
+--- The lege.strict module prevents use of undeclared global variables.
+-- Since all undeclared global variables in Lua have the value nil by default, it can be easy to accidentally use a
+-- global variable when you really wanted to use a local variable. You might even accidentally overwrite a global
+-- variable by typoing the name of an existing local variable. The "lege.strict" module causes accesses to global
+-- variables outside of C or a module's main chunk (I.E. not in any function) to raise an error.
+
+require "lege.strict"
+
+-- With strict, accessing global variables from anywhere that aren't first declared is an error
+-- print("The value of x is " .. tostring(x)) -- Error: variable 'x' is not declared
+
+-- You declare global variables anywhere in a main chunk (I.E. not in a function)
+-- They can be set to anything, even nil!
+x = nil
+print("The value of x is " .. tostring(x)) --> The value of x is nil
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/examples/weak_tables.lua.html b/examples/weak_tables.lua.html new file mode 100644 index 0000000..8330a72 --- /dev/null +++ b/examples/weak_tables.lua.html @@ -0,0 +1,90 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

weak_tables.lua

+
+--- Demonstrates the lege.weak module, for convenient creation of weak tables.
+
+local weak = require "lege.weak"
+
+-- Construct a table with both weak keys and weak values ('kv')
+local t = weak 'kv' {}
+print(t) --> weak table kv: 0xdeadbeaf
+print(getmetatable(t).__mode) --> kv
+
+-- For more information about weak tables, see section 2.10.2 of the Lua 5.1 reference manual:
+-- <https://www.lua.org/manual/5.1/manual.html#2.10.2>
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/index.html b/index.html new file mode 100644 index 0000000..7c7fe04 --- /dev/null +++ b/index.html @@ -0,0 +1,159 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ + +

The Lower Elements Game Engine

+

+

⚠️ Unstable APIs Ahead!

+ +

This is a beta (I.E. before v1.0.0) version of LEGE. As such, all APIs are considered unstable unless otherwise noted.

+ +

+ +

Modules

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
lege.c_libsAccess to common C libraries.
lege.enumAllows the creation of enumerations.
lege.logLogging facilities for LEGE programs.
lege.readonlyAllows the creation of readonly tables.
lege.strictchecks uses of undeclared global variables.
lege.structAllows the creation of strict structs.
lege.weakCreate tables with weak references to their keys and / or values.
lib.utilUsed by lib/modules/lutf8lib.c (LEGE port of PUC Lua 5.4's utf8 module)
+

Topics

+ + + + + +
README.md
+

Examples

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
enums.lua
hello_world.c
logging.lua
preload.c
readonly_tables..lua
strict_structs.lua
using_strict.lua
weak_tables.lua
+ +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/ldoc.css b/ldoc.css new file mode 100644 index 0000000..f945ae7 --- /dev/null +++ b/ldoc.css @@ -0,0 +1,304 @@ +/* BEGIN RESET + +Copyright (c) 2010, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.com/yui/license.html +version: 2.8.2r1 +*/ +html { + color: #000; + background: #FFF; +} +body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { + margin: 0; + padding: 0; +} +table { + border-collapse: collapse; + border-spacing: 0; +} +fieldset,img { + border: 0; +} +address,caption,cite,code,dfn,em,strong,th,var,optgroup { + font-style: inherit; + font-weight: inherit; +} +del,ins { + text-decoration: none; +} +li { + margin-left: 20px; +} +caption,th { + text-align: left; +} +h1,h2,h3,h4,h5,h6 { + font-size: 100%; + font-weight: bold; +} +q:before,q:after { + content: ''; +} +abbr,acronym { + border: 0; + font-variant: normal; +} +sup { + vertical-align: baseline; +} +sub { + vertical-align: baseline; +} +legend { + color: #000; +} +input,button,textarea,select,optgroup,option { + font-family: inherit; + font-size: inherit; + font-style: inherit; + font-weight: inherit; +} +input,button,textarea,select {*font-size:100%; +} +/* END RESET */ + +body { + margin-left: 1em; + margin-right: 1em; + font-family: arial, helvetica, geneva, sans-serif; + background-color: #ffffff; margin: 0px; +} + +code, tt { font-family: monospace; font-size: 1.1em; } +span.parameter { font-family:monospace; } +span.parameter:after { content:":"; } +span.types:before { content:"("; } +span.types:after { content:")"; } +.type { font-weight: bold; font-style:italic } + +body, p, td, th { font-size: .95em; line-height: 1.2em;} + +p, ul { margin: 10px 0 0 0px;} + +strong { font-weight: bold;} + +em { font-style: italic;} + +h1 { + font-size: 1.5em; + margin: 20px 0 20px 0; +} +h2, h3, h4 { margin: 15px 0 10px 0; } +h2 { font-size: 1.25em; } +h3 { font-size: 1.15em; } +h4 { font-size: 1.06em; } + +a:link { font-weight: bold; color: #004080; text-decoration: none; } +a:visited { font-weight: bold; color: #006699; text-decoration: none; } +a:link:hover { text-decoration: underline; } + +hr { + color:#cccccc; + background: #00007f; + height: 1px; +} + +blockquote { margin-left: 3em; } + +ul { list-style-type: disc; } + +p.name { + font-family: "Andale Mono", monospace; + padding-top: 1em; +} + +pre { + background-color: rgb(245, 245, 245); + border: 1px solid #C0C0C0; /* silver */ + padding: 10px; + margin: 10px 0 10px 0; + overflow: auto; + font-family: "Andale Mono", monospace; +} + +pre.example { + font-size: .85em; +} + +table.index { border: 1px #00007f; } +table.index td { text-align: left; vertical-align: top; } + +#container { + margin-left: 1em; + margin-right: 1em; + background-color: #f0f0f0; +} + +#product { + text-align: center; + border-bottom: 1px solid #cccccc; + background-color: #ffffff; +} + +#product big { + font-size: 2em; +} + +#main { + background-color: #f0f0f0; + border-left: 2px solid #cccccc; +} + +#navigation { + float: left; + width: 14em; + vertical-align: top; + background-color: #f0f0f0; + overflow: visible; +} + +#navigation h2 { + background-color:#e7e7e7; + font-size:1.1em; + color:#000000; + text-align: left; + padding:0.2em; + border-top:1px solid #dddddd; + border-bottom:1px solid #dddddd; +} + +#navigation ul +{ + font-size:1em; + list-style-type: none; + margin: 1px 1px 10px 1px; +} + +#navigation li { + text-indent: -1em; + display: block; + margin: 3px 0px 0px 22px; +} + +#navigation li li a { + margin: 0px 3px 0px -1em; +} + +#content { + margin-left: 14em; + padding: 1em; + width: 700px; + border-left: 2px solid #cccccc; + border-right: 2px solid #cccccc; + background-color: #ffffff; +} + +#about { + clear: both; + padding: 5px; + border-top: 2px solid #cccccc; + background-color: #ffffff; +} + +@media print { + body { + font: 12pt "Times New Roman", "TimeNR", Times, serif; + } + a { font-weight: bold; color: #004080; text-decoration: underline; } + + #main { + background-color: #ffffff; + border-left: 0px; + } + + #container { + margin-left: 2%; + margin-right: 2%; + background-color: #ffffff; + } + + #content { + padding: 1em; + background-color: #ffffff; + } + + #navigation { + display: none; + } + pre.example { + font-family: "Andale Mono", monospace; + font-size: 10pt; + page-break-inside: avoid; + } +} + +table.module_list { + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.module_list td { + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.module_list td.name { background-color: #f0f0f0; min-width: 200px; } +table.module_list td.summary { width: 100%; } + + +table.function_list { + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.function_list td { + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.function_list td.name { background-color: #f0f0f0; min-width: 200px; } +table.function_list td.summary { width: 100%; } + +ul.nowrap { + overflow:auto; + white-space:nowrap; +} + +dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;} +dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;} +dl.table h3, dl.function h3 {font-size: .95em;} + +/* stop sublists from having initial vertical space */ +ul ul { margin-top: 0px; } +ol ul { margin-top: 0px; } +ol ol { margin-top: 0px; } +ul ol { margin-top: 0px; } + +/* make the target distinct; helps when we're navigating to a function */ +a:target + * { + background-color: #FF9; +} + + +/* styles for prettification of source */ +pre .comment { color: #558817; } +pre .constant { color: #a8660d; } +pre .escape { color: #844631; } +pre .keyword { color: #aa5050; font-weight: bold; } +pre .library { color: #0e7c6b; } +pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; } +pre .string { color: #8080ff; } +pre .number { color: #f8660d; } +pre .function-name { color: #60447f; } +pre .operator { color: #2239a8; font-weight: bold; } +pre .preprocessor, pre .prepro { color: #a33243; } +pre .global { color: #800080; } +pre .user-keyword { color: #800080; } +pre .prompt { color: #558817; } +pre .url { color: #272fc2; text-decoration: underline; } + diff --git a/modules/lege.c_libs.html b/modules/lege.c_libs.html new file mode 100644 index 0000000..981cd5c --- /dev/null +++ b/modules/lege.c_libs.html @@ -0,0 +1,130 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module lege.c_libs

+

Access to common C libraries.

+

Libraries used by LEGE, such as SDL are exposed here as loaded FFI libraries.

+

See also:

+ + + +

Fields

+ + + + + +
sdlThe SDL library.
+ +
+
+ + +

Fields

+ +
+
+ + sdl +
+
+ The SDL library. + Used by LEGE for graphics, input, and operating system functions such as file handling.

+ +

LEGE currently uses SDL2. + + +

    +
  • sdl + + + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/modules/lege.enum.html b/modules/lege.enum.html new file mode 100644 index 0000000..2de6c6f --- /dev/null +++ b/modules/lege.enum.html @@ -0,0 +1,321 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module lege.enum

+

Allows the creation of enumerations.

+

Lege enums are immutable, meaning trying to add or change enum values after + their creation is an error, and detect accesses to undefined enum values.

+ +

Values can have any underlying type, but their keys must be strings.

+

Usage:

+
    +
    local enum = require "lege.enum"
    +
    +-- Define an enum
    +local Color = enum 'Color' {
    +-- Strings with numeric keys define enum values
    +"red",
    +"green",
    +"blue",
    +-- String keys allow you to define a different value
    +dark_orange = "red",
    +-- Values don't have to be strings, but keys do
    +black = 0,
    +}
    +
    +print(Color) --> enum Color: 0xdeadbeaf
    +
    +assert(Color.red == "red")
    +assert(Color.green == "green")
    +assert(Color.blue == "blue")
    +assert(Color.dark_orange == "red")
    +assert(Color.black == 0)
    +
    +-- Trying to access an undefined enum value is an error
    +-- print(Color.white) --> Error: no value 'white' on enum 'Color'
    +-- Likewise trying to set a value is an error
    +-- Color.White = 255 --> Error: attempt to set value 'White' on enum 'Color'
    +
    +
+ + +

Meta Methods

+ + + + + + + + + +
__newindexRaises an error caused by trying to modify an enum value.
__tostringConvert an enum type to a human-readable string.
+

Functions

+ + + + + + + + + + + + + + + + + +
returns... () + +
_enum_err_nf (self, key)Raises an error caused by access to an undefined enum value.
enum_body (values)Define an enum's values.
enum (name)Create an enum type.
+ +
+
+ + +

Meta Methods

+ +
+
+ + __newindex +
+
+ Raises an error caused by trying to modify an enum value. + + +

param:

+
    +
  • self + enum + The enum instance +
  • +
  • key + string + The key that was undefined +
  • +
  • value + The value that you tried to set +
  • +
+ + + + + +
+
+ + __tostring +
+
+ Convert an enum type to a human-readable string. + Currently we merely output the enum's name and address. + + +

param:

+
    +
  • self + enum + The enum to convert to a string +
  • +
+ + + + + +
+
+

Functions

+ +
+
+ + returns... () +
+
+ + + + + + +

Returns:

+
    + + A function enum for creating new enumeration types. +
+ + + + +
+
+ + _enum_err_nf (self, key) +
+
+ Raises an error caused by access to an undefined enum value. + + +

Parameters:

+
    +
  • self + enum + The enum instance +
  • +
  • key + string + The key that was undefined +
  • +
+ + +

Raises:

+ An error indicating which value was undefined, and on which enum + type + + + +
+
+ + enum_body (values) +
+
+ Define an enum's values. + A closure over an enum's name returned from enum which creates a new + metatable for the enum type, and allows you to define what + values the struct has. + + +

Parameters:

+
    +
  • values + table + Values for the new struct type +
  • +
+ +

Returns:

+
    + + enum + The new enum type +
+ + + + +
+
+ + enum (name) +
+
+ Create an enum type. + + +

Parameters:

+
    +
  • name + string + The enum's type name (used when converting to string) +
  • +
+ +

Returns:

+
    + + A closure over name enum_body to allow you to specify the + enum's values +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/modules/lege.log.html b/modules/lege.log.html new file mode 100644 index 0000000..e753a2c --- /dev/null +++ b/modules/lege.log.html @@ -0,0 +1,390 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module lege.log

+

Logging facilities for LEGE programs.

+

This module uses SDL's logging + facilities to write log messages to the appropriate place for each + platform.

+

Usage:

+
    +
    local log = require "lege.log"
    +
    +log.info("Log priority is currently set to " .. log.get_priority())
    +log.verbose("So you won't see this")
    +log.set_priority("verbose")
    +log.info("Log priority is now set to " .. log.get_priority())
    +
    +log.verbose("The game's still running")
    +log.debug("Starting frobnication process ...")
    +log.info("Logged in as xx_DankMemer69_xx")
    +log.warn("That username is stupid")
    +log.error("The server rejected your username, as it is too stupid")
    +log.critical("Cannot continue with a user this stupid")
    +
    +local msg_type = "info"
    +log.message(msg_type, "Yes, we're talking about *you*")
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
get_priority ()Get the lowest log priority at which log messages are output.
set_priority (priority)Set the lowest log priority at which log messages are output.
message (priority, message)Log a message at the specified priority.
verbose (message)Log a message at the verbose priority.
debug (message)Log a message at the debug priority.
info (message)Log a message at the info priority.
warn (message)Log a message at the warn priority.
error (message)Log a message at the error priority.
critical (message)Log a message at the critical priority.
+ +
+
+ + +

Functions

+ +
+
+ + get_priority () +
+
+ Get the lowest log priority at which log messages are output. + + + +

Returns:

+
    + + string + The current SDL log priority +
+ + +

See also:

+ + + +
+
+ + set_priority (priority) +
+
+ Set the lowest log priority at which log messages are output. + + +

Parameters:

+
    +
  • priority + string + The new SDL log priority +
  • +
+ + +

Raises:

+ if priority is not a valid log message priority + +

See also:

+ + + +
+
+ + message (priority, message) +
+
+ Log a message at the specified priority. + + +

Parameters:

+
    +
  • priority + string + The priority of the log message +
  • +
  • message + string + The message to log +
  • +
+ + +

Raises:

+ if priority is not a valid log message priority + +

See also:

+ + + +
+
+ + verbose (message) +
+
+ Log a message at the verbose priority. + + +

Parameters:

+
    +
  • message + string + The message to log +
  • +
+ + + +

See also:

+ + + +
+
+ + debug (message) +
+
+ Log a message at the debug priority. + + +

Parameters:

+
    +
  • message + string + The message to log +
  • +
+ + + +

See also:

+ + + +
+
+ + info (message) +
+
+ Log a message at the info priority. + + +

Parameters:

+
    +
  • message + string + The message to log +
  • +
+ + + +

See also:

+ + + +
+
+ + warn (message) +
+
+ Log a message at the warn priority. + + +

Parameters:

+
    +
  • message + string + The message to log +
  • +
+ + + +

See also:

+ + + +
+
+ + error (message) +
+
+ Log a message at the error priority. + + +

Parameters:

+
    +
  • message + string + The message to log +
  • +
+ + + +

See also:

+ + + +
+
+ + critical (message) +
+
+ Log a message at the critical priority. + + +

Parameters:

+
    +
  • message + string + The message to log +
  • +
+ + + +

See also:

+ + + +
+
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/modules/lege.readonly.html b/modules/lege.readonly.html new file mode 100644 index 0000000..d03b6c5 --- /dev/null +++ b/modules/lege.readonly.html @@ -0,0 +1,180 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module lege.readonly

+

Allows the creation of readonly tables.

+

+ +

+

Usage:

+
    +
    local readonly = require "lege.readonly"
    +
    +local consts = readonly {1, 2, 3; a=42, b=1337}
    +
    +-- Accessing values works as normal
    +print("The value of consts.b is " .. consts.b)
    +--> The value of b is 1337
    +
    +-- But changing them is an error
    +-- consts.b = 100
    +--> Error: attempt to modify readonly table
    +
    +-- You also can't get or set the table's metatable
    +print("consts' metatable is " .. tostring(getmetatable(consts)))
    +--> consts' metatable is false
    +-- setmetatable(consts, {})
    +--> Error: cannot change a protected metatable
    +
    +
+ + +

Functions

+ + + + + + + + + +
returns... () + +
readonly (T)Make the passed table readonly.
+ +
+
+ + +

Functions

+ +
+
+ + returns... () +
+
+ + + + + + +

Returns:

+
    + + A function readonly for making tables readonly +
+ + + + +
+
+ + readonly (T) +
+
+ Make the passed table readonly. + + +

Parameters:

+
    +
  • T + table + The table to make readonly +
  • +
+ +

Returns:

+
    + + table + A table with readonly access to the keys and values in the + passed table +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/modules/lege.strict.html b/modules/lege.strict.html new file mode 100644 index 0000000..66a8569 --- /dev/null +++ b/modules/lege.strict.html @@ -0,0 +1,107 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module lege.strict

+

checks uses of undeclared global variables.

+

All global variables must be 'declared' through a regular assignment + (even assigning nil will do) in a main chunk before being used + anywhere or assigned to inside a function.

+ +

This is a C API port of "strict.lua" from the Lua distribution

+

Usage:

+
    +
    require "lege.strict"
    +
    +-- With strict, accessing global variables from anywhere that aren't first
    +declared is an error
    +-- print("The value of x is " .. tostring(x))
    + --> Error: variable 'x' is not declared
    +
    +-- You declare global variables anywhere in a main chunk (I.E. not in a
    +function)
    +-- They can be set to anything, even nil!
    +x = nil
    +print("The value of x is " .. tostring(x)) --> The value of x is nil
    +
    +
+ + + +
+
+ + + + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/modules/lege.struct.html b/modules/lege.struct.html new file mode 100644 index 0000000..d00245f --- /dev/null +++ b/modules/lege.struct.html @@ -0,0 +1,325 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module lege.struct

+

Allows the creation of strict structs.

+

Strict structs defined by this module have strict field + access (I.E. trying to get or set the value of a field that is undefined for + a given struct type is an error).

+

Usage:

+
    +
    local struct = require "lege.struct"
    +
    +-- Define a Point struct, to hold x and y coordinates
    +local Point = struct 'Point' {
    +x = 0,
    +y = 0,
    +}
    +
    +-- Create a Point
    +local p = Point {
    +x = 10,
    +y = 20,
    +}
    +print(p) --> struct Point: 0xdeadbeaf
    +assert(p.x == 10)
    +assert(p.y == 20)
    +-- Trying to access or modify an undefined field is an error
    +-- print(p.z) --> Error: no field 'z' on struct Point
    +
    +-- When constructing a new struct, unspecified fields get their default
    +values p = Point {x=1} assert(p.x == 1) assert(p.y == 0)
    +
    +-- Struct fields can be modified as you'd expect, but don't set them to nil!
    +p.y = 42
    +assert(p.y == 42)
    +
    +
+ + +

Meta Methods

+ + + + + +
__tostringConvert a struct type to a human-readable string.
+

Functions

+ + + + + + + + + + + + + + + + + + + + + +
returns... () + +
_struct_err_nf (self, key)Raises an error caused by access to an undefined struct field.
new_instance (instance)Create a new struct type.
struct_body (fields)Define a struct's body.
struct (string)Create a struct type.
+ +
+
+ + +

Meta Methods

+ +
+
+ + __tostring +
+
+ Convert a struct type to a human-readable string. + Currently we merely output the struct's name and address. + + +

param:

+
    +
  • self + struct + The struct to convert to a string +
  • +
+ + + + + +
+
+

Functions

+ +
+
+ + returns... () +
+
+ + + + + + +

Returns:

+
    + + A function struct that Allows you to define structs +
+ + + + +
+
+ + _struct_err_nf (self, key) +
+
+ Raises an error caused by access to an undefined struct field. + + +

Parameters:

+
    +
  • self + struct + The struct instance +
  • +
  • key + string + The key that was undefined +
  • +
+ + +

Raises:

+ An error indicating which field was undefined, and on which struct + type + + + +
+
+ + new_instance (instance) +
+
+ Create a new struct type. + This is used as a closure returned from struct_body, and creates a new + instance of a struct. Any unset fields are set to their default value as + defined by the struct type. + + +

Parameters:

+
    +
  • instance + table + Table to use as the struct instance, including any + pre-initialized fields +
  • +
+ +

Returns:

+
    + + table + The passed instance, modified to be a struct of the correct + type +
+ +

Raises:

+ If instance contains undefined fields for the struct type + + + +
+
+ + struct_body (fields) +
+
+ Define a struct's body. + A closure over a struct's name returned from struct which creates a new + metatable for the struct type, and allows you to define what fields and + default values the struct has. + + +

Parameters:

+
    +
  • fields + table + Fields and default values for the new struct type +
  • +
+ +

Returns:

+
    + + A closure new_instance over the struct type's name and fields to + create a new instance of the defined struct type +
+ + + + +
+
+ + struct (string) +
+
+ Create a struct type. + + +

Parameters:

+
    +
  • string + name The struct's type name (used when converting to string) +
  • +
+ +

Returns:

+
    + + A + closure over name struct_body to allow you to specify the + struct's fields and default values +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/modules/lege.weak.html b/modules/lege.weak.html new file mode 100644 index 0000000..bbbf02c --- /dev/null +++ b/modules/lege.weak.html @@ -0,0 +1,246 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module lege.weak

+

Create tables with weak references to their keys and / or values.

+

This module provides a convenience function for creating weak tables, which + are described in section 2.10.2 of the Lua 5.1 reference + manual.

+

Usage:

+
    +
    local weak = require "lege.weak"
    +
    +-- Construct a table with both weak keys and weak values ('kv')
    +local t = weak 'kv' {}
    +print(t) --> weak table kv: 0xdeadbeaf
    +print(getmetatable(t).__mode) --> kv
    +
    +
+ + +

Meta Methods

+ + + + + +
__tostringConvert a weak table to a string.
+

Functions

+ + + + + + + + + + + + + +
returns... () + +
weak_constructor (tbl)Construct a weak table.
weak (mode)Create a weak table.
+ +
+
+ + +

Meta Methods

+ +
+
+ + __tostring +
+
+ Convert a weak table to a string. + The returned string includes the table's mode and address. + + +

param:

+
    +
  • weak_tbl + table + The weak table to convert to a string +
  • +
+ + + + + +
+
+

Functions

+ +
+
+ + returns... () +
+
+ + + + + + +

Returns:

+
    + + A function, weak, for constructing weak tables +
+ + + + +
+
+ + weak_constructor (tbl) +
+
+ Construct a weak table. + This function is returned from weak, and allows specifying the table to + make weak, according to the mode specified by the first parameter to weak. + + +

Parameters:

+
    +
  • tbl + table + The table to make weak +
  • +
+ +

Returns:

+
    + + table + The passed parameter, now a weak table +
+ + + + +
+
+ + weak (mode) +
+
+ +

Create a weak table. + The mode parameter can be one of:

+ +
    +
  • 'k': Table has weak keys
  • +
  • 'v': Table has weak values
  • +
  • 'kv': Table has both weak keys and weak values
  • +
+ + + +

Parameters:

+
    +
  • mode + string + The weak mode +
  • +
+ +

Returns:

+
    + + A function, weak_constructor, for specifying the table to make + weak +
+ +

Raises:

+ If the specified mode is invalid + + + +
+
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/modules/lib.util.html b/modules/lib.util.html new file mode 100644 index 0000000..dac208c --- /dev/null +++ b/modules/lib.util.html @@ -0,0 +1,89 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module lib.util

+

Used by lib/modules/lutf8lib.c (LEGE port of PUC Lua 5.4's utf8 module)

+

+ +

+ + + +
+
+ + + + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ + diff --git a/topics/README.md.html b/topics/README.md.html new file mode 100644 index 0000000..153273e --- /dev/null +++ b/topics/README.md.html @@ -0,0 +1,185 @@ + + + + + LEGE Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ + +

LEGE - The Lower Elements Game Engine

+ +

License: LGPL3 +Documentation +GitHub issues

+ + +

LEGE is a free software, open source game engine for building audio games. Its goals, in order, are to +be:

+ +
    +
  1. Easy to use
  2. +
  3. Cross platform
  4. +
  5. Powerful and extensible
  6. +
  7. Blazing fast!
  8. +
+ + +

+

Under Active and Early Development

+ +

This software is under active development and is in an early state. Everything described in this readme is aspirational, +and not necessarily representative of LEGE as it stands today. If you'd like to help, we love getting pull +requests.

+ + +

+

Easy to Use

+ +

LEGE uses the Lua programming language: "a powerful, efficient, lightweight, embeddable scripting language." It +is easy to get started building LEGE games, even if you're quite new to programming. The knowledge you gain writing LEGE +applications in Lua can also be used to write standalone Lua applications, and we embrace and promote Lua best practices +and existing convensions.

+ + +

+

Cross Platform

+ +

LEGE leverages well established, portable C libraries including SDL for input and rendering, and OpenAL +(specifically OpenAL Soft) for high quality, 3 dimensional audio. It is compatible with all major desktop +OS platforms: Windows, macOS, Linux, *BSD, etc. I also plan to put effort into making LEGE work on mobile devices where +possible, such as on Android and iOS. Audio gaming should be accessible to all!

+ +

Distributing a LEGE project is as easy as running lege dist, and publishing the built distribution (.zip / .exe +installer on Windows, .app / .dmg on macOS, Flatpak / Snap / Deb / whatever package format you choose on Linux).

+ + +

+

Powerful and Extensible

+ +

LEGE is designed to be highly extensible, offering the flexibility to use existing Lua or C modules, as well as +third-party providers for additional engine functionalities like map loading, networking, game chat, and updates. You +can even create your own modules to enhance the engine's capabilities.

+ +

Want to use the Discord SDK in your game? It's as easy as:

+ + +
+lege package add discord-sdk
+
+ + + +
+-- file: init.lua
+local discord = require "discord-sdk"
+
+ + +

Blazing Fast!

+ +

LEGE utilizes LuaJIT by default, which employs just-in-time compilation to translate Lua code into native +machine code, resulting in performance nearly on par with C. The core engine is written in C to ensure optimal +performance. Our aim is to strike the perfect balance between speed and ease of use.

+ + + +

+

Documentation

+ +

View the LEGE manual, API documentation, and examples on Github Pages

+ +

+

License

+ +

LEGE is distributed under the terms of the GNU Lesser General Public License 3.0:

+ +

Copyright (C) 2023 Michael Connor Buchan mikey@blindcomputing.org

+ +

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; version 3 of the License.

+ +

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details.

+ +

You should have received a copy of the GNU Lesser General Public License along with this library; if not, see +https://www.gnu.org/licenses/.

+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-02-27 22:38:41 +
+
+ +