From 43d1f375d18a2fbc547a9b4f23d1354d645856ca Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Fri, 12 Dec 2014 14:49:19 -0500 Subject: Use a settings object for the main settings This unifies the settings APIs. This also unifies the sync and async registration APIs, since the async registration API did not support adding non-functions to the API table. --- doc/lua_api.txt | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'doc/lua_api.txt') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 1550a78be..166cc024a 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -172,8 +172,8 @@ The main Lua script. Running this script should register everything it wants to register. Subsequent execution depends on minetest calling the registered callbacks. -`minetest.setting_get(name)` and `minetest.setting_getbool(name)` can be used -to read custom or existing settings at load time, if necessary. +`minetest.settings` can be used to read custom or existing settings at load +time, if necessary. (See `Settings`) ### `models` Models for entities or meshnodes. @@ -2177,16 +2177,10 @@ Call these functions only at load time! * See `minetest.builtin_auth_handler` in `builtin.lua` for reference ### Setting-related -* `minetest.setting_set(name, value)` - * Setting names can't contain whitespace or any of `="{}#`. - * Setting values can't contain the sequence `\n"""`. - * Setting names starting with "secure." can't be set. -* `minetest.setting_get(name)`: returns string or `nil` -* `minetest.setting_setbool(name, value)` - * See documentation on `setting_set` for restrictions. -* `minetest.setting_getbool(name)`: returns boolean or `nil` -* `minetest.setting_get_pos(name)`: returns position or nil -* `minetest.setting_save()`, returns `nil`, save all settings to config file +* `minetest.settings`: Settings object containing all of the settings from the + main config file (`minetest.conf`). +* `minetest.setting_get_pos(name)`: Loads a setting from the main settings and + parses it as a position (in the format `(1,2,3)`). Returns a position or nil. ### Authentication * `minetest.notify_authentication_modified(name)` @@ -3536,10 +3530,15 @@ It can be created via `Settings(filename)`. * `get(key)`: returns a value * `get_bool(key)`: returns a boolean * `set(key, value)` + * Setting names can't contain whitespace or any of `="{}#`. + * Setting values can't contain the sequence `\n"""`. + * Setting names starting with "secure." can't be set on the main settings object (`minetest.settings`). +* `set_bool(key, value)` + * See documentation for set() above. * `remove(key)`: returns a boolean (`true` for success) * `get_names()`: returns `{key1,...}` * `write()`: returns a boolean (`true` for success) - * write changes to file + * Writes changes to file. * `to_table()`: returns `{[key1]=value1,...}` Mapgen objects -- cgit v1.2.3