From 0251176f4f5283a71116771f625aee00ed785af6 Mon Sep 17 00:00:00 2001 From: FatalErr42O <58855799+FatalError42O@users.noreply.github.com> Date: Mon, 8 Jan 2024 19:31:05 -0800 Subject: [PATCH] documented media paths --- docs/index.html | 236 +----------------- docs/modules/binary.html | 284 ++++++++++++++++++++++ docs/modules/paths.html | 185 ++++++++++++++ init.lua | 15 +- modlib/{mod_utils_media.lua => paths.lua} | 57 ++++- 5 files changed, 534 insertions(+), 243 deletions(-) create mode 100644 docs/modules/binary.html create mode 100644 docs/modules/paths.html rename modlib/{mod_utils_media.lua => paths.lua} (55%) diff --git a/docs/index.html b/docs/index.html index e0712b8..b00010c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -28,252 +28,40 @@ -

Contents

-

Modules

-

Module binary

-

read and write (little endian) binary.

-

located in mtul.binary.

+

implements core dependencies and tools, especially for the MTUL libraries.

-

reading binary inputs

- +

Modules

+
- - + + - - - - - - - - - - + +
read_single (function)read an IEEE 754 single precision (32-bit) floating point numberbinaryread and write (little endian) binary.
read_double (function)read an IEEE 754 double-precision (64-bit) floating point number
read_uint (function, int)read an unsigned integer of any given length
read_uint (function, int)read a signed integer of any given lengthpathsmod utilities +find the paths + find mod information
-

misc binary helpers

- - - - - -
fround (number)"returns nearest 32-bit single precision float representation of a number" (or something)
-

expected function inputs

- - - - - - - - - -
read_byte ()read_byte is a param name which refers to a function which reads the next byte- returning a whole number between 0-255.
write_byte ()write_byte is similar to read_byte, however it is given an input and expected to write it to the file.
- -
-
- - -

reading binary inputs

- -
- read a binary inputs using a read_byte function. -
-
-
- - read_single (function) -
-
- read an IEEE 754 single precision (32-bit) floating point number - - -

Parameters:

- - - - - - -
-
- - read_double (function) -
-
- read an IEEE 754 double-precision (64-bit) floating point number - - -

Parameters:

- - - - - - -
-
- - read_uint (function, int) -
-
- read an unsigned integer of any given length - - -

Parameters:

-
    -
  • function - read_byte -
  • -
  • int - length in bytes of unsigned integer -
  • -
- - - - - -
-
- - read_uint (function, int) -
-
- read a signed integer of any given length - - -

Parameters:

-
    -
  • function - read_byte -
  • -
  • int - length in bytes of integer -
  • -
- - - - - -
-
-

misc binary helpers

- -
-
- - fround (number) -
-
- "returns nearest 32-bit single precision float representation of a number" (or something) - - -

Parameters:

-
    -
  • number - - - -
  • -
- -

Returns:

-
    - - nearest 32-bit single precision float representation of a number -
- - - - -
-
-

expected function inputs

- -
- functions will expect either a read_byte or write_byte function as inputs -
-
-
- - read_byte () -
-
- -

read_byte is a param name which refers to a function which reads the next byte- returning a whole number between 0-255.

- -
function byte()
-    left = left - 1
-    return assert(file_handle:read(1):byte())
-    --reads the next chracter, and converts it to a "numerical code" using string.byte()
-    --it's important that this function moves forward in the file stream (as :read(1) does)
-end
-
- - - - -

Returns:

-
    - - a bytecode (an int between 0 and 255.) -
- - - - -
-
- - write_byte () -
-
- write_byte is similar to read_byte, however it is given an input and expected to write it to the file. - (example needed) - - - - - - - -
-
-
generated by LDoc 1.5.0 -Last updated 2024-01-08 18:14:41 +Last updated 2024-01-08 19:24:47
diff --git a/docs/modules/binary.html b/docs/modules/binary.html new file mode 100644 index 0000000..bde7130 --- /dev/null +++ b/docs/modules/binary.html @@ -0,0 +1,284 @@ + + + + + MTUL core + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module binary

+

read and write (little endian) binary.

+

located in mtul.binary.

+ + +

reading binary inputs

+ + + + + + + + + + + + + + + + + +
read_single (function)read an IEEE 754 single precision (32-bit) floating point number
read_double (function)read an IEEE 754 double-precision (64-bit) floating point number
read_uint (function, int)read an unsigned integer of any given length
read_uint (function, int)read a signed integer of any given length
+

