mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-30 11:04:00 +01:00
Add optional frame to brush previews
This way, it's easiere to see where the edges are of the preview
This commit is contained in:
parent
d657ce1abe
commit
58d3c1e43b
@ -7,7 +7,8 @@ local make_brush = dofile(wea.modpath.."/lib/sculpt/make_brush.lua")
|
|||||||
-- @param brush_name string The name of the brush to create a preview for.
|
-- @param brush_name string The name of the brush to create a preview for.
|
||||||
-- @param target_size Vector3 The target size of the brush to create. Default: (10, 10, 0).
|
-- @param target_size Vector3 The target size of the brush to create. Default: (10, 10, 0).
|
||||||
-- @returns bool,string If the operation was successful, true followed by a preview of the brush as a string. If the operation was not successful, false and an error message string is returned instead.
|
-- @returns bool,string If the operation was successful, true followed by a preview of the brush as a string. If the operation was not successful, false and an error message string is returned instead.
|
||||||
local function preview_brush(brush_name, target_size)
|
local function preview_brush(brush_name, target_size, framed)
|
||||||
|
if framed == nil then framed = true end
|
||||||
if not target_size then target_size = Vector3.new(10, 10, 0) end
|
if not target_size then target_size = Vector3.new(10, 10, 0) end
|
||||||
local success, brush, brush_size = make_brush(brush_name, target_size)
|
local success, brush, brush_size = make_brush(brush_name, target_size)
|
||||||
|
|
||||||
@ -22,11 +23,14 @@ local function preview_brush(brush_name, target_size)
|
|||||||
values["."] = 1
|
values["."] = 1
|
||||||
values[" "] = 0
|
values[" "] = 0
|
||||||
|
|
||||||
print(wea.inspect(brush))
|
local frame_vertical = "+"..string.rep("-", math.max(0, brush_size.x)).."+"
|
||||||
|
|
||||||
local result = {}
|
local result = {}
|
||||||
|
if framed then table.insert(result, frame_vertical) end
|
||||||
|
|
||||||
for y = brush_size.y-1, 0, -1 do
|
for y = brush_size.y-1, 0, -1 do
|
||||||
local row = {}
|
local row = {}
|
||||||
|
if framed then table.insert(row, "|") end
|
||||||
for x = brush_size.x-1, 0, -1 do
|
for x = brush_size.x-1, 0, -1 do
|
||||||
local i = y*brush_size.x + x
|
local i = y*brush_size.x + x
|
||||||
local pixel = " "
|
local pixel = " "
|
||||||
@ -39,9 +43,13 @@ local function preview_brush(brush_name, target_size)
|
|||||||
end
|
end
|
||||||
table.insert(row, pixel)
|
table.insert(row, pixel)
|
||||||
end
|
end
|
||||||
|
if framed then table.insert(row, "|") end
|
||||||
table.insert(result, table.concat(row))
|
table.insert(result, table.concat(row))
|
||||||
end
|
end
|
||||||
print("RESULT", wea.inspect(result))
|
|
||||||
|
if framed then table.insert(result, frame_vertical) end
|
||||||
|
|
||||||
|
|
||||||
return true, table.concat(result, "\n")
|
return true, table.concat(result, "\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user