[Mod] mod utilities [modutil]

Post Reply
User avatar
theFox
Member
Posts: 185
Joined: Sun Feb 12, 2017 14:08
GitHub: theFox6
In-game: theFox
Location: Germany

[Mod] mod utilities [modutil]

by theFox » Post

A mod containing utilities I often use. The modules are be loaded on demand if another mod uses one of the components.
license: MIT
no dependencies
code: https://github.com/theFox6/modutil
download: https://github.com/theFox6/modutil/archive/master.zip

features
for a full list of features look at the README

log
A module for creating shorter logging functions.
The loggers will format the given log message and call minetest.log.
Typically you want to use it as following:

Code: Select all

my_mod.log = modutil.require("log").make_loggers()
my_mod.log.action("loggers loaded")
You can also pass the level of the loggers to the make_loggers function:

Code: Select all

my_mod.log = modutil.require("log").make_loggers("action","warning","error","debug")
If you create your logger after loading the mod you may want to pass the modname using:

Code: Select all

my_mod.log.info = modutil.require("log").make_logger("info","my_mod")
translations
A wrapper that checks if minetest.get_translator is avalible and replaces it if nessecary.
The module returns a fucntion that when called returns the translator. use:

Code: Select all

my_mod.S = modutil.require("translations")()
-- or for after loading
my_mod.S = modutil.require("translations")("my_mod")
check_prefix
A function doing the same as the standard minetest prefix check. It will assume the modname is correct if it called after loading. use:

Code: Select all

local check_prefix = modutil.require("check_prefix")
-- checks if name is in the format "modname:name" or ":modname:name"
-- if modname in "modname:name" is not the currently loaded mod it creates an error
-- returns id in the format "modname:name"
local id = check_prefix(name)
Feel free to suggest more utilities.
Last edited by theFox on Fri Sep 27, 2019 06:31, edited 3 times in total.
my mods and subgames (ง'̀-'́)ง

User avatar
Sokomine
Member
Posts: 4045
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: [Mod] mod utilities [modutil]

by Sokomine » Post

Can you describe what the mod is about and what it does? Hiding all behind spoilers isn't a good idea. I don't use JavaScript often. Thus, the spoiler cannot be unfolded. It's also documented on Github, and that at least is readable. But it'd be a lot nicer if the thread on the forum could be read as well.
A list of my mods can be found here.

User avatar
theFox
Member
Posts: 185
Joined: Sun Feb 12, 2017 14:08
GitHub: theFox6
In-game: theFox
Location: Germany

Re: [Mod] mod utilities [modutil]

by theFox » Post

Sokomine wrote:Hiding all behind spoilers isn't a good idea. I don't use JavaScript often. Thus, the spoiler cannot be unfolded. It's also documented on Github, and that at least is readable. But it'd be a lot nicer if the thread on the forum could be read as well.
Well I've removed the spoiler now. Sorry for the trouble, just thought it'd be better to keep the topic post short...
my mods and subgames (ง'̀-'́)ง

User avatar
Linuxdirk
Member
Posts: 2539
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] mod utilities [modutil]

by Linuxdirk » Post

I once was a fan of “utility mods” but I soon realized that no-one except the author uses them and that they serve no other purpose than outsourcing the code from one of the authors mods into another.

User avatar
theFox
Member
Posts: 185
Joined: Sun Feb 12, 2017 14:08
GitHub: theFox6
In-game: theFox
Location: Germany

Re: [Mod] mod utilities [modutil]

by theFox » Post

Linuxdirk wrote:that they serve no other purpose than outsourcing the code from one of the authors mods into another.
Exactly right, but I'd be happy to add new utilities if you need anything.
my mods and subgames (ง'̀-'́)ง

User avatar
theFox
Member
Posts: 185
Joined: Sun Feb 12, 2017 14:08
GitHub: theFox6
In-game: theFox
Location: Germany

Re: [Mod] mod utilities [modutil]

by theFox » Post

Hey everyone,
I have added my VenusParser.
If you are annoyed by "then" and "end" statements this is just the thing for you.
Check out the syntax of venus files in the parser's readme.

Also there have been braking changes:
The module "log" was renamed to "logging".
Some mods may have problems with their log if you update modutil.
If you get errors that say a mod tries to index some fields like "info", "action", "warning" etc.
you may want to update those mods too.
my mods and subgames (ง'̀-'́)ง

Post Reply

Who is online

Users browsing this forum: anju64, Bing [Bot] and 4 guests