Extract voxel manipulations wraper minetest.with_map_part_do(). Relates to lord-server/lord#1084, lord-server/lord#1058, lord-server/lord#663, lord-server/lord#661.

This commit is contained in:
alek13
2024-04-02 18:41:54 +03:00
parent 146305cabe
commit 93b4988dab
2 changed files with 25 additions and 16 deletions

View File

@@ -6,7 +6,9 @@ VoxelManip = {}
--- Loads a chunk of map into the VoxelManip object --- Loads a chunk of map into the VoxelManip object
--- containing the region formed by `p1` and `p2`. --- containing the region formed by `p1` and `p2`.
--- * returns actual emerged `pmin`, actual emerged `pmax` --- * returns actual emerged `pmin`, actual emerged `pmax`
function VoxelManip:read_from_map(p1, p2) end --- @param position1 Position min position for load part of map
--- @param position2 Position max position for load part of map
function VoxelManip:read_from_map(position1, position2) end
--- Writes the data loaded from the `VoxelManip` back to --- Writes the data loaded from the `VoxelManip` back to
--- the map. --- the map.
--- * **important**: data must be set using `VoxelManip:set_data()` before --- * **important**: data must be set using `VoxelManip:set_data()` before
@@ -17,6 +19,7 @@ function VoxelManip:read_from_map(p1, p2) end
--- all modified blocks with `minetest.fix_light()` as soon as possible. --- all modified blocks with `minetest.fix_light()` as soon as possible.
--- Keep in mind that modifying the map where light is incorrect can cause --- Keep in mind that modifying the map where light is incorrect can cause
--- more lighting bugs. --- more lighting bugs.
--- @param light boolean Default: true
function VoxelManip:write_to_map(light) end function VoxelManip:write_to_map(light) end
--- Returns a `MapNode` table of the node currently loaded in --- Returns a `MapNode` table of the node currently loaded in
--- the `VoxelManip` at that position --- the `VoxelManip` at that position
@@ -24,11 +27,12 @@ function VoxelManip:get_node_at(pos) end
--- Sets a specific `MapNode` in the `VoxelManip` at --- Sets a specific `MapNode` in the `VoxelManip` at
--- that position. --- that position.
function VoxelManip:set_node_at(pos, node) end function VoxelManip:set_node_at(pos, node) end
--- Retrieves the node content data loaded into the --- Retrieves the node content data loaded into the `VoxelManip` object.
--- `VoxelManip` object.
--- * returns raw node data in the form of an array of node content IDs --- * returns raw node data in the form of an array of node content IDs
--- * if the param `buffer` is present, this table will be used to store the --- * if the param `buffer` is present, this table will be used to store the
--- result instead. --- result instead.
--- @param buffer number[]|nil
--- @return number[]
function VoxelManip:get_data(buffer) end function VoxelManip:get_data(buffer) end
--- Sets the data contents of the `VoxelManip` object --- Sets the data contents of the `VoxelManip` object
--- function VoxelManip:set_data(data) end --- function VoxelManip:set_data(data) end
@@ -42,8 +46,7 @@ function VoxelManip:get_data(buffer) end
--- * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole --- * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
--- area if left out. --- area if left out.
function VoxelManip:set_lighting(light, p1, p2) end function VoxelManip:set_lighting(light, p1, p2) end
--- Gets the light data read into the --- Gets the light data read into the `VoxelManip` object.
--- `VoxelManip` object
--- * Returns an array (indices 1 to volume) of integers ranging from `0` to --- * Returns an array (indices 1 to volume) of integers ranging from `0` to
--- `255`. --- `255`.
--- * Each value is the bitwise combination of day and night light values --- * Each value is the bitwise combination of day and night light values
@@ -51,23 +54,25 @@ function VoxelManip:set_lighting(light, p1, p2) end
--- * `light = day + (night * 16)` --- * `light = day + (night * 16)`
--- * If the param `buffer` is present, this table will be used to store the --- * If the param `buffer` is present, this table will be used to store the
--- result instead. --- result instead.
--- @param buffer number[]
--- @return number[]
function VoxelManip:get_light_data(buffer) end function VoxelManip:get_light_data(buffer) end
--- Sets the `param1` (light) contents of each node --- Sets the `param1` (light) contents of each node in the `VoxelManip`.
--- in the `VoxelManip`.
--- * expects lighting data in the same format that `get_light_data()` returns --- * expects lighting data in the same format that `get_light_data()` returns
--- @param light_data number[]
function VoxelManip:set_light_data(light_data) end function VoxelManip:set_light_data(light_data) end
--- Gets the raw `param2` data read into the --- Gets the raw `param2` data read into the `VoxelManip` object.
--- `VoxelManip` object.
--- * Returns an array (indices 1 to volume) of integers ranging from `0` to --- * Returns an array (indices 1 to volume) of integers ranging from `0` to
--- `255`. --- `255`.
--- * If the param `buffer` is present, this table will be used to store the --- * If the param `buffer` is present, this table will be used to store the
--- result instead. --- result instead.
--- @param buffer number[]
--- @return number[]
function VoxelManip:get_param2_data(buffer) end function VoxelManip:get_param2_data(buffer) end
--- Sets the `param2` contents of each node in --- Sets the `param2` contents of each node in the `VoxelManip`.
--- the `VoxelManip`. --- @param param2_data number[]
function VoxelManip:set_param2_data(param2_data) end function VoxelManip:set_param2_data(param2_data) end
--- Calculate lighting within the --- Calculate lighting within the `VoxelManip`.
--- `VoxelManip`.
--- * To be used only by a `VoxelManip` object from --- * To be used only by a `VoxelManip` object from
--- `minetest.get_mapgen_object`. --- `minetest.get_mapgen_object`.
--- * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole --- * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
@@ -76,6 +81,9 @@ function VoxelManip:set_param2_data(param2_data) end
--- * `propagate_shadow` is an optional boolean deciding whether shadows in a --- * `propagate_shadow` is an optional boolean deciding whether shadows in a
--- generated mapchunk above are propagated down into the mapchunk, defaults --- generated mapchunk above are propagated down into the mapchunk, defaults
--- to `true` if left out. --- to `true` if left out.
--- @param p1 Position
--- @param p2 Position
--- @param propagate_shadow boolean
function VoxelManip:calc_lighting(p1, p2, propagate_shadow) end function VoxelManip:calc_lighting(p1, p2, propagate_shadow) end
--- Update liquid flow --- Update liquid flow
function VoxelManip:update_liquids() end function VoxelManip:update_liquids() end

