[Mod] mod utilities [modutil]

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

[Mod] mod utilities [modutil]

by theFox » Sat Jun 08, 2019 11:47

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

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 Wed Jun 19, 2019 13:35, edited 2 times in total.
my mods and subgames (ง'̀-'́)ง
 

Sokomine
Member
 
Posts: 3827
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: [Mod] mod utilities [modutil]

by Sokomine » Sun Jun 16, 2019 13:54

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: 173
Joined: Sun Feb 12, 2017 14:08
Location: Germany
GitHub: theFox6
In-game: theFox

Re: [Mod] mod utilities [modutil]

by theFox » Sun Jun 16, 2019 15:25

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: 2061
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

Re: [Mod] mod utilities [modutil]

by Linuxdirk » Sun Jun 16, 2019 16:23

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: 173
Joined: Sun Feb 12, 2017 14:08
Location: Germany
GitHub: theFox6
In-game: theFox

Re: [Mod] mod utilities [modutil]

by theFox » Wed Jun 19, 2019 13:34

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 (ง'̀-'́)ง
 


Return to WIP Mods



Who is online

Users browsing this forum: mtf and 4 guests