mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2025-07-13 05:10:27 +02:00
Synchronization with Uberi version 2016-01-23
This commit is contained in:
@ -36,6 +36,7 @@ load_module(path .. "/visualization.lua")
|
||||
load_module(path .. "/serialization.lua")
|
||||
load_module(path .. "/code.lua")
|
||||
load_module(path .. "/compatibility.lua")
|
||||
load_module(path .. "/wand.lua")
|
||||
|
||||
|
||||
if minetest.setting_getbool("log_mods") then
|
||||
|
@ -147,7 +147,7 @@ function worldedit.stack2(pos1, pos2, direction, amount, finished)
|
||||
translated.x = translated.x + direction.x
|
||||
translated.y = translated.y + direction.y
|
||||
translated.z = translated.z + direction.z
|
||||
worldedit.copy2(pos1, pos2, translated, volume)
|
||||
worldedit.copy2(pos1, pos2, translated)
|
||||
minetest.after(0, next_one)
|
||||
else
|
||||
if finished then
|
||||
@ -221,6 +221,38 @@ function worldedit.copy(pos1, pos2, axis, amount)
|
||||
return worldedit.volume(pos1, pos2)
|
||||
end
|
||||
|
||||
--- Copies a region by offset vector `off`.
|
||||
-- @param pos1
|
||||
-- @param pos2
|
||||
-- @param off
|
||||
-- @return The number of nodes copied.
|
||||
function worldedit.copy2(pos1, pos2, off)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local get_node, get_meta, set_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.set_node
|
||||
local pos = {}
|
||||
pos.x = pos2.x
|
||||
while pos.x >= pos1.x do
|
||||
pos.y = pos2.y
|
||||
while pos.y >= pos1.y do
|
||||
pos.z = pos2.z
|
||||
while pos.z >= pos1.z do
|
||||
local node = get_node(pos) -- Obtain current node
|
||||
local meta = get_meta(pos):to_table() -- Get meta of current node
|
||||
local newpos = vector.add(pos, off) -- Calculate new position
|
||||
set_node(newpos, node) -- Copy node to new position
|
||||
get_meta(newpos):from_table(meta) -- Set metadata of new node
|
||||
pos.z = pos.z - 1
|
||||
end
|
||||
pos.y = pos.y - 1
|
||||
end
|
||||
pos.x = pos.x - 1
|
||||
end
|
||||
return worldedit.volume(pos1, pos2)
|
||||
end
|
||||
|
||||
--- Moves a region along `axis` by `amount` nodes.
|
||||
-- @return The number of nodes moved.
|
||||
|
@ -157,7 +157,7 @@ function worldedit.pyramid(pos, axis, height, node_name)
|
||||
-- Set up voxel manipulator
|
||||
local manip, area = mh.init_axis_radius(pos, axis,
|
||||
height >= 0 and height or -height)
|
||||
local data = mh.get_empty_data()
|
||||
local data = mh.get_empty_data(area)
|
||||
|
||||
-- Handle inverted pyramids
|
||||
local start_axis, end_axis, step
|
||||
@ -177,7 +177,7 @@ function worldedit.pyramid(pos, axis, height, node_name)
|
||||
y = pos.y - area.MinEdge.y,
|
||||
z = pos.z - area.MinEdge.z,
|
||||
}
|
||||
local size = height * step
|
||||
local size = math.abs(height * step)
|
||||
local count = 0
|
||||
-- For each level of the pyramid
|
||||
for index1 = 0, height, step do
|
||||
|
@ -144,9 +144,9 @@ local function load_schematic(value)
|
||||
"([^%s]+)%s+(%d+)%s+(%d+)[^\r\n]*[\r\n]*") do
|
||||
param1, param2 = tonumber(param1), tonumber(param2)
|
||||
table.insert(nodes, {
|
||||
x = originx + tonumber(x),
|
||||
y = originy + tonumber(y),
|
||||
z = originz + tonumber(z),
|
||||
x = tonumber(x),
|
||||
y = tonumber(y),
|
||||
z = tonumber(z),
|
||||
name = name,
|
||||
param1 = param1 ~= 0 and param1 or nil,
|
||||
param2 = param2 ~= 0 and param2 or nil,
|
||||
|
BIN
worldedit/textures/worldedit_wand.png
Normal file
BIN
worldedit/textures/worldedit_wand.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 442 B |
51
worldedit/wand.lua
Normal file
51
worldedit/wand.lua
Normal file
@ -0,0 +1,51 @@
|
||||
minetest.register_tool("worldedit:wand", {
|
||||
description = "WorldEdit wand tool. Left-click to set the 1st position, Right-click to set the 2nd position.",
|
||||
groups = {},
|
||||
inventory_image = "worldedit_wand.png",
|
||||
wield_image = "",
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
stack_max = 1, -- there is no need to have more than one
|
||||
liquids_pointable = true, -- ground with only water on can be selected as well
|
||||
-- the tool_capabilities are completely irrelevant here - no need to dig
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level=0,
|
||||
groupcaps={
|
||||
fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
|
||||
snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
|
||||
choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0}
|
||||
}
|
||||
},
|
||||
node_placement_prediction = nil,
|
||||
|
||||
on_use = function(itemstack, placer, pointed_thing)
|
||||
if placer ~= nil and pointed_thing ~= nil then
|
||||
local name = placer:get_player_name()
|
||||
local pos = minetest.get_pointed_thing_position( pointed_thing, false ) -- not above
|
||||
|
||||
if not pos then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
worldedit.pos1[name] = pos
|
||||
worldedit.mark_pos1(name)
|
||||
|
||||
end
|
||||
return itemstack -- nothing consumed, nothing changed
|
||||
end,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing) -- Left Click
|
||||
if placer ~= nil and pointed_thing ~= nil then
|
||||
local name = placer:get_player_name()
|
||||
local pos = minetest.get_pointed_thing_position( pointed_thing, false ) -- not above
|
||||
|
||||
if not pos then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
worldedit.pos2[name] = pos
|
||||
worldedit.mark_pos2(name)
|
||||
end
|
||||
return itemstack -- nothing consumed, nothing changed
|
||||
end,
|
||||
})
|
Reference in New Issue
Block a user