]> git.lizzy.rs Git - worldedit.git/blobdiff - WorldEdit API.md
Fix deserialization of schematics with node names table
[worldedit.git] / WorldEdit API.md
index c05958e84ac6df76c0572ebb7c0469344d6cb751..fc9cf652e0bda75d020d8a9842d9431beefd8f61 100644 (file)
@@ -21,9 +21,16 @@ Manipulations
 -------------\r
 Contained in manipulations.lua, this module allows several node operations to be applied over a region.\r
 \r
-### count = worldedit.set(pos1, pos2, nodename)\r
+### count = worldedit.set(pos1, pos2, node_name)\r
 \r
-Sets a region defined by positions `pos1` and `pos2` to `nodename`. To clear a region, use "air" as the value of `nodename`.\r
+Sets a region defined by positions `pos1` and `pos2` to `node_name`. To clear a region, use "air" as the value of `node_name`.\r
+If `node_name` is a list of nodes, each set node is randomly picked from it.\r
+\r
+Returns the number of nodes set.\r
+\r
+### `count = worldedit.set_param2(pos1, pos2, param2)`\r
+\r
+Sets the param2 values of all nodes in a region defined by positions `pos1` and `pos2` to `param2`.\r
 \r
 Returns the number of nodes set.\r
 \r