View File

@@ -1072,9 +1072,10 @@ function minetest.get_perlin(seeddiff, octaves, persistence, spread) end
--- * Loads the manipulator from the map if positions are passed. --- * Loads the manipulator from the map if positions are passed.
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4955-L4957) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4955-L4957)
--- @param positions table array [pos1, pos2] --- @param position1 Position min position
--- @param position2 Position max position
--- @return VoxelManip --- @return VoxelManip
function minetest.get_voxel_manip(positions) end function minetest.get_voxel_manip(position1, position2) end
--- * Set the types of on-generate notifications that should be collected. --- * Set the types of on-generate notifications that should be collected.
--- * `flags` is a flag field with the available flags: --- * `flags` is a flag field with the available flags:
--- * dungeon --- * dungeon
@@ -1102,7 +1103,7 @@ function minetest.get_decoration_id(decoration_name) end
--- * Return requested mapgen object if available (see [Mapgen objects]) --- * Return requested mapgen object if available (see [Mapgen objects])
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4975-L4976) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4975-L4976)
--- @return VoxelManip, number, number --- @return VoxelManip|number[][]|number[][][], number, number
function minetest.get_mapgen_object(objectname) end function minetest.get_mapgen_object(objectname) end
--- * Returns the heat at the position, or `nil` on failure. --- * Returns the heat at the position, or `nil` on failure.
--- ---