[Mod] Modding Library [modlib]

Post Reply
User avatar
LMD
Member
Posts: 1397
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

[Mod] Modding Library [modlib]

by LMD » Post

Modding Library (modlib)

Multipurpose Minetest Modding Library

About

No dependencies. Licensed under the MIT License. Written by Lars Mueller aka LMD or appguru(eu).

API

Mostly self-documenting code. Mod namespace is modlib or _ml, containing all variables & functions.

Configuration


Legacy
  1. Configuration is loaded from /config/., the following extensions are supported and loaded (in the given order), with loaded configurations overriding properties of previous ones:
    1. json
    2. lua
    3. luon, Lua but without the return
    4. conf
  2. Settings are loaded from minetest.conf and override configuration values
Locations
  1. Default configuration: /conf.lua
  2. World configuration: config/.
  3. Mod configuration: /conf.
  4. Minetest configuration: minetest.conf
Formats
  1. lua
  2. Lua, with the environment being the configuration object
  3. field = value works
  4. Return new configuration object to replace
  5. luon
  6. Single Lua literal
  7. Booleans, numbers, strings and tables
  8. conf
  9. Minetest-like configuration files
  10. json
  11. Not recommended
Last edited by LMD on Mon Dec 28, 2020 17:33, edited 2 times in total.
My stuff: Projects - Mods - Website

Yeti
Member
Posts: 20
Joined: Fri May 01, 2020 10:27

Re: [Mod] Modding Library [modlib]

by Yeti » Post

Latest update breaks the Advanced Weapons mod.

I had to rollback to the previous version to start the server.

User avatar
LMD
Member
Posts: 1397
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Modding Library [modlib]

by LMD » Post

Yeti wrote:
Mon Aug 17, 2020 01:38
Latest update breaks the Advanced Weapons mod.

I had to rollback to the previous version to start the server.
You are right, the last update does in fact break that mod. I have updated all my mods (at least on GitHub) except for adv_weapons (big update upcoming, the current version contains a handful of bugs and tons of missing features). This release is going to be huge (4k lines and counting) so it's taking some time.
My stuff: Projects - Mods - Website

Yeti
Member
Posts: 20
Joined: Fri May 01, 2020 10:27

Re: [Mod] Modding Library [modlib]

by Yeti » Post

Sounds interesting.

Any chance that things like the gatling gun can be used on monsters and not just on other players. I've played around with a detector grid around my factory and automated weapons would just be the bees knees.

Either way, I'm looking forward to what you've come up with.

Cheers and good luck with it

User avatar
Wuzzy
Member
Posts: 4803
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] Modding Library [modlib]

by Wuzzy » Post

Where's the mod?

User avatar
LMD
Member
Posts: 1397
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Modding Library [modlib]

by LMD » Post

Wuzzy wrote:
Sat Aug 22, 2020 17:03
Where's the mod?
On CDB & GitHub - will update the readme to include the links.
My stuff: Projects - Mods - Website

mase
Member
Posts: 91
Joined: Tue Feb 21, 2017 20:16
In-game: mase

Re: [Mod] Modding Library [modlib]

by mase » Post

Modlib causes the luacontroller overheating with the simple interrupt example code from the mesecons site:
https://mesecons.net/luacontroller

User avatar
LMD
Member
Posts: 1397
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Modding Library [modlib]

by LMD » Post

mase wrote:
Sat Dec 26, 2020 21:43
Modlib causes the luacontroller overheating with the simple interrupt example code from the mesecons site:
https://mesecons.net/luacontroller
The example with the "worst" (shortest) interrupt I see there is

Code: Select all

interrupt(0.5, "a parameter")
print(event.iid) 
Using which I can not reproduce that bug - the luacontroller doesn't overheat. Modlib should hardly affect performance or interfere with mesecons by it's very nature.

You could try upgrading modlib.
My stuff: Projects - Mods - Website

mase
Member
Posts: 91
Joined: Tue Feb 21, 2017 20:16
In-game: mase

Re: [Mod] Modding Library [modlib]

by mase » Post

I already use the master branch of modlib.

0siribix
Member
Posts: 123
Joined: Tue Nov 17, 2020 20:54
GitHub: 0siribix
In-game: 0siribix

Re: [Mod] Modding Library [modlib]

by 0siribix » Post

I get an error on game start[codeModError: Failed to load and run script from ~/.minetest/mods/modlib/init.lua:
Setting [mgv7_np_dungeons] is a group.
stack traceback:
[C]: in function 'to_table'
~/.minetest/mods/modlib/conf.lua:17: in function 'build_setting_tree'
~/.minetest/mods/modlib/init.lua:86: in main chunk
Check debug.txt for details.[/code]
Posted on the github tracker. Maybe it's because I changed some mapgen settings?

Edit: Confirmed that if I return noise settings to default, game loads without issue

User avatar
LMD
Member
Posts: 1397
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Modding Library [modlib]

by LMD » Post

0siribix wrote:
Mon Jan 18, 2021 14:13
I get an error on game start[codeModError: Failed to load and run script from ~/.minetest/mods/modlib/init.lua:
Setting [mgv7_np_dungeons] is a group.
stack traceback:
[C]: in function 'to_table'
~/.minetest/mods/modlib/conf.lua:17: in function 'build_setting_tree'
~/.minetest/mods/modlib/init.lua:86: in main chunk
Check debug.txt for details.[/code]
Posted on the github tracker. Maybe it's because I changed some mapgen settings?

Edit: Confirmed that if I return noise settings to default, game loads without issue
This is an issue with minetest.settings:to_table(). Please report it at the engine bugtracker.
My stuff: Projects - Mods - Website

0siribix
Member
Posts: 123
Joined: Tue Nov 17, 2020 20:54
GitHub: 0siribix
In-game: 0siribix

Re: [Mod] Modding Library [modlib]

by 0siribix » Post

will do

User avatar
LMD
Member
Posts: 1397
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Modding Library [modlib]

by LMD » Post

mase wrote:
Sat Dec 26, 2020 21:43
Modlib causes the luacontroller overheating with the simple interrupt example code from the mesecons site:
https://mesecons.net/luacontroller
This has finally been fixed by luk3yx. You can get the newest releast (tag: rolling-73) from GitHub.
My stuff: Projects - Mods - Website

User avatar
Extex
Member
Posts: 245
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

Re: [Mod] Modding Library [modlib]

by Extex » Post

I can't seem to get modlib.minetest.decode_png to work.

Code adapted from modlib_test

Code: Select all

local path = modlib.mod.get_resource("drawmap", "maps")
for _, filename in pairs(minetest.get_dir_list(path, false)) do
    if modlib.text.ends_with(filename, ".png") then
        local file = io.open(path .. "/" .. filename, "r")
        local png = modlib.minetest.decode_png(file)
        file:close()
    end
end
Here's the bug I'm getting:
Spoiler

Code: Select all

...minetest-5.8.0-win64\bin\..\mods\modlib\minetest\png.lua:99: assertion failed!
stack traceback:
	[C]: in function 'assert'
	...minetest-5.8.0-win64\bin\..\mods\modlib\minetest\png.lua:99: in function 'read'
	...minetest-5.8.0-win64\bin\..\mods\modlib\minetest\png.lua:124: in function 'decode_png'
	...esktop\minetest-5.8.0-win64\bin\..\mods\drawmap\init.lua:13: in function 'reload_files'
	...esktop\minetest-5.8.0-win64\bin\..\mods\drawmap\init.lua:18: in main chunk
Check debug.txt for details.
Creator of jelys_pizzaria and motorbike, and player of persistent kingdoms. RIP

User avatar
LMD
Member
Posts: 1397
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Modding Library [modlib]

by LMD » Post

Extex wrote:
Wed Apr 17, 2024 23:04
I can't seem to get modlib.minetest.decode_png to work. [...]
Here's the bug I'm getting:
Spoiler

Code: Select all

...minetest-5.8.0-win64\bin\..\mods\modlib\minetest\png.lua:99: assertion failed!
stack traceback:
	[C]: in function 'assert'
	...minetest-5.8.0-win64\bin\..\mods\modlib\minetest\png.lua:99: in function 'read'
	...minetest-5.8.0-win64\bin\..\mods\modlib\minetest\png.lua:124: in function 'decode_png'
This assertion is triggered by the file ending prematurely, in this case, before 8 bytes of signature have been read. Are you sure that the file handles you are passing are correct?
My stuff: Projects - Mods - Website

User avatar
Blockhead
Member
Posts: 1688
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: [Mod] Modding Library [modlib]

by Blockhead » Post

Direct source code link - saved others (and possibly my future self) from going to ContentDB or a search engine.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

Post Reply

Who is online

Users browsing this forum: No registered users and 67 guests