Remove wrong data pass to write_to_map()

This commit is contained in:
rubenwardy 2018-06-06 00:49:25 +01:00
parent 27d26cae44
commit 5bc4e35009
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C

View File

@ -143,19 +143,15 @@ array to the engine:
{% highlight lua %} {% highlight lua %}
vm:set_data(data) vm:set_data(data)
vm:write_to_map(data) vm:write_to_map(true)
{% endhighlight %} {% endhighlight %}
For setting lighting and param2 data, there are the appropriately named For setting lighting and param2 data, there are the appropriately named
`set_light_data()` and `set_param2_data()` methods `set_light_data()` and `set_param2_data()` methods.
You then need to update lighting and other things: `write_to_map()` takes a boolean which is true if you want lighting to be
calculated. If you pass false, you need to recalculate lighting at some future
{% highlight lua %} date using `minetest.fix_light`.
vm:update_map()
{% endhighlight %}
and that's it!
## Example ## Example
@ -175,9 +171,9 @@ local function grass_to_dirt(pos1, pos2)
local data = vm:get_data() local data = vm:get_data()
-- Modify data -- Modify data
for z = min.z, max.z do for z = pos1.z, pos2.z do
for y = min.y, max.y do for y = pos1.y, pos2.y do
for x = min.x, max.x do for x = pos1.x, pos2.x do
local vi = a:index(x, y, z) local vi = a:index(x, y, z)
if data[vi] == c_grass then if data[vi] == c_grass then
data[vi] = c_dirt data[vi] = c_dirt
@ -188,8 +184,7 @@ local function grass_to_dirt(pos1, pos2)
-- Write data -- Write data
vm:set_data(data) vm:set_data(data)
vm:write_to_map(data) vm:write_to_map(true)
vm:update_map()
end end
{% endhighlight %} {% endhighlight %}