You may register slopes in two ways: letting the mod generating all the stuff or getting the definitions and registering the nodes in the calling mod. With the first method, slope nodes will be registered within naturalslopeslib while with the second method, you can set the slope names from the calling mod. In both cases, the shape update behaviour is handled automatically by the library according to the settings and the availability of poschangelib and twmlib.
For the first method, just call naturalslopeslib.register_slopes.
For the first method, just call naturalslopeslib.register_slopes. For example:
For example:
naturalslopeslib.register_slopes("default:dirt")
naturalslopeslib.register_slopes("default:dirt")
You can use naturalslopeslib.get_all_shapes to get the name of the slope nodes.
You can use `naturalslopeslib.get_all_shapes` to get the name of the slope nodes.
For the second method, get the slope definitions from naturalslopeslib.get_slope_defs and register the four nodes manually with the desired names with minetest.register_node. When done, call naturalslopeslib.set_slopes to link all the different shapes.
For example:
local slope_defs = naturalslopeslib.get_slope_defs("defaut:dirt")
local slope_names = {"default:dirt_slope", "default:dirt_inner_corner", "default:dirt_outer_corner", "default:dirt_pike"}
Regarding dependencies, the slopes are defined by copying the current definition of the original node. This means that modifications applied to the original node after the slopes are registered are not applied to slopes. If you want the slopes to act like the original nodes no matter what happen to their definition, you can call naturalslopes.propagate_overrides() before or after registering slopes. That way all future call to minetest.override_item (even from other unknown mods) will also apply to slopes silently, removing the need to explicitely define mod requirements.
@ -86,23 +91,63 @@ Definitions
### ReplacementTable
A table containing references to various shape. The type of references can either be a name or an internal id.
{
source = full node reference,
straight = straight slope reference,
inner = inner corner reference,
outer = outer corner reference,
pike = pike/slab reference,
chance = inverted chance of happening,
chance_factors = multiplicator for `chance` for each type {mapgen = w, stomp = x, time = y, place = z}. By default all of these factors are 1 (no effect).
}
{
source = full node reference,
straight = straight slope reference,
inner = inner corner reference,
outer = outer corner reference,
pike = pike/slab reference,
chance = inverted chance of happening,
chance_factors = multiplicator for `chance` for each type
{mapgen = w, stomp = x, time = y, place = z}.
By default all of these factors are 1 (no effect).
This tables holds default definition override for newly registered slopes. When using register_slope, they are added to def_changes if not already set to avoid copy/pasting a lot of things and automate some behaviours.
{
drop_source = true/false
-- When true, if no drop is defined, it is set to the source node
-- instead of the slope.
-- For example, digging a dirt slope gives a dirt block (when true)
-- or the dirt slope (when false)
tiles = {{align_style="world"}}
-- As for tile definitions, the list can hold up to 6 values,
-- but only align_style, backface_culling and scale are read.
groups = {not_in_creative_inventory = 1}
-- The list of groups to add with their value.
-- Set a group value to 0 to remove it
other keys
-- Override this key when no change is explicitely set.
}
Note that changes to default_definitions are not retroactives. If the defaults are changed on the run, all slopes that were previously registered are not affected.
Good practices are setting the defaults before registering your slopes, then calling naturalslopeslib.reset_defaults() to prevent your settings to effect further declarations.
### naturalslopeslib.reset_defaults()
Resets `naturalslopeslib.default_definition` to the less-impacting values.
Registers all slope shapes and automatic stomping for a full node.
* Registers all slope shapes and automatic stomping for a full node.
* `base_node_name` the full block node name.
* `def_changes` changes to apply from the base node definition.
* All the attributes are copied to the sloped nodes expect those ones which are replaced:
@ -110,14 +155,15 @@ Registration API
* `nodebox` or `mesh` is replaced
* `selection_box` and `collision_box` matching to the according mesh
* `paramtype` is set to "light", and `paramtype2` to "facedir" or "colorfacedir"
* the group "natural_slope" is added (1 = straight, 2 = inner corner, 3 = outer corner, 4 = pike)
* the group "family:<full node name>" is added
* Then they are changed from def_changes. Use "nil" string to explicitely erase a value (an not nil).
* the group `"natural_slope"` is added (1 = straight, 2 = inner corner, 3 = outer corner, 4 = pike)
* the group `"family:<full node name>"` is added
* Then they are changed from def_changes. Use `"nil"` string to explicitely erase a value (an not `nil`).
* `update_chance` inverted chance for the node to be updated.
* `factors` optional table for chance factors. By default each factor is 1.
* `color_convert` optional function to convert color palettes (see below). Ignored when paramtype2 from the base node is not `"color"`. By default, it matches the first 8 values, and other color values are set to 0.
* returns ReplacementTable.
Warning: The palette for slopes can only have 8 colors while the original one can hold up to 256 colors. A reduced palette must be provided for nodes which paramtype2 is "color" even if not all colors are used.
About color palettes: The palette for slopes can only have 8 colors while the original one can hold up to 256 colors. A reduced palette must be provided for nodes which paramtype2 is "color" even if not all colors are used. To control how the palette values are converted, you may pass a function(int, bool) as `color_convert`. When the second parameter is true, the first parameter is the full block color index (from 0 to 255) and it must return an index for the slope color (from 0 to 7). When false the first parameter is the slope color index (from 0 to 7) and it must return an index for the full block color index (from 0 to 255).
* Requires `poschangelib`. If the mod is not installed, this function will do nothing.
* Register `stomp_desc` from all shapes of `source_node_name` to `dest_node_name`.
Register `stomp_desc` from all shapes of `source_node_name` to `dest_node_name`.
It requires `poschangelib`. If the mod is not activated, this function will do nothing.
### naturalslopeslib.propagate_overrides()
* Once called, calling minetest.override_item from that point will also apply the modifications to the corresponding slopes. Once called, this behaviour cannot be disabled.
Once called, calling `minetest.override_item` from that point will also apply the modifications to the corresponding slopes. Once called, this behaviour cannot be disabled.
Getters
@ -155,10 +202,10 @@ Getters
* `paramtype` is set to "light", and `paramtype2` to "facedir" or "colorfacedir"
* the group "natural_slope" is added (1 = straight, 2 = inner corner, 3 = outer corner, 4 = pike)
* the group "family:<full node name>" is added
* Then they are changed from def_changes. Use "nil" string to explicitely erase a value (an not nil).
* Then they are changed from `def_changes`. Use `"nil"` string to explicitely erase a value (an not `nil`).
* returns a table of node definitions for straight slope, inner corner, outer corner and pike in that order.
Warning: The palette for slopes can only have 8 colors while the original one can hold up to 256 colors. A reduced palette must be provided for nodes which paramtype2 is "color" even if not all colors are used.
Warning: The palette for slopes can only have 8 colors while the original one can hold up to 256 colors. A reduced palette must be provided for nodes which paramtype2 is `"color"` even if not all colors are used.
Returns the node and all it's slope names in a table {source, straight, inner corner, outer corner, pike}. Returns {source} if there are no slopes for this node.
* Callback for poschangelib, to get the same effect as naturalslopeslib.update_shape.
Callback for poschangelib, to get the same effect as naturalslopeslib.update_shape.
Map generation
@ -245,14 +300,12 @@ Which is updating an area on generation after other map generation functions.
### naturalslopeslib.set_manual_map_generation()
* Disables the default registration to handle the mapgen manually.
* Once it is called, other mods should take care of handling shape update
on generation. Otherwise nothing is done.
Disables the default registration to handle the mapgen manually. Once it is called, other mods should take care of handling shape update on generation. Otherwise nothing is done.
* Returns true or false. It may not reflect the actual behaviour if the default mapgen behaviour was disabled by naturalslopeslib.set_manual_map_generation.
* Returns `true` or `false`. It may not reflect the actual behaviour if the default mapgen behaviour was disabled by naturalslopeslib.set_manual_map_generation.
### naturalslopeslib.setting_generation_method()
* Returns "VoxelManip" or "Progressive". It may not reflect the actual behaviour if the default mapgen behaviour was disabled by naturalslopeslib.set_manual_map_generation.
* Returns `"VoxelManip"` or `"Progressive"`. It may not reflect the actual behaviour if the default mapgen behaviour was disabled by naturalslopeslib.set_manual_map_generation.
### naturalslopeslib.setting_generation_factor()
* Returns the chance factor for map generation to reflect the landscape age. It is cumulative with the "mapgen" chance factor of each node if any is defined. It may not reflect the actual behaviour if the default mapgen behaviour was disabled by naturalslopeslib.set_manual_map_generation.
* Returns the chance factor for map generation to reflect the landscape age. It is cumulative with the `"mapgen"` chance factor of each node if any is defined. It may not reflect the actual behaviour if the default mapgen behaviour was disabled by naturalslopeslib.set_manual_map_generation.
### naturalslopeslib.setting_stomp_factor()
* Returns the chace factor when walking on nodes. It is cumulative with the "stomp" chance factor of each node if any is defined.
* Returns the chace factor when walking on nodes. It is cumulative with the `"stomp"` chance factor of each node if any is defined.
* This factor is applied upon node registration.
### naturalslopeslib.setting_dig_place_factor()
* Returns the chace factor when the neighbouring nodes change. It is cumulative with the "place" chance factor of each node if any is defined.
* Returns the chace factor when the neighbouring nodes change. It is cumulative with the `"place"` chance factor of each node if any is defined.
### naturalslopeslib.setting_time_factor()
* Returns the chace factor on timed update. It is cumulative with the "time" chance factor of each node if any is defined.
* Returns the chace factor on timed update. It is cumulative with the `"time"` chance factor of each node if any is defined.
* This factor is applied upon node registration.
### naturalslopeslib.setting_generation_skip()
@ -315,17 +368,17 @@ These functions get the current settings with the default value if not set.
* Returns true or false. This setting is read only on startup and may not reflect the actual value if it was changed while the server is running.
* Returns `true` or `false`. This setting is read only on startup and may not reflect the actual value if it was changed while the server is running.
### naturalslopeslib.setting_smooth_rendering()
* Returns true or false. This setting is read only when registering nodes and may not reflect the actual value if it was changed while the server is running.
* Returns `true` or `false`. This setting is read only when registering nodes and may not reflect the actual value if it was changed while the server is running.
Chat commands
-------------
### updshape
### /updshape
* requires `server` privilege.
* Force updating the node the player is standing upon.