]> git.lizzy.rs Git - worldedit.git/commitdiff
Properly document the WorldEdit API.
authorAnthony Zhang <azhang9@gmail.com>
Sat, 14 Jul 2012 02:14:25 +0000 (22:14 -0400)
committerAnthony Zhang <azhang9@gmail.com>
Sat, 14 Jul 2012 02:14:25 +0000 (22:14 -0400)
README.md
functions.lua
init.lua

index 0e58e6fc320e6d4faf0f2127377f7dce76f9ee7f..b6f6e6c50c5e74af3034ce755e49ddcab0be8b6a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -101,6 +101,64 @@ Load nodes from "(world folder)/schems/<file>.we" with position 1 of the current
     //load some random filename
     //load huge_base
 
+WorldEdit API
+-------------
+WorldEdit exposes all significant functionality in a simple interface. Adding WorldEdit to the file "depends.txt" in your mod gives you access to all of the `worldedit` functions. These are useful if you're looking for high-performance node manipulation without all the hassle of writing tons of code.
+
+### worldedit.volume(pos1, pos2)
+
+Determines the volume of the region defined by positions `pos1` and `pos2`.
+
+Returns the volume.
+
+### worldedit.set(pos1, pos2, nodename)
+
+Sets a region defined by positions `pos1` and `pos2` to `nodename`. To clear to region, use "air" as the value of `nodename`.
+
+Returns the number of nodes set.
+
+### worldedit.replace(pos1, pos2, searchnode, replacenode)
+
+Replaces all instances of `searchnode` with `replacenode` in a region defined by positions `pos1` and `pos2`.
+
+Returns the number of nodes replaced.
+
+### worldedit.copy(pos1, pos2, axis, amount)
+
+Copies the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes.
+
+Returns the number of nodes copied.
+
+### worldedit.move(pos1, pos2, axis, amount)
+
+Moves the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes.
+
+Returns the number of nodes moved.
+
+### worldedit.stack(pos1, pos2, axis, count)
+
+duplicates the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") `count` times.
+
+Returns the number of nodes stacked.
+
+### worldedit.dig(pos1, pos2)
+
+Digs a region defined by positions `pos1` and `pos2`.
+
+Returns the number of nodes dug.
+
+### worldedit.serialize(pos1, pos2)
+
+Converts the region defined by positions `pos1` and `pos2` into a single string.
+
+Returns the serialized data and the number of nodes serialized.
+
+### worldedit.deserialize(originpos, value)
+
+Loads the nodes represented by string `value` at position `originpos`.
+
+Returns the number of nodes deserialized.
+
 License
 -------
 Copyright 2012 sfan5 and Anthony Zhang (Temperest)
index 2226e4c82309531f296f7f752f5d389f8fa2476b..35015a5e5d924e38b894a333e691dd019f1c858a 100644 (file)
@@ -20,8 +20,8 @@ worldedit.volume = function(pos1, pos2)
        return (pos2.x - pos1.x + 1) * (pos2.y - pos1.y + 1) * (pos2.z - pos1.z + 1)\r
 end\r
 \r
---fills a region defined by positions `pos1` and `pos2` with `nodename`, returning the number of nodes filled\r
-worldedit.fill = function(pos1, pos2, nodename)\r
+--sets a region defined by positions `pos1` and `pos2` to `nodename`, returning the number of nodes filled\r
+worldedit.set = function(pos1, pos2, nodename)\r
        local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
        local env = minetest.env\r
 \r
@@ -72,7 +72,7 @@ worldedit.replace = function(pos1, pos2, searchnode, replacenode)
        return count\r
 end\r
 \r
---copies the region defined by positions `pos1` and `pos2` along the `axis` axis by `amount` nodes, returning the number of nodes copied\r
+--copies the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes, returning the number of nodes copied\r
 worldedit.copy = function(pos1, pos2, axis, amount)\r
        local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
        local env = minetest.env\r
@@ -117,7 +117,7 @@ worldedit.copy = function(pos1, pos2, axis, amount)
        return worldedit.volume(pos1, pos2)\r
 end\r
 \r
---moves the region defined by positions `pos1` and `pos2` along the `axis` axis by `amount` nodes, returning the number of nodes moved\r
+--moves the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes, returning the number of nodes moved\r
 worldedit.move = function(pos1, pos2, axis, amount)\r
        local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
        local env = minetest.env\r
@@ -164,7 +164,7 @@ worldedit.move = function(pos1, pos2, axis, amount)
        return worldedit.volume(pos1, pos2)\r
 end\r
 \r
---duplicates the region defined by positions `pos1` and `pos2` along the `axis` axis `count` times, returning the number of nodes stacked\r
+--duplicates the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") `count` times, returning the number of nodes stacked\r
 worldedit.stack = function(pos1, pos2, axis, count)\r
        local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
        local length = pos2[axis] - pos1[axis] + 1\r
index f37f7546ecf346f4bf145dee4c0777e9eb94917a..3191bd0f6be8b6d9e468b9a01da835ae590a9c67 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -112,8 +112,8 @@ minetest.register_chatcommand("/set", {
                        return\r
                end\r
 \r
-               local count = worldedit.fill(pos1, pos2, param)\r
-               minetest.chat_send_player(name, count .. " nodes filled")\r
+               local count = worldedit.set(pos1, pos2, param)\r
+               minetest.chat_send_player(name, count .. " nodes set")\r
        end,\r
 })\r
 \r