Module data

off-world storage for position-dependent data (data in mapblocks, tilenames, etc) indexed in 10^3 groups and saved in the mod-storage

Class DataStorage

mapblock_lib.create_data_storage (storage) create a new world data storage object
mapblock_lib.create_data_link (target_pos) Creates a data link to the target position
mapblock_lib.is_data_link (the) Checks if the data is a link
mapblock_lib.resolve_data_link (storage, pos, max_recursions) Resolves a data link from the storage
DataStorage:get (pos) Returns the data at given position
DataStorage:set (pos, data) Sets the data at given position
DataStorage:merge (pos, data) Merges the data at given position with the existing data
DataStorage:clear () Clears all data from the storage


Class DataStorage

World data storage object
mapblock_lib.create_data_storage (storage)
create a new world data storage object

Parameters:

  • storage the modstorage object from "minetest.getmod_storage()"

Returns:

    DataStorage the storage object
mapblock_lib.create_data_link (target_pos)
Creates a data link to the target position

Parameters:

  • target_pos the position to link to

Returns:

    the link object
mapblock_lib.is_data_link (the)
Checks if the data is a link

Parameters:

  • the data object

Returns:

    true if the data object is a link
mapblock_lib.resolve_data_link (storage, pos, max_recursions)
Resolves a data link from the storage

Parameters:

  • storage the DataStorage object
  • pos the first position to resolve
  • max_recursions [opt] maximum recursion count before aborting (defaults to 10)

Returns:

  1. the resolved data object or nil if none found
  2. the target position of the link
DataStorage:get (pos)
Returns the data at given position

Parameters:

DataStorage:set (pos, data)
Sets the data at given position

Parameters:

  • pos util.node_pos the position of the data
  • data the data to save at the position or nil to clear
DataStorage:merge (pos, data)
Merges the data at given position with the existing data

Parameters:

  • pos util.node_pos the position of the data
  • data the data to merge at the position, only top-level fields will be merged together
DataStorage:clear ()
Clears all data from the storage
generated by LDoc 1.4.6 Last updated 2023-03-30 05:48:06