LVM: Fix ContentID inaccuracy

This commit is contained in:
rubenwardy 2021-01-25 08:38:39 +00:00
parent d12e5244b3
commit e8e16eee5d

View File

@ -105,9 +105,8 @@ if data[idx] == c_stone then
end end
``` ```
It is recommended that you find and store the content IDs of nodes types Content IDs of a node type may change during load time, so it is recommended that
at load time because the IDs of a node type will never change. Make sure to store you don't try getting them during this time.
the IDs in a local variable for performance reasons.
Nodes in an LVM data array are stored in reverse co-ordinate order, so you should Nodes in an LVM data array are stored in reverse co-ordinate order, so you should
always iterate in the order `z, y, x`. For example: always iterate in the order `z, y, x`. For example:
@ -170,11 +169,10 @@ time using `minetest.fix_light`.
## Example ## Example
```lua ```lua
-- Get content IDs during load time, and store into a local local function grass_to_dirt(pos1, pos2)
local c_dirt = minetest.get_content_id("default:dirt") local c_dirt = minetest.get_content_id("default:dirt")
local c_grass = minetest.get_content_id("default:dirt_with_grass") local c_grass = minetest.get_content_id("default:dirt_with_grass")
local function grass_to_dirt(pos1, pos2)
-- Read data into LVM -- Read data into LVM
local vm = minetest.get_voxel_manip() local vm = minetest.get_voxel_manip()
local emin, emax = vm:read_from_map(pos1, pos2) local emin, emax = vm:read_from_map(pos1, pos2)