mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-21 23:13:00 +00:00
upgrade 7 more commands
This commit is contained in:
parent
adfc6d6499
commit
8d6db6d3f5
7 changed files with 68 additions and 42 deletions
|
@ -6,6 +6,8 @@
|
||||||
-- ██ ██ ██ ██ ██ █████
|
-- ██ ██ ██ ██ ██ █████
|
||||||
-- ██ ██ ██ ██ ██ ██
|
-- ██ ██ ██ ██ ██ ██
|
||||||
-- ███████ ██ ██ ████ ███████
|
-- ███████ ██ ██ ████ ███████
|
||||||
|
|
||||||
|
|
||||||
function worldeditadditions.line(pos1, pos2, thickness, node_name)
|
function worldeditadditions.line(pos1, pos2, thickness, node_name)
|
||||||
local pos1_sorted, pos2_sorted = worldedit.sort_pos(pos1, pos2)
|
local pos1_sorted, pos2_sorted = worldedit.sort_pos(pos1, pos2)
|
||||||
-- pos2 will always have the highest co-ordinates now
|
-- pos2 will always have the highest co-ordinates now
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
local wea_c = worldeditadditions_core
|
||||||
|
|
||||||
local function parse_slope_range(text)
|
local function parse_slope_range(text)
|
||||||
if string.match(text, "%.%.") then
|
if string.match(text, "%.%.") then
|
||||||
-- It's in the form a..b
|
-- It's in the form a..b
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
local wea_c = worldeditadditions_core
|
||||||
|
local Vector3 = wea_c.Vector3
|
||||||
|
|
||||||
-- ██ ██ ███ ██ ███████
|
-- ██ ██ ███ ██ ███████
|
||||||
-- ██ ██ ████ ██ ██
|
-- ██ ██ ████ ██ ██
|
||||||
-- ██ ██ ██ ██ ██ █████
|
-- ██ ██ ██ ██ ██ █████
|
||||||
|
@ -39,13 +42,21 @@ worldeditadditions_core.register_command("line", {
|
||||||
)) -- Volume of a cylinder
|
)) -- Volume of a cylinder
|
||||||
end,
|
end,
|
||||||
func = function(name, replace_node, radius)
|
func = function(name, replace_node, radius)
|
||||||
local start_time = worldeditadditions.get_ms_time()
|
local start_time = wea_c.get_ms_time()
|
||||||
local success, stats = worldeditadditions.line(worldedit.pos1[name], worldedit.pos2[name], radius, replace_node)
|
-- Can't sort here because the start & ending points matter
|
||||||
local time_taken = worldeditadditions.get_ms_time() - start_time
|
local pos1 = Vector3.clone(worldedit.pos1[name])
|
||||||
|
local pos2 = Vector3.clone(worldedit.pos2[name])
|
||||||
|
|
||||||
|
local success, stats = worldeditadditions.line(
|
||||||
|
pos1, pos2,
|
||||||
|
radius,
|
||||||
|
replace_node
|
||||||
|
)
|
||||||
|
local time_taken = wea_c.get_ms_time() - start_time
|
||||||
|
|
||||||
if success == false then return false, stats end
|
if success == false then return false, stats end
|
||||||
|
|
||||||
minetest.log("action", name .. " used //line at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. ", replacing " .. stats.replaced .. " nodes in " .. time_taken .. "s")
|
minetest.log("action", name.." used //line from "..pos1.." to "..pos2..", replacing "..stats.replaced.." nodes in "..time_taken.."s")
|
||||||
return true, stats.replaced .. " nodes replaced in " .. worldeditadditions.format.human_time(time_taken)
|
return true, stats.replaced.." nodes replaced in "..wea_c.format.human_time(time_taken)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
local wea = worldeditadditions
|
local wea = worldeditadditions
|
||||||
local wea_c = worldeditadditions_core
|
local wea_c = worldeditadditions_core
|
||||||
local Vector3 = worldeditadditions.Vector3
|
local Vector3 = wea.Vector3
|
||||||
|
|
||||||
local function parse_params_maze(params_text, is_3d)
|
local function parse_params_maze(params_text, is_3d)
|
||||||
if not params_text then params_text = "" end
|
if not params_text then params_text = "" end
|
||||||
params_text = wea.trim(params_text)
|
params_text = wea_c.trim(params_text)
|
||||||
if #params_text == 0 then
|
if #params_text == 0 then
|
||||||
return false, "No arguments specified"
|
return false, "No arguments specified"
|
||||||
end
|
end
|
||||||
|
|
||||||
local parts = worldeditadditions.split_shell(params_text)
|
local parts = wea_c.split_shell(params_text)
|
||||||
|
|
||||||
local replace_node = parts[1]
|
local replace_node = parts[1]
|
||||||
local seed = os.time() * math.random()
|
local seed = os.time() * math.random()
|
||||||
|
@ -31,7 +31,7 @@ local function parse_params_maze(params_text, is_3d)
|
||||||
path_depth = tonumber(parts[4])
|
path_depth = tonumber(parts[4])
|
||||||
end
|
end
|
||||||
if #parts >= param_index_seed then
|
if #parts >= param_index_seed then
|
||||||
seed = worldeditadditions.parse.seed(parts[param_index_seed])
|
seed = wea_c.parse.seed(parts[param_index_seed])
|
||||||
end
|
end
|
||||||
|
|
||||||
replace_node = worldedit.normalize_nodename(replace_node)
|
replace_node = worldedit.normalize_nodename(replace_node)
|
||||||
|
@ -75,7 +75,7 @@ wea_c.register_command("maze", {
|
||||||
return worldedit.volume(worldedit.pos1[name], worldedit.pos2[name])
|
return worldedit.volume(worldedit.pos1[name], worldedit.pos2[name])
|
||||||
end,
|
end,
|
||||||
func = function(name, replace_node, seed, path_length, path_width)
|
func = function(name, replace_node, seed, path_length, path_width)
|
||||||
local start_time = wea.get_ms_time()
|
local start_time = wea_c.get_ms_time()
|
||||||
|
|
||||||
local pos1, pos2 = Vector3.sort(worldedit.pos1[name], worldedit.pos2[name])
|
local pos1, pos2 = Vector3.sort(worldedit.pos1[name], worldedit.pos2[name])
|
||||||
local replaced = wea.maze2d(
|
local replaced = wea.maze2d(
|
||||||
|
@ -85,10 +85,10 @@ wea_c.register_command("maze", {
|
||||||
path_length, path_width
|
path_length, path_width
|
||||||
)
|
)
|
||||||
|
|
||||||
local time_taken = wea.get_ms_time() - start_time
|
local time_taken = wea_c.get_ms_time() - start_time
|
||||||
|
|
||||||
minetest.log("action", name.." used //maze at "..pos1.." - "..pos2..", replacing "..replaced.." nodes in "..time_taken.."s")
|
minetest.log("action", name.." used //maze at "..pos1.." - "..pos2..", replacing "..replaced.." nodes in "..time_taken.."s")
|
||||||
return true, replaced.." nodes replaced in "..wea.format.human_time(time_taken)
|
return true, replaced.." nodes replaced in "..wea_c.format.human_time(time_taken)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -107,18 +107,24 @@ wea_c.register_command("maze3d", {
|
||||||
require_pos = 2,
|
require_pos = 2,
|
||||||
parse = function(params_text)
|
parse = function(params_text)
|
||||||
local values = {parse_params_maze(params_text, true)}
|
local values = {parse_params_maze(params_text, true)}
|
||||||
return worldeditadditions.table.unpack(values)
|
return wea_c.table.unpack(values)
|
||||||
end,
|
end,
|
||||||
nodes_needed = function(name)
|
nodes_needed = function(name)
|
||||||
return worldedit.volume(worldedit.pos1[name], worldedit.pos2[name])
|
return worldedit.volume(worldedit.pos1[name], worldedit.pos2[name])
|
||||||
end,
|
end,
|
||||||
func = function(name, replace_node, seed, path_length, path_width, path_depth)
|
func = function(name, replace_node, seed, path_length, path_width, path_depth)
|
||||||
local start_time = worldeditadditions.get_ms_time()
|
local start_time = wea_c.get_ms_time()
|
||||||
local replaced = worldeditadditions.maze3d(worldedit.pos1[name], worldedit.pos2[name], replace_node, seed, path_length, path_width, path_depth)
|
local pos1, pos2 = Vector3.sort(worldedit.pos1[name], worldedit.pos2[name])
|
||||||
local time_taken = worldeditadditions.get_ms_time() - start_time
|
local replaced = wea_c.maze3d(
|
||||||
|
pos1, pos2,
|
||||||
|
replace_node,
|
||||||
|
seed,
|
||||||
|
path_length, path_width, path_depth
|
||||||
|
)
|
||||||
|
local time_taken = wea_c.get_ms_time() - start_time
|
||||||
|
|
||||||
|
|
||||||
minetest.log("action", name.." used //maze3d at "..worldeditadditions.vector.tostring(worldedit.pos1[name]).." - "..worldeditadditions.vector.tostring(worldedit.pos2[name])..", replacing "..replaced.." nodes in "..time_taken.."s")
|
minetest.log("action", name.." used //maze3d at "..pos1.." - "..pos2..", replacing "..replaced.." nodes in "..time_taken.."s")
|
||||||
return true, replaced.." nodes replaced in "..worldeditadditions.format.human_time(time_taken)
|
return true, replaced.." nodes replaced in "..wea_c.format.human_time(time_taken)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
local wea = worldeditadditions
|
local wea = worldeditadditions
|
||||||
|
local wea_c = worldeditadditions_core
|
||||||
local Vector3 = wea.Vector3
|
local Vector3 = wea.Vector3
|
||||||
|
|
||||||
-- ██████ ██████ ███ ███ ███████
|
-- ██████ ██████ ███ ███ ███████
|
||||||
|
@ -14,7 +15,7 @@ worldeditadditions_core.register_command("metaball", {
|
||||||
parse = function(params_text)
|
parse = function(params_text)
|
||||||
if not params_text then params_text = "" end
|
if not params_text then params_text = "" end
|
||||||
|
|
||||||
local parts = wea.split_shell(params_text)
|
local parts = wea_c.split_shell(params_text)
|
||||||
|
|
||||||
if #parts < 1 then
|
if #parts < 1 then
|
||||||
return false, "Error: Not enough arguments (see /help /dome for usage information)."
|
return false, "Error: Not enough arguments (see /help /dome for usage information)."
|
||||||
|
@ -88,7 +89,7 @@ worldeditadditions_core.register_command("metaball", {
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
func = function(name, subcommand, subargs)
|
func = function(name, subcommand, subargs)
|
||||||
local start_time = wea.get_ms_time()
|
local start_time = wea_c.get_ms_time()
|
||||||
local message = ""
|
local message = ""
|
||||||
local append_time = false
|
local append_time = false
|
||||||
if subcommand == "list" then
|
if subcommand == "list" then
|
||||||
|
@ -142,14 +143,14 @@ worldeditadditions_core.register_command("metaball", {
|
||||||
append_time = true
|
append_time = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local time_taken = wea.get_ms_time() - start_time
|
local time_taken = wea_c.get_ms_time() - start_time
|
||||||
|
|
||||||
|
|
||||||
if append_time then
|
if append_time then
|
||||||
message = message.." in "..wea.format.human_time(time_taken)
|
message = message.." in "..wea_c.format.human_time(time_taken)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.log("action", name.." used //metaballs "..subcommand.." in "..wea.format.human_time(time_taken))
|
minetest.log("action", name.." used //metaballs "..subcommand.." in "..wea_c.format.human_time(time_taken))
|
||||||
return true, message
|
return true, message
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
local wea = worldeditadditions
|
local wea = worldeditadditions
|
||||||
local Vector3 = wea.Vector3
|
local wea_c = worldeditadditions_core
|
||||||
|
local Vector3 = wea_c.Vector3
|
||||||
|
|
||||||
local function parse_stage2(name, parts)
|
local function parse_stage2(name, parts)
|
||||||
local success, vpos1, vpos2 = wea.parse.axes(
|
local success, vpos1, vpos2 = wea_c.parse.axes(
|
||||||
parts,
|
parts,
|
||||||
wea.player_dir(name)
|
wea_c.player_dir(name)
|
||||||
)
|
)
|
||||||
|
|
||||||
if not success then return success, vpos1 end
|
if not success then return success, vpos1 end
|
||||||
|
@ -32,7 +33,7 @@ worldeditadditions_core.register_command("move+", { -- TODO: Make this an overri
|
||||||
parse = function(params_text)
|
parse = function(params_text)
|
||||||
if not params_text then params_text = "" end
|
if not params_text then params_text = "" end
|
||||||
|
|
||||||
local parts = wea.split_shell(params_text)
|
local parts = wea_c.split_shell(params_text)
|
||||||
|
|
||||||
return true, parts
|
return true, parts
|
||||||
end,
|
end,
|
||||||
|
@ -40,7 +41,7 @@ worldeditadditions_core.register_command("move+", { -- TODO: Make this an overri
|
||||||
return worldedit.volume(worldedit.pos1[name], worldedit.pos2[name])
|
return worldedit.volume(worldedit.pos1[name], worldedit.pos2[name])
|
||||||
end,
|
end,
|
||||||
func = function(name, parts)
|
func = function(name, parts)
|
||||||
local start_time = wea.get_ms_time()
|
local start_time = wea_c.get_ms_time()
|
||||||
|
|
||||||
local success_a, copy_offset = parse_stage2(name, parts)
|
local success_a, copy_offset = parse_stage2(name, parts)
|
||||||
if not success_a then return success_a, copy_offset end
|
if not success_a then return success_a, copy_offset end
|
||||||
|
@ -67,10 +68,10 @@ worldeditadditions_core.register_command("move+", { -- TODO: Make this an overri
|
||||||
worldedit.pos2[name] = target_pos2
|
worldedit.pos2[name] = target_pos2
|
||||||
worldedit.marker_update(name)
|
worldedit.marker_update(name)
|
||||||
|
|
||||||
local time_taken = wea.get_ms_time() - start_time
|
local time_taken = wea_c.get_ms_time() - start_time
|
||||||
|
|
||||||
|
|
||||||
minetest.log("action", name.." used //move+ from "..source_pos1.." - "..source_pos2.." to "..target_pos1.." - "..target_pos2..", modifying "..nodes_modified.." nodes in "..wea.format.human_time(time_taken))
|
minetest.log("action", name.." used //move+ from "..source_pos1.." - "..source_pos2.." to "..target_pos1.." - "..target_pos2..", modifying "..nodes_modified.." nodes in "..wea_c.format.human_time(time_taken))
|
||||||
return true, nodes_modified.." nodes moved using offset "..copy_offset.." in "..wea.format.human_time(time_taken)
|
return true, nodes_modified.." nodes moved using offset "..copy_offset.." in "..wea_c.format.human_time(time_taken)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
|
||||||
local wea = worldeditadditions
|
local wea = worldeditadditions
|
||||||
|
local wea_c = worldeditadditions_core
|
||||||
|
local Vector3 = wea_c.Vector3
|
||||||
|
|
||||||
worldeditadditions_core.register_command("noise2d", {
|
worldeditadditions_core.register_command("noise2d", {
|
||||||
params = "[<key_1> [<value_1>]] [<key_2> [<value_2>]] ...]",
|
params = "[<key_1> [<value_1>]] [<key_2> [<value_2>]] ...]",
|
||||||
|
@ -8,28 +10,28 @@ worldeditadditions_core.register_command("noise2d", {
|
||||||
require_pos = 2,
|
require_pos = 2,
|
||||||
parse = function(params_text)
|
parse = function(params_text)
|
||||||
if not params_text then return true, {} end
|
if not params_text then return true, {} end
|
||||||
params_text = wea.trim(params_text)
|
params_text = wea_c.trim(params_text)
|
||||||
if params_text == "" then return true, {} end
|
if params_text == "" then return true, {} end
|
||||||
|
|
||||||
|
|
||||||
local success, map = worldeditadditions.parse.map(params_text,
|
local success, map = wea_c.parse.map(params_text,
|
||||||
wea.noise.engines.available) -- Keywords
|
wea.noise.engines.available) -- Keywords
|
||||||
if not success then return success, map end
|
if not success then return success, map end
|
||||||
|
|
||||||
if map.scale then
|
if map.scale then
|
||||||
map.scale = tonumber(map.scale)
|
map.scale = tonumber(map.scale)
|
||||||
map.scale = wea.Vector3.new(map.scale, map.scale, map.scale)
|
map.scale = Vector3.new(map.scale, map.scale, map.scale)
|
||||||
elseif map.scalex or map.scaley or map.scalez then
|
elseif map.scalex or map.scaley or map.scalez then
|
||||||
map.scalex = tonumber(map.scalex) or 1
|
map.scalex = tonumber(map.scalex) or 1
|
||||||
map.scaley = tonumber(map.scaley) or 1
|
map.scaley = tonumber(map.scaley) or 1
|
||||||
map.scalez = tonumber(map.scalez) or 1
|
map.scalez = tonumber(map.scalez) or 1
|
||||||
map.scale = wea.Vector3.new(map.scalex, map.scaley, map.scalez)
|
map.scale = Vector3.new(map.scalex, map.scaley, map.scalez)
|
||||||
end
|
end
|
||||||
if map.offsetx or map.offsety or map.offsetz then
|
if map.offsetx or map.offsety or map.offsetz then
|
||||||
map.offsetx = tonumber(map.offsetx) or 0
|
map.offsetx = tonumber(map.offsetx) or 0
|
||||||
map.offsety = tonumber(map.offsety) or 0
|
map.offsety = tonumber(map.offsety) or 0
|
||||||
map.offsetz = tonumber(map.offsetz) or 0
|
map.offsetz = tonumber(map.offsetz) or 0
|
||||||
map.offset = wea.Vector3.new(map.offsetx, map.offsety, map.offsetz)
|
map.offset = Vector3.new(map.offsetx, map.offsety, map.offsetz)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true, map
|
return true, map
|
||||||
|
@ -38,15 +40,16 @@ worldeditadditions_core.register_command("noise2d", {
|
||||||
return worldedit.volume(worldedit.pos1[name], worldedit.pos2[name])
|
return worldedit.volume(worldedit.pos1[name], worldedit.pos2[name])
|
||||||
end,
|
end,
|
||||||
func = function(name, params)
|
func = function(name, params)
|
||||||
local start_time = worldeditadditions.get_ms_time()
|
local start_time = wea_c.get_ms_time()
|
||||||
local success, stats = worldeditadditions.noise.run2d(
|
local pos1, pos2 = Vector3.sort(worldedit.pos1[name], worldedit.pos2[name])
|
||||||
worldedit.pos1[name], worldedit.pos2[name],
|
local success, stats = wea.noise.run2d(
|
||||||
|
pos1, pos2,
|
||||||
params
|
params
|
||||||
)
|
)
|
||||||
if not success then return success, stats end
|
if not success then return success, stats end
|
||||||
local time_taken = worldeditadditions.get_ms_time() - start_time
|
local time_taken = wea_c.get_ms_time() - start_time
|
||||||
|
|
||||||
minetest.log("action", name .. " used //noise2d at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. ", adding " .. stats.added .. " nodes and removing " .. stats.removed .. " nodes in " .. time_taken .. "s")
|
minetest.log("action", name .. " used //noise2d at " .. pos1 .. " - "..pos2..", adding " .. stats.added .. " nodes and removing " .. stats.removed .. " nodes in " .. wea_c.format.human_time(time_taken))
|
||||||
return true, stats.added .. " nodes added and " .. stats.removed .. " nodes removed in " .. worldeditadditions.format.human_time(time_taken)
|
return true, stats.added .. " nodes added and " .. stats.removed .. " nodes removed in " .. wea_c.format.human_time(time_taken)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue