[Mod] LuaConfig [luaconfig]
Note: This thread contains only a brief description and release announcements. For more details, see the wiki page: http://wiki.minetest.net/Mods/LuaConfig
This mod makes it really, really easy for other mods to load Lua-based configuration settings. It's as simple as adding "luaconfig" to your mod's depends.txt and putting this at the top of your init.lua:
and then optionally (to make settings globally visible):
This automatically detects the name and path of your mod and loads settings from "config.lua" in your mod directory and/or "mymod_config.lua" in the world directory, allowing the latter to add to or overwrite the former. No errors will be generated if either or both files are missing.
This mod allows simple Lua variable-based configuration settings that almost guarantee that you don't accidentally set global variables from the config files (you can if you REALLY try, but it's difficult). You'll have access to all variables defined from the config files using logic like:
Mod Details
Require Minetest Version: (probably any; tested in 0.4.12)
Dependencies: (none)
Soft Dependencies: (none)
Craft Recipes: (none)
API:
Git Repo: https://github.com/prestidigitator/minetest-mod-luaconfig
Copyright and Licensing
Author: Prestidigitator
License: WTFPL
Change History
Version 1.0
This mod makes it really, really easy for other mods to load Lua-based configuration settings. It's as simple as adding "luaconfig" to your mod's depends.txt and putting this at the top of your init.lua:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local config = luaconfig.loadConfig();
and then optionally (to make settings globally visible):
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
mymod = { config = config };
This automatically detects the name and path of your mod and loads settings from "config.lua" in your mod directory and/or "mymod_config.lua" in the world directory, allowing the latter to add to or overwrite the former. No errors will be generated if either or both files are missing.
This mod allows simple Lua variable-based configuration settings that almost guarantee that you don't accidentally set global variables from the config files (you can if you REALLY try, but it's difficult). You'll have access to all variables defined from the config files using logic like:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
print(config.message);
Mod Details
Require Minetest Version: (probably any; tested in 0.4.12)
Dependencies: (none)
Soft Dependencies: (none)
Craft Recipes: (none)
API:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
luaconfig.loadConfig([modName, [configTable]])
Git Repo: https://github.com/prestidigitator/minetest-mod-luaconfig
Copyright and Licensing
Author: Prestidigitator
License: WTFPL
Change History
Version 1.0
- Released 2015-05-03
- First working version.