Description:
A mod that reads settings from mod.conf.
NOTE: This mod is a work-in-progress but is functional. Currently, in order to use modconf.getModMetaData, key-value instances in mod.conf must be delimited by an equals symbol with one whitespace on both sides (e.g. " = "). In the future, trimming out whitespace will be done automatically.
Usage:
Global Functions:
- modconf.getModMetaData
- Adds fields from mod.conf to a table object.
- Usage: modconf.getModMetaData(object)
- Parameters:
- object: (optional if saving returned value) The object table of which to append fields read from mod.conf file.
- Returns: Table object containing fields read from mod.conf file.
- Aliases:
- core.get_mod_metadata
- minetest.get_mod_metadata
- modconf.getModDefaults
- Reads default settings from local settingtypes.txt file.
- Usage: modconf.getModDefaults(object)
- Parameters:
- object: (optional if saving returned value) The object table of which to append fields read from settingtypes.txt file.
- Returns: Table object containing fields read from settingtypes.txt file.
- Aliases:
- core.get_mod_defaults
- minetest.get_mod_defaults
depends.txt:
Code: Select all
modconf?
Code: Select all
-- Main global object table
mymod = {}
-- Create settings object from core function
if minetest.global_exists('modconf') or minetest.get_modpath('modconf') then
mymod.settings = minetest.get_mod_metadata()
end
mymod.name = mymod.settings:get('name')
mymod.version = mymod.settings:get('version')
minetest.log('action', 'Loading ' .. mymod.name .. ' version ' .. mymod.version)
Code: Select all
-- Main global object table
mymod = {}
-- Read fields into table from 'mod.conf'
if minetest.global_exists('modconf') then
modconf.getModMetaData(mymod)
end
minetest.log('action', 'Loading ' .. mymod.name .. ' version ' .. mymod.version)
Code: Select all
-- Table object to read fields into
local defaults = {}
-- Read fields into table from 'settingtypes.txt'
if minetest.get_modpath('modconf') then
modconf.getModDefaults(defaults)
end
-- Alternatively can be called thus:
local defaults = modconf.getModDefaults()
Links:
Releases: