From 6f9af6f0fd3cd64edbd460f4648485f502b268aa Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Thu, 29 Mar 2018 17:01:23 +0100 Subject: [PATCH] Lua Voxel Manipulators: Move get_data() to reading section --- en/chapters/lvm.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/en/chapters/lvm.md b/en/chapters/lvm.md index b5d7143..7eb6172 100644 --- a/en/chapters/lvm.md +++ b/en/chapters/lvm.md @@ -36,7 +36,6 @@ an LVM like so: {% highlight lua %} local vm = minetest.get_voxel_manip() local emin, emax = vm:read_from_map(pos1, pos2) -local data = vm:get_data() -- node type {% endhighlight %} An LVM may not read exactly the area you tell it to, for performance reasons. @@ -45,16 +44,21 @@ which stand for *emerged min pos* and *emerged max pos*. An LVM will load the ar it contains for you - whether that involves loading from memory, from disk, or calling the map generator. -`get_data()` returns a flat array where each entry represents the type of a -particular node. You can get param2 and lighting data using the methods -`get_light_data()` and `get_param2_data()`. The index for the flat arrays -returned are exactly the same. - ## Reading Nodes -You'll need to use `emin` and `emax` to work out where a node is in the data of -an LVM. There's a helper class called `VoxelArea` which handles the calculation -for you: +To read the types of nodes at particular positions, you'll need to use `get_data()`. +`get_data()` returns a flat array where each entry represents the type of a +particular node. + +{% highlight lua %} +local data = vm:get_data() +{% endhighlight %} + +You can get param2 and lighting data using the methods `get_light_data()` and `get_param2_data()`. + +You'll need to use `emin` and `emax` to work out where a node is in the flat arrays +given by the above methods. There's a helper class called `VoxelArea` which handles +the calculation for you: {% highlight lua %} local a = VoxelArea:new{