Module settings
Encapsulates the settings API of minetest and extends it with further
functions.
get (name, default_value, cast_function) |
Gets a value from the configuration as is. |
get_bool (name, default_value) |
Gets a boolean from the configuration. |
get_list (name, default_value) |
Gets a list from the configuration. |
get_number (name, default_value) |
Gets a number from the configuration. |
get_pos2d (name, default_value) |
Gets a pos (with x and y values) from the configuration. |
get_pos3d (name, default_value) |
Gets a pos with (x, y and z values) from the configuration. |
get_string (name, default_value) |
Gets a string from the configuration. |
get_table (name, default_value, ...) |
Gets a table with the given keys form the configuration. |
save () |
Saves all settings to configuration file. |
set (name, value) |
Set a value with the given name into the configuration. |
get_pos |
Gets a pos from the configuration, this is an alias for get_pos3d. |
Functions
-
get (name, default_value, cast_function)
-
Gets a value from the configuration as is.
Parameters:
- name
The name of the value to get.
- default_value
Optional. The default_value to return if the value is
not set in the configuration. Can be nil.
- cast_function
Optional. The function to apply to the value that is
read, for example to convert it into a different type.
If this function returns nil, the default value IS
returned. Can be nil.
Returns:
The value from the configuration with the given name. If the read
value is nil, the default value is returned or nil.
-
get_bool (name, default_value)
-
Gets a boolean from the configuration.
Parameters:
- name
The name of the value to get.
- default_value
Optional. The default value to return if the value is nil.
Can be nil.
Returns:
The boolean with the given name, or the default value if it is nil,
or nil.
-
get_list (name, default_value)
-
Gets a list from the configuration.
Parameters:
- name
The name of the value to get.
- default_value
Optional. The default value to return if the value is
nil. Can be nil.
Returns:
The list with the given name, or the default value if it is nil,
or nil.
-
get_number (name, default_value)
-
Gets a number from the configuration.
Parameters:
- name
The name of the value to get.
- default_value
Optional. The default value to return if the value is nil.
Can be nil.
Returns:
The number with the given name, or the default value if it is nil,
or nil.
-
get_pos2d (name, default_value)
-
Gets a pos (with x and y values) from the configuration.
Parameters:
- name
The name of the value to get.
- default_value
Optional. The default value to return if the value is nil.
Can be nil.
Returns:
The pos with the given name, or the default value if it is nil,
or nil.
-
get_pos3d (name, default_value)
-
Gets a pos with (x, y and z values) from the configuration.
Parameters:
- name
The name of the value to get.
- default_value
Optional. The default value to return if the value is nil.
Can be nil.
Returns:
The pos with the given name, or the default value if it is nil,
or nil.
-
get_string (name, default_value)
-
Gets a string from the configuration.
Parameters:
- name
The name of the value to get.
- default_value
Optional. The default value to return if the value is nil.
Can be nil.
Returns:
The string with the given name, or the default value if it is nil,
or nil.
-
get_table (name, default_value, ...)
-
Gets a table with the given keys form the configuration.
Parameters:
- name
The name of the value to get.
- default_value
The default value to return if the value is nil, can be
nil.
- ...
The name of the keys, or a table with the name and the conversion
function.
Returns:
The table with the given name and the given keys, or the default
value it is nil.
-
save ()
-
Saves all settings to configuration file.
-
set (name, value)
-
Set a value with the given name into the configuration.
Parameters:
- name
The name of the value to set. Is not allowed to contain '="#{}'.
- value
The value.
Fields
-
get_pos
-
Gets a pos from the configuration, this is an alias for get_pos3d.
- name
The name of the value to get.
- default_value
Optional. The default value to return if the value is nil.
Can be nil.