mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 15:33:00 +00:00
//sculpt: put height at the end
This commit is contained in:
parent
2756eb0eb5
commit
f5e2ada5bd
3 changed files with 16 additions and 15 deletions
|
@ -11,7 +11,7 @@ Note to self: See the bottom of this file for the release template text.
|
||||||
- `//sculpt`:
|
- `//sculpt`:
|
||||||
- Fix undefined `default` brush
|
- Fix undefined `default` brush
|
||||||
- Change defaults to `circle`, `height=1`, and `brushsize=8`.
|
- Change defaults to `circle`, `height=1`, and `brushsize=8`.
|
||||||
- **TODO:** change ordering to put `height` after `brushsize` instead of the other way around
|
- Change argument ordering to put `height` after `brushsize` instead of the other way around
|
||||||
- Commands that modify the terrain now ignore liquids
|
- Commands that modify the terrain now ignore liquids
|
||||||
- `//hollow`: Fix safe region bug
|
- `//hollow`: Fix safe region bug
|
||||||
- Significant backend refactoring to tidy things up
|
- Significant backend refactoring to tidy things up
|
||||||
|
|
|
@ -5,10 +5,10 @@ local Vector3 = wea_c.Vector3
|
||||||
--- Applies the given brush with the given height and size to the given position.
|
--- Applies the given brush with the given height and size to the given position.
|
||||||
-- @param pos1 Vector3 The position at which to apply the brush.
|
-- @param pos1 Vector3 The position at which to apply the brush.
|
||||||
-- @param brush_name string The name of the brush to apply.
|
-- @param brush_name string The name of the brush to apply.
|
||||||
-- @param height number The height of the brush application.
|
|
||||||
-- @param brush_size Vector3 The size of the brush application. Values are interpreted on the X/Y coordinates, and NOT X/Z!
|
-- @param brush_size Vector3 The size of the brush application. Values are interpreted on the X/Y coordinates, and NOT X/Z!
|
||||||
|
-- @param height number The height of the brush application.
|
||||||
-- @returns bool, string|{ added: number, removed: number } A bool indicating whether the operation was successful or not, followed by either an error message as a string (if it was not successful) or a table of statistics (if it was successful).
|
-- @returns bool, string|{ added: number, removed: number } A bool indicating whether the operation was successful or not, followed by either an error message as a string (if it was not successful) or a table of statistics (if it was successful).
|
||||||
local function apply(pos1, brush_name, height, brush_size)
|
local function apply(pos1, brush_name, brush_size, height)
|
||||||
-- 1: Get & validate brush
|
-- 1: Get & validate brush
|
||||||
local success, brush, brush_size_actual = wea.sculpt.make_brush(brush_name, brush_size)
|
local success, brush, brush_size_actual = wea.sculpt.make_brush(brush_name, brush_size)
|
||||||
if not success then return success, brush end
|
if not success then return success, brush end
|
||||||
|
|
|
@ -9,7 +9,7 @@ local Vector3 = wea_c.Vector3
|
||||||
-- ██ ██ ██ ██ ██ ██ ██
|
-- ██ ██ ██ ██ ██ ██ ██
|
||||||
-- ███████ ██████ ██████ ███████ ██ ██
|
-- ███████ ██████ ██████ ███████ ██ ██
|
||||||
worldeditadditions_core.register_command("sculpt", {
|
worldeditadditions_core.register_command("sculpt", {
|
||||||
params = "[<brush_name=default> [<height=1> [<brush_size=8>]]]",
|
params = "[<brush_name=default> [<brush_size=8> [<height=1>]]]",
|
||||||
description = "Applies a sculpting brush to the terrain with a given height. See //sculptlist to list all available brushes. Note that while the brush size is configurable, the actual brush size you end up with may be slightly different to that which you request due to brush size restrictions.",
|
description = "Applies a sculpting brush to the terrain with a given height. See //sculptlist to list all available brushes. Note that while the brush size is configurable, the actual brush size you end up with may be slightly different to that which you request due to brush size restrictions.",
|
||||||
privs = { worldedit = true },
|
privs = { worldedit = true },
|
||||||
require_pos = 1,
|
require_pos = 1,
|
||||||
|
@ -21,8 +21,8 @@ worldeditadditions_core.register_command("sculpt", {
|
||||||
local parts = wea_c.split_shell(params_text)
|
local parts = wea_c.split_shell(params_text)
|
||||||
|
|
||||||
local brush_name = "circle"
|
local brush_name = "circle"
|
||||||
local height = 1
|
|
||||||
local brush_size = 8
|
local brush_size = 8
|
||||||
|
local height = 1
|
||||||
|
|
||||||
if #parts >= 1 then
|
if #parts >= 1 then
|
||||||
brush_name = table.remove(parts, 1)
|
brush_name = table.remove(parts, 1)
|
||||||
|
@ -30,24 +30,25 @@ worldeditadditions_core.register_command("sculpt", {
|
||||||
return false, "A brush with the name '"..brush_name.."' doesn't exist. Try using //sculptlist to list all available brushes."
|
return false, "A brush with the name '"..brush_name.."' doesn't exist. Try using //sculptlist to list all available brushes."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #parts >= 1 then
|
|
||||||
height = tonumber(table.remove(parts, 1))
|
|
||||||
if not height then
|
|
||||||
return false, "Invalid height value (must be an integer - negative values lower terrain instead of raising it)"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if #parts >= 1 then
|
if #parts >= 1 then
|
||||||
brush_size = tonumber(table.remove(parts, 1))
|
brush_size = tonumber(table.remove(parts, 1))
|
||||||
if not brush_size or brush_size < 1 then
|
if not brush_size or brush_size < 1 then
|
||||||
return false, "Invalid brush size. Brush sizes must be a positive integer."
|
return false, "Invalid brush size. Brush sizes must be a positive integer."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if #parts >= 1 then
|
||||||
|
height = tonumber(table.remove(parts, 1))
|
||||||
|
if not height then
|
||||||
|
return false,
|
||||||
|
"Invalid height value (must be an integer - negative values lower terrain instead of raising it)"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
brush_size = Vector3.new(brush_size, brush_size, 0):floor()
|
brush_size = Vector3.new(brush_size, brush_size, 0):floor()
|
||||||
|
|
||||||
return true, brush_name, math.floor(height), brush_size
|
return true, brush_name, brush_size, math.floor(height)
|
||||||
end,
|
end,
|
||||||
nodes_needed = function(name, brush_name, height, brush_size)
|
nodes_needed = function(name, brush_name, brush_size, height)
|
||||||
local success, brush, size_actual = wea.sculpt.make_brush(brush_name, brush_size)
|
local success, brush, size_actual = wea.sculpt.make_brush(brush_name, brush_size)
|
||||||
if not success then return 0 end
|
if not success then return 0 end
|
||||||
|
|
||||||
|
@ -60,13 +61,13 @@ worldeditadditions_core.register_command("sculpt", {
|
||||||
|
|
||||||
return size_actual.x * size_actual.y * range_nodes
|
return size_actual.x * size_actual.y * range_nodes
|
||||||
end,
|
end,
|
||||||
func = function(name, brush_name, height, brush_size)
|
func = function(name, brush_name, brush_size, height)
|
||||||
local start_time = wea_c.get_ms_time()
|
local start_time = wea_c.get_ms_time()
|
||||||
|
|
||||||
local pos1 = wea_c.Vector3.clone(worldedit.pos1[name])
|
local pos1 = wea_c.Vector3.clone(worldedit.pos1[name])
|
||||||
local success, stats = wea.sculpt.apply(
|
local success, stats = wea.sculpt.apply(
|
||||||
pos1,
|
pos1,
|
||||||
brush_name, height, brush_size
|
brush_name, brush_size, height
|
||||||
)
|
)
|
||||||
if not success then return success, stats.added end
|
if not success then return success, stats.added end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue