anchor.storage
contains the node database of anchors. It is a table with coordinates in minetest.pos_to_string
format as the keys and another table as the values. The structure of the values are descripted below:
uuid
(String): The unique identifier of the anchor, in the format"(<x>,<y>,<z>)<os.time()>"
.name
(String): The title of the anchor.subtitle
(String, optional): Short descriptiondescription
(String): The long description of the anchor.
Sync a anchor's data to the node database. pos
should be a valid position of a anchor, and meta
should be the metadata of the anchor. If meta
is absent, the mod will try to get one from the pos
provided.
Write a anchor's data to both node metadata and node database. pos
should be a valid position of a anchor, and data
should be a key-value pair in the anchor.storage
value format, with the following exceptions:
uuid
(String or Boolean): Iftrue
, a new one will always be generated. If string, the string will be the new UUID. If no uuid is detected from the anchor's metadata, and no string is passed, a new one will be generated.
Return a anchor's data in the anchor.storage
value format by reading the given anchor's metadata.
Anchor mod uses up two field in player metadata: anchor_list
and anchor_list_alt
. Unless otherwise specified, in this section, player
means a player ObjectRef.
Get a list of valid anchors unlocked by the player. Not that this function will automatically remove all invalid anchors from player's list.
Remove all anchors from the player's list. The player then have to re-unlock all the anchors one-by-one in order to use them
Add an anchor into the player's list. item
should be a coordinate table with a extra optional uuid
field. If duplications is detected, false
is returned, otherwise true
.
Remove an anchor from the player's list. The syntax is the same as above.
Register an anchor. def
should be a node defination table, with the following fields modified by anchor mod:
on_rightclick
: To handle anchor edit formspec and unlock.can_dig
: To disallow non-admins to dig the anchor.on_construct
: To set up inital metadata of the node.on_destruct
: To remove the anchor from the node database.groups.anchor
: Always set to1
to add all anchors togroup:anchor
.
Unless otherwise specified, all objects within anchor.gui
are flow.make_gui
returned values. Please refer to README.md of that mod for full usage of the following objects.
The formspec used to set up new anchors. When calling :show(player,ctx)
, ctx
should be a table with a field pos
containing the coordinate of the target anchor.
The formspec used to modify existing anchors. When calling :show(player,ctx)
, ctx
should be a table with a field pos
containing the coordinate of the target anchor.
The formspec used to list anchors a player unlocked.