1
0
mirror of https://github.com/Uberi/Minetest-WorldEdit.git synced 2024-12-25 18:20:38 +01:00

Documentation for //stack2, code style fixes, add author section to README.

This commit is contained in:
Uberi 2014-07-06 19:42:02 -04:00
parent b32aadd7fa
commit 175ac211ca
4 changed files with 162 additions and 143 deletions

View File

@ -98,13 +98,13 @@ Display the volume of the current WorldEdit region.
//volume
### `//set <node>`
### `//set <node1> ...`
Set the current WorldEdit region to `<node>`.
Set the current WorldEdit region to a random mix of `<node1>`, `...`.
//set air
//set cactus
//set Bronze Block
//set cactus stone glass
//set Bronze
//set mesecons:wire_00000000_off
### `//replace <search node> <replace node>`
@ -219,6 +219,13 @@ Stack the current WorldEdit region along the x/y/z/? axis `<count>` times.
//stack z +5
//stack ? 12
### `//stack2 <count> <x> <y> <z>`
Stack the current WorldEdit region `<count>` times by offset `<x>`, `<y>`, `<z>`.
//stack2 5 3 8 2
//stack2 1 -1 -1 -1
### `//scale <factor>`
Scale the current WorldEdit positions and region by a factor of positive integer `<factor>` with position 1 as the origin.

View File

@ -130,6 +130,21 @@ The WorldEdit Schematic format is accessed via the WorldEdit API, or WorldEdit s
The second is the Minetest Schematic format (MTS). The details of this format may be found in the Minetest documentation and are out of the scope of this document. Access to this format is done via specialized MTS commands such as `//mtschemcreate` and `//mtschemplace`.
Authors
-------
WorldEdit would not be possible without the contributions of many developers and designers. Below, they are listed alphabetically:
cheapie
cornernote
cyisfor
electricface
kaeza
khonkhortisan
sfan5
ShadowNinja
spillz
Uberi/Temperest
License
-------
Copyright 2013 sfan5, Anthony Zhang (Uberi/Temperest), and Brett O'Donnell (cornernote).

View File

@ -48,8 +48,16 @@ worldedit.set = function(pos1, pos2, nodenames)
for i,v in ipairs(nodenames) do
node_ids[i] = minetest.get_content_id(nodenames[i])
end
if #node_ids == 1 then --only one type of node
local id = node_ids[1]
for i in area:iterp(pos1, pos2) do
nodes[i] = node_ids[math.random(#node_ids)]
nodes[i] = node_ids[id]
end
else --fill randomly with all types of specified nodes
local id_count, rand = #node_ids, math.random
for i in area:iterp(pos1, pos2) do
nodes[i] = node_ids[rand(id_count)]
end
end
--update map nodes
@ -260,8 +268,8 @@ worldedit.copy2 = function(pos1, pos2, direction, volume)
oz = originalz
for z = iz, ez, sz do
-- reusing pos1/pos2 as source/dest here
pos1.x = ox; pos1.y = oy; pos1.z = oz
pos2.x = x; pos2.y = y; pos2.z = z
pos1.x, pos1.y, pos1.z = ox, oy, oz
pos2.x, pos2.y, pos2.z = x, y, z
local node = get_node(pos1)
local meta = to_table(get_meta(pos1)) --get meta of current node
add_node(pos2,node)

View File

@ -279,16 +279,15 @@ minetest.register_chatcommand("/volume", {
})
minetest.register_chatcommand("/set", {
params = "<node>",
description = "Set the current WorldEdit region to <node>",
params = "<node1> ...",
description = "Set the current WorldEdit region to a random mix of <node1>, ...",
privs = {worldedit=true},
func = safe_region(function(name, param)
local nodes = {}
for nodename in param:gmatch("[^%s]+") do
local node = get_node(name, nodename)
if not node then
worldedit.player_notify(name, 'Could not identify node "'..name..'"')
worldedit.player_notify(name, "Could not identify node \"" .. name .. "\"")
return
end
nodes[#nodes + 1] = node
@ -620,8 +619,8 @@ minetest.register_chatcommand("/stack", {
})
minetest.register_chatcommand("/stack2", {
params = "<count> <x>/<y>/<z>",
description = "Stack the current WorldEdit region <count> times translating each time by x, y and z in the respective directions.",
params = "<count> <x> <y> <z>",
description = "Stack the current WorldEdit region <count> times by offset <x>, <y>, <z>",
privs = {worldedit=true},
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
@ -629,36 +628,26 @@ minetest.register_chatcommand("/stack2", {
worldedit.player_notify(name, "Select a position first!")
return
end
local repetitions, incs = param:match("([0-9]+)%s*(.+)")
repetitions = repetitions and tonumber(repetitions)
local repetitions, incs = param:match("(%d+)%s*(.+)")
if repetitions == nil then
worldedit.player_notify(name, "invalid count: " .. param)
return
end
repetitions = tonumber(repetitions)
local x,y,z = incs:match("(.+)/(.+)/(.+)")
local x, y, z = incs:match("([+-]?%d+) ([+-]%d+) ([+-]%d+)")
if x == nil then
worldedit.player_notify(name, "invalid increments: " .. param)
return
end
x = tonumber(x)
y = tonumber(y)
z = tonumber(z)
if x == nil or y == nil or z == nil then
worldedit.player_notify(name, "increments must be numbers: " .. param)
return
end
x, y, z = tonumber(x), tonumber(y), tonumber(z)
local count = worldedit.volume(pos1, pos2) * repetitions
return safe_region(function()
worldedit.stack2(pos1, pos2, {x=x, y=y, z=z}, repetitions,
function()
worldedit.player_notify(name, count .. " nodes stacked")
end)
end,
function()
function() worldedit.player_notify(name, count .. " nodes stacked") end)
end, function()
return count
end)(name,param) -- more hax
end