misc binary helpers

+ + + + + +
fround (number)"returns nearest 32-bit single precision float representation of a number" (or something)
+

expected function inputs

+ + + + + + + + + +
read_byte ()read_byte is a param name which refers to a function which reads the next byte- returning a whole number between 0-255.
write_byte ()write_byte is similar to read_byte, however it is given an input and expected to write it to the file.
+ +
+
+ + +

reading binary inputs

+ +
+ read a binary inputs using a read_byte function. +
+
+
+ + read_single (function) +
+
+ read an IEEE 754 single precision (32-bit) floating point number + + +

Parameters:

+ + + + + + +
+
+ + read_double (function) +
+
+ read an IEEE 754 double-precision (64-bit) floating point number + + +

Parameters:

+ + + + + + +
+
+ + read_uint (function, int) +
+
+ read an unsigned integer of any given length + + +

Parameters:

+
    +
  • function + read_byte +
  • +
  • int + length in bytes of unsigned integer +
  • +
+ + + + + +
+
+ + read_uint (function, int) +
+
+ read a signed integer of any given length + + +

Parameters:

+
    +
  • function + read_byte +
  • +
  • int + length in bytes of integer +
  • +
+ + + + + +
+
+

misc binary helpers

+ +
+
+ + fround (number) +
+
+ "returns nearest 32-bit single precision float representation of a number" (or something) + + +

Parameters:

+
    +
  • number + + + +
  • +
+ +

Returns:

+
    + + nearest 32-bit single precision float representation of a number +
+ + + + +
+
+

expected function inputs

+ +
+ functions will expect either a read_byte or write_byte function as inputs +
+
+
+ + read_byte () +
+
+ +

read_byte is a param name which refers to a function which reads the next byte- returning a whole number between 0-255.

+ +
function byte()
+    left = left - 1
+    return assert(file_handle:read(1):byte())
+    --reads the next chracter, and converts it to a "numerical code" using string.byte()
+    --it's important that this function moves forward in the file stream (as :read(1) does)
+end
+
+ + + + +

Returns:

+
    + + a bytecode (an int between 0 and 255.) +
+ + + + +
+
+ + write_byte () +
+
+ write_byte is similar to read_byte, however it is given an input and expected to write it to the file. + (example needed) + + + + + + + +
+
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-01-08 19:24:47 +
+
+ + diff --git a/docs/modules/paths.html b/docs/modules/paths.html new file mode 100644 index 0000000..35a0a7d --- /dev/null +++ b/docs/modules/paths.html @@ -0,0 +1,185 @@ + + + + + MTUL core + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module paths

+

mod utilities +find the paths + find mod information

+

+ +

+ + +

Tables

+ + + + + + + + + + + + + + + + + +
media_pathspaths of loaded media.
modname_by_mediamodname by media.
overriden_media_pathsoverriden media paths.
overriden_media_pathsmods with overriden media (indexed by media).
+ +
+
+ + +

Tables

+ +
+
+ + media_paths +
+
+ paths of loaded media. + a list of filepaths of loaded media, i.e:

+
{
+    ["model.b3d"] = "C:/path/minetest/mods/mod2/models/model.b3d"
+    ["img.png"] = "C:/path/minetest/mods/mod2/textures/img.png"
+}
+
+

NOTE: "loaded" meaning the final mediapath- what the client loads. + + + + + + + +

+
+ + modname_by_media +
+
+ +

modname by media. + a list of mods by indexed by the name of loaded media

+
{
+    ["model.b3d"] = "mod2"
+}
+
+ + + + + + + + +
+
+ + overriden_media_paths +
+
+ +

overriden media paths. + a list of media paths that were overriden by conflicting model names- the unloaded media, i.e:

+
{
+    ["model.b3d"] = {
+        "C:/path/minetest/mods/mod1/models/model.b3d"
+    }
+}
+
+ + + + + + + + +
+
+ + overriden_media_paths +
+
+ +

mods with overriden media (indexed by media). + a list of mods that have overriden media, by media names

+
{
+    ["model.b3d"] = {
+        "mod1",
+    }
+}
+
+ + + + + + + + +
+
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2024-01-08 19:24:47 +
+
+ + diff --git a/init.lua b/init.lua index 3e0f50c..d0db2b9 100644 --- a/init.lua +++ b/init.lua @@ -4,15 +4,10 @@ mtul = mtul or { --initialize namespace vars if not present. mtul.binary = mtul.binary or {} mtul.utils = mtul.utils or {} +mtul.paths = mtul.paths or {} mtul.loaded_modules.filesystem = true ---optionally allow user to overset local math with mtul while still keeping core funcs & consts. -mtul.math = {} -for i, v in pairs(math) do - mtul.math[i] = v -end - --run files. These will directly modify the mtul sub tables. -mtul.path = minetest.get_modpath("mtul_filesystem") -dofile(mtul.path.."/modlib/binary.lua") -dofile(mtul.path.."/modlib/mod_utils.lua") -dofile(mtul.path.."/modlib/mod_utils_media.lua") +local path = minetest.get_modpath("mtul_filesystem") +dofile(path.."/modlib/binary.lua") +dofile(path.."/modlib/mod_utils.lua") +dofile(path.."/modlib/paths.lua") diff --git a/modlib/mod_utils_media.lua b/modlib/paths.lua similarity index 55% rename from modlib/mod_utils_media.lua rename to modlib/paths.lua index 040977e..bf52a21 100644 --- a/modlib/mod_utils_media.lua +++ b/modlib/paths.lua @@ -1,5 +1,10 @@ --felt this was big enough that it practically deserved it's own file. -- TODO support for server texture packs (and possibly client TPs in singleplayer?) + +--- mod utilities +--find the paths +--- find mod information +-- @module paths local media_foldernames = {"textures", "sounds", "media", "models", "locale"} local media_extensions = { -- Textures @@ -7,14 +12,14 @@ local media_extensions = { -- Sounds "ogg"; -- Models - "x", "b3d", "md2", "obj"; + "x", "b3d", "md2", "obj", "gltf"; -- Translations "tr"; } local function split_extension(filename) return filename:match"^(.*)%.(.*)$" end ---mmmm yes, according to modlib we should make this loop it's own global function apart of modlib. Foolish me thinking we can just make case specific +--make it a set. for i, v in pairs(media_extensions) do media_extensions[v] = true end @@ -47,21 +52,55 @@ end local paths = {} local mods = {} local overridden_paths = {} -local overridden_mods = {} +local mods_with_overriden_media = {} for _, mod in ipairs(mtul.utils.get_mod_load_order()) do local mod_media = collect_media(mod.name) for medianame, path in pairs(mod_media) do if paths[medianame] then overridden_paths[medianame] = overridden_paths[medianame] or {} table.insert(overridden_paths[medianame], paths[medianame]) - overridden_mods[medianame] = overridden_mods[medianame] or {} - table.insert(overridden_mods[medianame], mods[medianame]) + mods_with_overriden_media[medianame] = mods_with_overriden_media[medianame] or {} + table.insert(mods_with_overriden_media[medianame], mods[medianame]) end paths[medianame] = path mods[medianame] = mod.name end end -mtul.media_paths = paths -mtul.overriden_media_paths = paths -mtul.modname_by_media = paths -mtul.overriden_modnames_by_media = paths \ No newline at end of file +--- paths of loaded media. +-- a list of filepaths of loaded media, i.e: +-- { +-- ["model.b3d"] = "C:/path/minetest/mods/mod2/models/model.b3d" +-- ["img.png"] = "C:/path/minetest/mods/mod2/textures/img.png" +-- } +-- NOTE: "loaded" meaning the final mediapath- what the client loads. +-- @table media_paths +mtul.paths.media_paths = paths + +---modname by media. +-- a list of mods by indexed by the name of loaded media +-- { +-- ["model.b3d"] = "mod2" +-- } +-- @table modname_by_media +-- NOTE: "loaded" meaning the final mediapath- what the client loads. +mtul.paths.modname_by_media = mods + +--- overriden media paths. +-- a list of media paths that were overriden by conflicting model names- the unloaded media, i.e: +-- { +-- ["model.b3d"] = { +-- "C:/path/minetest/mods/mod1/models/model.b3d" +-- } +-- } +-- @table overriden_media_paths +mtul.paths.overriden_media_paths = overridden_paths + +--- mods with overriden media (indexed by media). +-- a list of mods that have overriden media, by media names +-- { +-- ["model.b3d"] = { +-- "mod1", +-- } +-- } +-- @table overriden_media_paths +mtul.paths.mods_with_overriden_media = mods_with_overriden_media \ No newline at end of file