Nodes

Manipulate and get information’s about nodes.

Nodes are defined as dicts in the form

>>> {'param1': 15, 'name': 'air', 'param2': 0, 'x': -158.67400138786, 'y': 3.5000000521541, 'z': -16.144999935403}

The keys “param1” and “param2” are optional storage variables.

class miney.Nodes(mt: miney.minetest.Minetest)[source]

Manipulate and get information’s about node.

Nodes manipulation is currently tested for up to 25.000 node, more optimization will come later

get(point: Union[miney.point.Point, miney.node.Node, Iterable]) → Union[miney.node.Node, list][source]

Get the node at given position. It returns a node object. This contains the “x”, “y”, “z”, “param1”, “param2” and “name” attributes, where “name” is the node type like “default:dirt”.

If instead of a single point/node a list or tuple with 2 points/nodes is given, this function returns a list of nodes. This list contains a cuboid of nodes with the diagonal between the given points.

Tip: You can get a list of all available node types with type.

Parameters

point – A Point object

Returns

The node type on this position

property name

In Minetest, the type of the node, something like “dirt”, is the “name” of this node.

This property returns all available node names in the game, sorted by categories. In the end it just returns the corresponding minetest name string, so mt.node.types.default.dirt returns the string ‘default:dirt’. It’s only a nice shortcut in REPL, cause with auto completion you have only pressed 2-4 keys to get to your type.

Examples

Directly access a type:

>>> mt.node.name.default.dirt
'default:dirt'

Iterate over all available types:

>>> for node_type in mt.node.name:
>>>     print(node_type)
default:pine_tree
default:dry_grass_5
farming:desert_sand_soil
... (there should be over 400 different types)
>>> print(len(mt.node.name))
421

Get a list of all types:

>>> list(mt.node.name)
['default:pine_tree', 'default:dry_grass_5', 'farming:desert_sand_soil', ...

Add 99 dirt to player “IloveDirt“‘s inventory:

>>> mt.player.IloveDirt.inventory.add(mt.node.name.default.dirt, 99)
Return type

NameIterable

Returns

TypeIterable object with categories. Look at the examples above for usage.

set(node: Union[miney.node.Node, list])None[source]

Set a single or multiple nodes at given position to another node type (something like mt.nodes.type.default.apple). You can get a list of all available node types with type

The nodes parameter can be a single Node object or a list of Node objects for bulk spawning.

Examples

Replace the node under the first players feet with dirt:

>>> from miney import Node
>>> pos = Node(mt.player[0].position.x, mt.player[0].position.y - 1, mt.player[0].position.z, "default:dirt")
>>> mt.nodes.set(mt.player[0].position)
Parameters

node – A dict or a list of dicts with node definitions