From ed13adf35f0d0718a1cbab269730e45ab455ff1c Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Thu, 29 Mar 2018 16:54:56 +0100 Subject: [PATCH] Lua Voxel Manipulators: Mention param2 and lighting data --- en/chapters/lvm.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/en/chapters/lvm.md b/en/chapters/lvm.md index d1b21b6..b5d7143 100644 --- a/en/chapters/lvm.md +++ b/en/chapters/lvm.md @@ -36,7 +36,7 @@ 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() +local data = vm:get_data() -- node type {% endhighlight %} An LVM may not read exactly the area you tell it to, for performance reasons. @@ -45,6 +45,11 @@ 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 @@ -137,6 +142,9 @@ vm:set_data(data) vm:write_to_map(data) {% endhighlight %} +For setting lighting and param2 data, there are the appropriately named +`set_light_data()` and `set_param2_data()` methods + You then need to update lighting and other things: {% highlight lua %} @@ -185,6 +193,8 @@ end * Create `replace_in_area(from, to, pos1, pos2)` which replaces all instances of `from` with `to` in the area given, where from and to are node names. -* Make an LVM which causes mossy cobble to spread to nearby stone and cobble nodes. +* Make a function which rotates all chest nodes by 90°. +* Make a function which uses an LVM to cause mossy cobble to spread to nearby + stone and cobble nodes. Does your implementation cause mossy cobble to spread more than a distance of one each time? How could you stop this?