diff options
author | sfan5 <sfan5@live.de> | 2012-08-19 09:36:11 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2012-08-19 09:36:11 +0200 |
commit | e39493e789d77f98af4cdc17de21ca1ef0547571 (patch) | |
tree | 66acd31792c4064588dd646f9acc7df4b0227b24 /init.lua | |
parent | 5b66b5ec2592155bae00ad958c3b032f7aa3118d (diff) |
Add //spiral and worldedit.spiral API function
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 32 |
1 files changed, 31 insertions, 1 deletions
@@ -216,6 +216,36 @@ minetest.register_chatcommand("/hollowcylinder", { end,
})
+
+minetest.register_chatcommand("/spiral", {
+ params = "<size> <node>",
+ description = "Add Spiral at WorldEdit position 1 with size <size>, composed of <node>",
+ privs = {worldedit=true},
+ func = function(name, param)
+ local pos = worldedit.pos1[name]
+ if pos == nil then
+ minetest.chat_send_player(name, "No WorldEdit region selected")
+ return
+ end
+
+ local found, _, size, nodename = param:find("(%d+)%s+([^%s]+)$")
+ if found == nil then
+ minetest.chat_send_player(name, "Invalid usage: " .. param)
+ return
+ end
+ if axis == "?" then
+ axis = worldedit.player_axis(name)
+ end
+ if not worldedit.node_is_valid(pos, nodename) then
+ minetest.chat_send_player(name, "Invalid node name: " .. param)
+ return
+ end
+
+ local count = worldedit.spiral(pos, tonumber(size), nodename)
+ minetest.chat_send_player(name, count .. " nodes changed")
+ end,
+})
+
minetest.register_chatcommand("/cylinder", {
params = "x/y/z/? <length> <radius> <node>",
description = "Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length> and radius <radius>, composed of <node>",
@@ -486,4 +516,4 @@ minetest.register_chatcommand("/load", { minetest.chat_send_player(name, count .. " nodes loaded")
end,
-})
\ No newline at end of file +})
|