Configuration Panel Mod v1.1
config (by sorcerykid)
Configuration Panel is an API extension for Minetest that allows seamless loading of mod configuration at runtime. It provides much greater flexibility than Minetest's builtin 'Settings' interface, since the mod configuration itself is read as a native Lua script. Hence it's possible to include simple data structures without the need for serialization, in addition to temporary variables, mathematical expressions, and conditional branching.
- "An important use of Lua is as a configuration language...."
from Programming in Lua: Extending your Application (https://www.lua.org/pil/25.html)
"Lua started off as a configuration language. This has some nice quirks in that it's great for creating and configuring things - which is what you want to do in a game."
from Lua Users Wiki: Lua versus Python (http://lua-users.org/wiki/LuaVersusPython)
Repository:
https://bitbucket.org/sorcerykid/config
Download Archive (.zip)
Download Archive (.tar.gz)
Dependencies:
Default Mod (optional)
ActiveFormspecs Mod (optional)
Installation Instructions:
- Unzip the archive into the mods directory of your game
- Rename the config-master directory to "config"
- Add "config" as a dependency to any mods using the API
The MIT License (MIT)
Overview
There is only one function call necessary to load your mod's configuration:
- minetest.load_config( base_config, options )
Automatically loads the mod configuration at server-startup according to the options and returns a table of key-value pairs.- 'base_config' is the default mod configuration (optional)
- 'options' are the additional options that effect loading behavior (optional)
This would be the typical order of loading on Linux distros of Minetest:
- /usr/local/share/minetest/games/minetest_game/mods/sample_mod/config.lua
- /home/minetest/.minetest/worlds/sample_world/config/sample_mod.lua
Code: Select all
/usr/local/share/minetest/games/minetest_game/mods/sample_mod/config.lua
allow_fly = false
allow_walk = false
allow_swim = false
/home/minetest/.minetest/worlds/sample_world/config/sample_mod.lua
allow_swim = true
For security reasons, configuration scripts are executed within a restricted environment. However, the following builtin functions are made available for convenience:
- core.print
- core.debug (alias for minetest.log)
- core.is_yes (alias for minetest.is_yes)
- core.has_feature (alias for minetest.has_feature)
- core.string_to_pos (alias for minetest.string_to_pos)
- core.pos_to_string (alias for minetest.pos_to_string)
- core.colorize (alias for minetest.colorize)
- core.tonumber
- core.tostring
- core.sprintf (alias for string.format)
- core.tolower (alias for string.lower)
- core.toupper (alias for string.upper)
- core.concat (alias for table.concat)
- core.random (alias for math.random)
- core.max (alias for math.max)
- core.min (alias for math.min)
- core.next
- core.pairs
- core.ipairs
- core.date (alias for os.date)
- core.time (alias for os.time)
- core.assert
- core.error
A chat command is also available for editing the configuration directly in-game. Simply type '/config' followed by the mod name to configure. The interface is self-explanatory.
Special Note: Before using the chat command you must add "config" to the list of trusted mods in minetest.conf and you must install the ActiveFormspecs mod, otherwise the editing functionality will be disabled.