Groups

In a number of places, there is a group table. Groups define the properties of a thing (item, node, armor of entity, capabilities of tool) in such a way that the engine and other mods can can interact with the thing without actually knowing what the thing is.

Usage

Groups are stored in a table, having the group names with keys and the group ratings as values. For example:

-- Default dirt
groups = {crumbly=3, soil=1}

-- A more special dirt-kind of thing
groups = {crumbly=2, soil=1, level=2, outerspace=1}

Groups always have a rating associated with them. If there is no useful meaning for a rating for an enabled group, it shall be 1.

When not defined, the rating of a group defaults to 0. Thus when you read groups, you must interpret nil and 0 as the same value, 0.

You can read the rating of a group for an item or a node by using

minetest.get_item_group(itemname, groupname)

Groups of items

Groups of items can define what kind of an item it is (e.g. wool).

Groups of nodes

In addition to the general item things, groups are used to define whether a node is destroyable and how long it takes to destroy by a tool.

Groups of entities

For entities, groups are, as of now, used only for calculating damage. The rating is the percentage of damage caused by tools with this damage group. See [Entity damage mechanism].

object.get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
object.set_armor_groups({fleshy=30, cracky=80})

Groups of tools

Groups in tools define which groups of nodes and entities they are effective towards.

Groups in crafting recipes

An example: Make meat soup from any meat, any water and any bowl:

{
    output = 'food:meat_soup_raw',
    recipe = {
        {'group:meat'},
        {'group:water'},
        {'group:bowl'},
    },
    -- preserve = {'group:bowl'}, -- Not implemented yet (TODO)
}

Another example: Make red wool from white wool and red dye:

{
    type = 'shapeless',
    output = 'wool:red',
    recipe = {'wool:white', 'group:dye,basecolor_red'},
}

Special groups

  • immortal: Skips all damage and breath handling for an object. This group will also hide the integrated HUD status bars for players, and is automatically set to all players when damage is disabled on the server.
  • punch_operable: For entities; disables the regular damage mechanism for players punching it by hand or a non-tool item, so that it can do something else than take damage.
  • level: Can be used to give an additional sense of progression in the game.
    • A larger level will cause e.g. a weapon of a lower level make much less damage, and get worn out much faster, or not be able to get drops from destroyed nodes.
    • 0 is something that is directly accessible at the start of gameplay
    • There is no upper limit
  • dig_immediate: Player can always pick up node without reducing tool wear
    • 2: the node always gets the digging time 0.5 seconds (rail, sign)
    • 3: the node always gets the digging time 0 seconds (torch)
  • disable_jump: Player (and possibly other things) cannot jump from node
  • fall_damage_add_percent: damage speed = speed * (1 + value/100)
  • bouncy: value is bounce speed in percent
  • falling_node: if there is no walkable block under the node it will fall
  • float: the node will not fall through liquids
  • attached_node: if the node under it is not a walkable block the node will be dropped as an item. If the node is wallmounted the wallmounted direction is checked.
  • connect_to_raillike: makes nodes of raillike drawtype with same group value connect to each other
  • slippery: Players and items will slide on the node. Slipperiness rises steadily with slippery value, starting at 1.
  • disable_repair: If set to 1 for a tool, it cannot be repaired using the "toolrepair" crafting recipe

Known damage and digging time defining groups

  • crumbly: dirt, sand
  • cracky: tough but crackable stuff like stone.
  • snappy: something that can be cut using fine tools; e.g. leaves, small plants, wire, sheets of metal
  • choppy: something that can be cut using force; e.g. trees, wooden planks
  • fleshy: Living things like animals and the player. This could imply some blood effects when hitting.
  • explody: Especially prone to explosions
  • oddly_breakable_by_hand: Can be added to nodes that shouldn't logically be breakable by the hand but are. Somewhat similar to dig_immediate, but times are more like {[1]=3.50,[2]=2.00,[3]=0.70} and this does not override the speed of a tool if the tool can dig at a faster speed than this suggests for the hand.

Examples of custom groups

Item groups are often used for defining, well, groups of items.

  • meat: any meat-kind of a thing (rating might define the size or healing ability or be irrelevant -- it is not defined as of yet)
  • eatable: anything that can be eaten. Rating might define HP gain in half hearts.
  • flammable: can be set on fire. Rating might define the intensity of the fire, affecting e.g. the speed of the spreading of an open fire.
  • wool: any wool (any origin, any color)
  • metal: any metal
  • weapon: any weapon
  • heavy: anything considerably heavy

Digging time calculation specifics

Groups such as crumbly, cracky and snappy are used for this purpose. Rating is 1, 2 or 3. A higher rating for such a group implies faster digging time.

The level group is used to limit the toughness of nodes a tool can dig and to scale the digging times / damage to a greater extent.

Please do understand this, otherwise you cannot use the system to it's full potential.

Tools define their properties by a list of parameters for groups. They cannot dig other groups; thus it is important to use a standard bunch of groups to enable interaction with tools.