minetest/minetest — pull request #1583 by Zeno- (2014-08-28 07:19:03+00:00)
Title: Lua api extensions

Added:
minetest.set_nodes_in_area(minp, maxp, node)
minetest.remove_nodes_in_area(minp, maxp)

Rationale:
Some mods (for example, worldedit and plants_lib) currently do bulk operations on nodes in an area, such as clearing or replacing them. Currently this is done in Lua via an x,y,z loop calling either set_node or remove_node -- whichever is appropriate. Since these are "bulk" operations it makes sense to have them as part of the Lua API. An alternative is to use vmanip, however this (currently) causes problems between different (mapgen, for example) mods that use different methods: directly calling set_node or remove_node vs. those that use vmanip. Additionally, the execution time to create a vmanip area exceeds the total execution times of these new functions.

Advantages:
a) A single call to one function to set/remove the nodes in an area is arguably "cleaner" than having to write a loop in Lua that achieves the same function, making Lua code more readable and concise
b) Undertaking the operations in C++ is slighty faster (between approximately 1.4 to 4 times faster using LuaJIT)

Backward compatibility:
Does not affect existing Lua scripts