minetest.place_schematic_on_vmanip
This page contains unofficial, low-quality Lua API documentation and is likely to be outdated or wrong. Do not rely on it! For the official and up-to-date documentation, see Lua API Documentation. |
This page has been proposed for deletion for the following reason: "Contains unofficial and potentially outdated, redundant and inconsistent Lua API information" If you don't think that this page should be deleted, please explain why on the talk page. |
Syntax
minetest.place_schematic_on_vmanip(vm, pos, schematic, rotation, replacements, force_placement)
Description
This method works in a similar fashion to minetest.place_schematic, but can be used with a VoxelManip for better performance when manipulating large amounts of nodes.
- Uses VoxelManip object vm, which is the voxel manipulator you are using to e.g. generate terrain
- Places the schematic specified by schematic (see: Schematic specifier) at pos.
- Rotation can be "0", "90", "180", "270", or "random".
- If the rotation parameter is omitted, the schematic is not rotated.
- replacements = {["old_name"] = "convert_to", ...}
- force_placement is a boolean indicating whether nodes other than air and ignore are replaced by the schematic
Example
The below snippet places the acacia tree from default at some terrain position with a random rotation when the data written at the voxelmanip index is dirt with dry grass. It
{{code local data = {} local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax}) for z = minp.z, maxp.z do for x = minp.x, maxp.x do for y = minp.y-1, maxp.y+1 do -- E.g. terrain generation code here end end end -- Decoration for z = minp.z, maxp.z do for x = minp.x, maxp.x do local ivm = area:index(x, minp.y-1, z) for y = minp.y-1, maxp.y+1 do if data[ivm] == minetest.get_content_id("default:dirt_with_dry_grass") and math.random(0, 500) then -- We place the tree if there is grass with dirt, but we could also have retrieved the y from the -- terrain heightmap in which case we would not necessarily have to loop from minp.y to maxp.y again minetest.place_schematic_on_vmanip(vm, { x = x - 4, y = y, z = z - 4}, minetest.get_modpath("default").."/schematics/acacia_tree.mts", "random", nil, false) end end end end }}