@@ -45,6 +52,13 @@ Copies the region defined by positions `pos1` and `pos2` along the `axis` axis (
 \r
 Returns the number of nodes copied.\r
 \r
+### count = worldedit.copy2(pos1, pos2, off)\r
+\r
+Copies the region defined by positions `pos1` and `pos2` by the offset vector `off`.\r
+Note that the offset needs to be big enough that there is no overlap.\r
+\r
+Returns the number of nodes copied.\r
+\r
 ### count = worldedit.move(pos1, pos2, axis, amount)\r
 \r
 Moves the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes.\r
@@ -57,6 +71,13 @@ Duplicates the region defined by positions `pos1` and `pos2` along the `axis` ax
 \r
 Returns the number of nodes stacked.\r
 \r
+### count = worldedit.stack2(pos1, pos2, direction, amount)\r
+\r
+Duplicates the region defined by positions `pos1` and `pos2` `amount` times with offset vector `direction`.\r
+Note that the offset vector needs to be big enough that there is no overlap.\r
+\r
+Returns the number of nodes stacked.\r
+\r
 ### count, newpos1, newpos2 = worldedit.stretch(pos1, pos2, stretchx, stretchy, stretchz)\r
 \r
 Stretches the region defined by positions `pos1` and `pos2` by an factor of positive integers `stretchx`, `stretchy`. and `stretchz` along the X, Y, and Z axes, respectively, with `pos1` as the origin.\r
@@ -103,51 +124,39 @@ Primitives
 ----------\r
 Contained in primitives.lua, this module allows the creation of several geometric primitives.\r
 \r
-### count = worldedit.hollow_sphere(pos, radius, nodename)\r
-\r
-Adds a hollow sphere centered at `pos` with radius `radius`, composed of `nodename`.\r
-\r
-Returns the number of nodes added.\r
-\r
-### count = worldedit.sphere(pos, radius, nodename)\r
+### count = worldedit.cube(pos, width, height, length, node_name, hollow)\r
 \r
-Adds a sphere centered at `pos` with radius `radius`, composed of `nodename`.\r
+Adds a cube with its ground level centered at `pos`, the dimensions `width` x `height` x `length`, composed of `node_name`.\r
 \r
 Returns the number of nodes added.\r
 \r
-### count = worldedit.hollow_dome(pos, radius, nodename)\r
+### count = worldedit.sphere(pos, radius, node_name, hollow)\r
 \r
-Adds a hollow dome centered at `pos` with radius `radius`, composed of `nodename`.\r
+Adds a sphere centered at `pos` with radius `radius`, composed of `node_name`.\r
 \r
 Returns the number of nodes added.\r
 \r
-### count = worldedit.dome(pos, radius, nodename)\r
+### count = worldedit.dome(pos, radius, node_name, hollow)\r
 \r
-Adds a dome centered at `pos` with radius `radius`, composed of `nodename`.\r
+Adds a dome centered at `pos` with radius `radius`, composed of `node_name`.\r
 \r
 Returns the number of nodes added.\r
 \r
-### count = worldedit.hollow_cylinder(pos, axis, length, radius, nodename)\r
+### count = worldedit.cylinder(pos, axis, length, radius1, radius2, node_name, hollow)\r
 \r
-Adds a hollow cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`.\r
+Adds a cylinder-like at `pos` along the `axis` axis ("x" or "y" or "z") with length `length`, base radius `radius1` and top radius `radius2`, composed of `node_name`.\r
 \r
 Returns the number of nodes added.\r
 \r
-### count = worldedit.cylinder(pos, axis, length, radius, nodename)\r
+### count = worldedit.pyramid(pos, axis, height, node_name, hollow)\r
 \r
-Adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`.\r
+Adds a pyramid centered at `pos` along the `axis` axis ("x" or "y" or "z") with height `height`, composed of `node_name`.\r
 \r
 Returns the number of nodes added.\r
 \r
-### count = worldedit.pyramid(pos, axis, height, nodename)\r
+### count = worldedit.spiral(pos, length, height, spacer, node_name)\r
 \r
-Adds a pyramid centered at `pos` along the `axis` axis ("x" or "y" or "z") with height `height`.\r
-\r
-Returns the number of nodes added.\r
-\r
-### count = worldedit.spiral(pos, length, height, spacer, nodename)\r
-\r
-Adds a spiral centered at `pos` with side length `length`, height `height`, space between walls `spacer`, composed of `nodename`.\r
+Adds a spiral centered at `pos` with side length `length`, height `height`, space between walls `spacer`, composed of `node_name`.\r
 \r
 Returns the number of nodes added.\r
 \r
@@ -167,15 +176,15 @@ Hides all nodes in a region defined by positions `pos1` and `pos2` by non-destru
 \r
 Returns the number of nodes hidden.\r
 \r
-### count = worldedit.suppress(pos1, pos2, nodename)\r
+### count = worldedit.suppress(pos1, pos2, node_name)\r
 \r
-Suppresses all instances of `nodename` in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes.\r
+Suppresses all instances of `node_name` in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes.\r
 \r
 Returns the number of nodes suppressed.\r
 \r
-### count = worldedit.highlight(pos1, pos2, nodename)\r
+### count = worldedit.highlight(pos1, pos2, node_name)\r
 \r
-Highlights all instances of `nodename` in a region defined by positions `pos1` and `pos2` by non-destructively hiding all other nodes.\r
+Highlights all instances of `node_name` in a region defined by positions `pos1` and `pos2` by non-destructively hiding all other nodes.\r
 \r
 Returns the number of nodes found.\r
 \r
@@ -187,31 +196,32 @@ Returns the number of nodes restored.
 \r
 Serialization\r
 -------------\r
-Contained in serialization.lua, this module allows regions of nodes to be serialized and deserialized to formats suitable for use outside MineTest.\r
+Contained in serialization.lua, this module allows regions of nodes to be serialized and deserialized to formats suitable for use outside Minetest.\r
 \r
-### version = worldedit.valueversion(value)\r
+### version, extra_fields, content = worldedit.read_header(value)\r
 \r
-Determines the version of serialized data `value`.\r
+Reads the header from serialized data `value`.\r
 \r
-Returns the version as a positive integer or 0 for unknown versions.\r
+Returns the version as a positive integer (nil for unknown versions),\r
+extra header fields (nil if not supported), and the content after the header.\r
 \r
 ### data, count = worldedit.serialize(pos1, pos2)\r
 \r
 Converts the region defined by positions `pos1` and `pos2` into a single string.\r
 \r
-Returns the serialized data and the number of nodes serialized.\r
+Returns the serialized data and the number of nodes serialized, or nil.\r
 \r
-### pos1, pos2, count = worldedit.allocate(originpos, value)\r
+### pos1, pos2, count = worldedit.allocate(origin_pos, value)\r
 \r
-Determines the volume the nodes represented by string `value` would occupy if deserialized at `originpos`.\r
+Determines the volume the nodes represented by string `value` would occupy if deserialized at `origin_pos`.\r
 \r
-Returns the two corner positions and the number of nodes.\r
+Returns the two corner positions and the number of nodes, or nil.\r
 \r
-### count = worldedit.deserialize(originpos, value)\r
+### count = worldedit.deserialize(origin_pos, value)\r
 \r
-Loads the nodes represented by string `value` at position `originpos`.\r
+Loads the nodes represented by string `value` at position `origin_pos`.\r
 \r
-Returns the number of nodes deserialized.\r
+Returns the number of nodes deserialized or nil.\r
 \r
 Code\r
 ----\r
@@ -227,4 +237,4 @@ Returns an error if the code fails or nil otherwise.
 \r
 Executes `code` as a Lua chunk in the global namespace with the variable `pos` available, for each node in a region defined by positions `pos1` and `pos2`.\r
 \r
-Returns an error if the code fails or nil otherwise.
\ No newline at end of file
+Returns an error if the code fails or nil otherwise.\r