mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 07:23:00 +00:00
pos_marker_wall: add support for customising sides displayed
...it's not exposed in the UI yet tho.
This commit is contained in:
parent
46587164bd
commit
b3f7ae9d7c
1 changed files with 196 additions and 172 deletions
|
@ -117,8 +117,14 @@ end
|
||||||
-- @param player_name string The name of the player that the wall belongs to.
|
-- @param player_name string The name of the player that the wall belongs to.
|
||||||
-- @param pos1 Vector3 pos1 of the defined region.
|
-- @param pos1 Vector3 pos1 of the defined region.
|
||||||
-- @param pos2 Vector3 pos2 of the defined region.
|
-- @param pos2 Vector3 pos2 of the defined region.
|
||||||
|
-- @param sides_to_display string The sides of the marker wall that should actually be displayed, squished together into a single string. Defaults to "+x-x+z-z". Use "+x-x+z-z+y-y" to display all sides; add and remove sides as desired.
|
||||||
-- @returns table<entitylist> A list of all created entities.
|
-- @returns table<entitylist> A list of all created entities.
|
||||||
local function create_wall(player_name, pos1, pos2)
|
local function create_wall(player_name, pos1, pos2, sides_to_display)
|
||||||
|
if not sides_to_display then
|
||||||
|
sides_to_display = "+x-x+z-z" -- this matches WorldEdit
|
||||||
|
-- To display all of them:
|
||||||
|
-- sides_to_display = "+x-x+z-z+y-y"
|
||||||
|
end
|
||||||
print("DEBUG:marker_wall create_wall --> START player_name", player_name, "pos1", pos1, "pos2", pos2)
|
print("DEBUG:marker_wall create_wall --> START player_name", player_name, "pos1", pos1, "pos2", pos2)
|
||||||
local pos1s, pos2s = Vector3.sort(pos1, pos2)
|
local pos1s, pos2s = Vector3.sort(pos1, pos2)
|
||||||
|
|
||||||
|
@ -139,38 +145,41 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
-- ██ ██ ██
|
-- ██ ██ ██
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
-- First, do positive x
|
-- First, do positive x
|
||||||
local posx_pos1 = Vector3.new(
|
if string.find(sides_to_display, "+x") then
|
||||||
math.max(pos1s.x, pos2s.x) + 0.5,
|
local posx_pos1 = Vector3.new(
|
||||||
math.min(pos1s.y, pos2s.y) - 0.5,
|
math.max(pos1s.x, pos2s.x) + 0.5,
|
||||||
math.min(pos1s.z, pos2s.z) - 0.5
|
math.min(pos1s.y, pos2s.y) - 0.5,
|
||||||
)
|
math.min(pos1s.z, pos2s.z) - 0.5
|
||||||
local posx_pos2 = Vector3.new(
|
)
|
||||||
math.max(pos1s.x, pos2s.x) + 0.5,
|
local posx_pos2 = Vector3.new(
|
||||||
math.max(pos1s.y, pos2s.y) + 0.5,
|
math.max(pos1s.x, pos2s.x) + 0.5,
|
||||||
math.max(pos1s.z, pos2s.z) + 0.5
|
math.max(pos1s.y, pos2s.y) + 0.5,
|
||||||
)
|
math.max(pos1s.z, pos2s.z) + 0.5
|
||||||
|
)
|
||||||
|
|
||||||
print("DEBUG ************ +X pos1", posx_pos1, "pos2", posx_pos2)
|
print("DEBUG ************ +X pos1", posx_pos1, "pos2", posx_pos2)
|
||||||
|
|
||||||
for z = posx_pos2.z, posx_pos1.z, -entity_wall_size do
|
for z = posx_pos2.z, posx_pos1.z, -entity_wall_size do
|
||||||
for y = posx_pos2.y, posx_pos1.y, -entity_wall_size do
|
for y = posx_pos2.y, posx_pos1.y, -entity_wall_size do
|
||||||
local single_pos1 = Vector3.new(
|
local single_pos1 = Vector3.new(
|
||||||
posx_pos1.x,
|
posx_pos1.x,
|
||||||
y,
|
y,
|
||||||
z
|
z
|
||||||
)
|
)
|
||||||
local single_pos2 = Vector3.new(
|
local single_pos2 = Vector3.new(
|
||||||
posx_pos1.x,
|
posx_pos1.x,
|
||||||
math.max(y - entity_wall_size, posx_pos1.y),
|
math.max(y - entity_wall_size, posx_pos1.y),
|
||||||
math.max(z - entity_wall_size, posx_pos1.z)
|
math.max(z - entity_wall_size, posx_pos1.z)
|
||||||
)
|
)
|
||||||
|
|
||||||
local entity = create_single(player_name,
|
local entity = create_single(player_name,
|
||||||
single_pos1, single_pos2,
|
single_pos1, single_pos2,
|
||||||
"x"
|
"x"
|
||||||
)
|
)
|
||||||
table.insert(entities, entity)
|
table.insert(entities, entity)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,39 +189,41 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
-- Now, do negative x
|
-- Now, do negative x
|
||||||
local negx_pos1 = Vector3.new(
|
if string.find(sides_to_display, "-x") then
|
||||||
math.min(pos1s.x, pos2s.x) - 0.5,
|
local negx_pos1 = Vector3.new(
|
||||||
math.min(pos1s.y, pos2s.y) - 0.5,
|
math.min(pos1s.x, pos2s.x) - 0.5,
|
||||||
math.min(pos1s.z, pos2s.z) - 0.5
|
math.min(pos1s.y, pos2s.y) - 0.5,
|
||||||
)
|
math.min(pos1s.z, pos2s.z) - 0.5
|
||||||
local negx_pos2 = Vector3.new(
|
)
|
||||||
math.min(pos1s.x, pos2s.x) - 0.5,
|
local negx_pos2 = Vector3.new(
|
||||||
math.max(pos1s.y, pos2s.y) + 0.5,
|
math.min(pos1s.x, pos2s.x) - 0.5,
|
||||||
math.max(pos1s.z, pos2s.z) + 0.5
|
math.max(pos1s.y, pos2s.y) + 0.5,
|
||||||
)
|
math.max(pos1s.z, pos2s.z) + 0.5
|
||||||
print("DEBUG ************ -X pos1", negx_pos1, "pos2", negx_pos2)
|
)
|
||||||
|
print("DEBUG ************ -X pos1", negx_pos1, "pos2", negx_pos2)
|
||||||
|
|
||||||
for z = negx_pos2.z, negx_pos1.z, -entity_wall_size do
|
for z = negx_pos2.z, negx_pos1.z, -entity_wall_size do
|
||||||
for y = negx_pos2.y, negx_pos1.y, -entity_wall_size do
|
for y = negx_pos2.y, negx_pos1.y, -entity_wall_size do
|
||||||
local single_pos1 = Vector3.new(
|
local single_pos1 = Vector3.new(
|
||||||
negx_pos1.x,
|
negx_pos1.x,
|
||||||
y,
|
y,
|
||||||
z
|
z
|
||||||
)
|
)
|
||||||
local single_pos2 = Vector3.new(
|
local single_pos2 = Vector3.new(
|
||||||
negx_pos1.x,
|
negx_pos1.x,
|
||||||
math.max(y - entity_wall_size, negx_pos1.y),
|
math.max(y - entity_wall_size, negx_pos1.y),
|
||||||
math.max(z - entity_wall_size, negx_pos1.z)
|
math.max(z - entity_wall_size, negx_pos1.z)
|
||||||
)
|
)
|
||||||
|
|
||||||
local entity = create_single(player_name,
|
local entity = create_single(player_name,
|
||||||
single_pos1, single_pos2,
|
single_pos1, single_pos2,
|
||||||
"-x"
|
"-x"
|
||||||
)
|
)
|
||||||
table.insert(entities, entity)
|
table.insert(entities, entity)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
|
@ -221,38 +232,41 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
-- ██
|
-- ██
|
||||||
-- Now, positive y
|
-- Now, positive y
|
||||||
local posy_pos1 = Vector3.new(
|
if string.find(sides_to_display, "+y") then
|
||||||
math.min(pos1s.x, pos2s.x) - 0.5,
|
local posy_pos1 = Vector3.new(
|
||||||
math.max(pos1s.y, pos2s.y) + 0.5,
|
math.min(pos1s.x, pos2s.x) - 0.5,
|
||||||
math.min(pos1s.z, pos2s.z) - 0.5
|
math.max(pos1s.y, pos2s.y) + 0.5,
|
||||||
)
|
math.min(pos1s.z, pos2s.z) - 0.5
|
||||||
local posy_pos2 = Vector3.new(
|
)
|
||||||
math.max(pos1s.x, pos2s.x) + 0.5,
|
local posy_pos2 = Vector3.new(
|
||||||
math.max(pos1s.y, pos2s.y) + 0.5,
|
math.max(pos1s.x, pos2s.x) + 0.5,
|
||||||
math.max(pos1s.z, pos2s.z) + 0.5
|
math.max(pos1s.y, pos2s.y) + 0.5,
|
||||||
)
|
math.max(pos1s.z, pos2s.z) + 0.5
|
||||||
|
)
|
||||||
|
|
||||||
print("DEBUG ************ +Y pos1", posy_pos1, "pos2", posy_pos2)
|
print("DEBUG ************ +Y pos1", posy_pos1, "pos2", posy_pos2)
|
||||||
|
|
||||||
for z = posy_pos2.z, posy_pos1.z, -entity_wall_size do
|
for z = posy_pos2.z, posy_pos1.z, -entity_wall_size do
|
||||||
for x = posy_pos2.x, posy_pos1.x, -entity_wall_size do
|
for x = posy_pos2.x, posy_pos1.x, -entity_wall_size do
|
||||||
local single_pos1 = Vector3.new(
|
local single_pos1 = Vector3.new(
|
||||||
x,
|
x,
|
||||||
posy_pos1.y,
|
posy_pos1.y,
|
||||||
z
|
z
|
||||||
)
|
)
|
||||||
local single_pos2 = Vector3.new(
|
local single_pos2 = Vector3.new(
|
||||||
math.max(x - entity_wall_size, posy_pos1.x),
|
math.max(x - entity_wall_size, posy_pos1.x),
|
||||||
posy_pos1.y,
|
posy_pos1.y,
|
||||||
math.max(z - entity_wall_size, posy_pos1.z)
|
math.max(z - entity_wall_size, posy_pos1.z)
|
||||||
)
|
)
|
||||||
|
|
||||||
local entity = create_single(player_name,
|
local entity = create_single(player_name,
|
||||||
single_pos1, single_pos2,
|
single_pos1, single_pos2,
|
||||||
"y"
|
"y"
|
||||||
)
|
)
|
||||||
table.insert(entities, entity)
|
table.insert(entities, entity)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
|
@ -261,38 +275,41 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
-- ██
|
-- ██
|
||||||
-- ██
|
-- ██
|
||||||
-- Now, negative y
|
-- Now, negative y
|
||||||
local negy_pos1 = Vector3.new(
|
if string.find(sides_to_display, "-y") then
|
||||||
math.min(pos1s.x, pos2s.x) - 0.5,
|
local negy_pos1 = Vector3.new(
|
||||||
math.min(pos1s.y, pos2s.y) - 0.5,
|
math.min(pos1s.x, pos2s.x) - 0.5,
|
||||||
math.min(pos1s.z, pos2s.z) - 0.5
|
math.min(pos1s.y, pos2s.y) - 0.5,
|
||||||
)
|
math.min(pos1s.z, pos2s.z) - 0.5
|
||||||
local negy_pos2 = Vector3.new(
|
)
|
||||||
math.max(pos1s.x, pos2s.x) + 0.5,
|
local negy_pos2 = Vector3.new(
|
||||||
math.min(pos1s.y, pos2s.y) - 0.5,
|
math.max(pos1s.x, pos2s.x) + 0.5,
|
||||||
math.max(pos1s.z, pos2s.z) + 0.5
|
math.min(pos1s.y, pos2s.y) - 0.5,
|
||||||
)
|
math.max(pos1s.z, pos2s.z) + 0.5
|
||||||
|
)
|
||||||
|
|
||||||
print("DEBUG ************ -Y pos1", negy_pos1, "pos2", negy_pos2)
|
print("DEBUG ************ -Y pos1", negy_pos1, "pos2", negy_pos2)
|
||||||
|
|
||||||
for z = negy_pos2.z, negy_pos1.z, -entity_wall_size do
|
for z = negy_pos2.z, negy_pos1.z, -entity_wall_size do
|
||||||
for x = negy_pos2.x, negy_pos1.x, -entity_wall_size do
|
for x = negy_pos2.x, negy_pos1.x, -entity_wall_size do
|
||||||
local single_pos1 = Vector3.new(
|
local single_pos1 = Vector3.new(
|
||||||
x,
|
x,
|
||||||
negy_pos1.y,
|
negy_pos1.y,
|
||||||
z
|
z
|
||||||
)
|
)
|
||||||
local single_pos2 = Vector3.new(
|
local single_pos2 = Vector3.new(
|
||||||
math.max(x - entity_wall_size, negy_pos1.x),
|
math.max(x - entity_wall_size, negy_pos1.x),
|
||||||
negy_pos1.y,
|
negy_pos1.y,
|
||||||
math.max(z - entity_wall_size, negy_pos1.z)
|
math.max(z - entity_wall_size, negy_pos1.z)
|
||||||
)
|
)
|
||||||
|
|
||||||
local entity = create_single(player_name,
|
local entity = create_single(player_name,
|
||||||
single_pos1, single_pos2,
|
single_pos1, single_pos2,
|
||||||
"-y"
|
"-y"
|
||||||
)
|
)
|
||||||
table.insert(entities, entity)
|
table.insert(entities, entity)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ███████
|
-- ███████
|
||||||
|
@ -301,79 +318,86 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
-- ██ ███
|
-- ██ ███
|
||||||
-- ███████
|
-- ███████
|
||||||
-- Now, positive z. Almost there!
|
-- Now, positive z. Almost there!
|
||||||
local posz_pos1 = Vector3.new(
|
if string.find(sides_to_display, "+z") then
|
||||||
math.min(pos1s.x, pos2s.x) - 0.5,
|
local posz_pos1 = Vector3.new(
|
||||||
math.min(pos1s.y, pos2s.y) - 0.5,
|
math.min(pos1s.x, pos2s.x) - 0.5,
|
||||||
math.max(pos1s.z, pos2s.z) + 0.5
|
math.min(pos1s.y, pos2s.y) - 0.5,
|
||||||
)
|
math.max(pos1s.z, pos2s.z) + 0.5
|
||||||
local posz_pos2 = Vector3.new(
|
)
|
||||||
math.max(pos1s.x, pos2s.x) + 0.5,
|
local posz_pos2 = Vector3.new(
|
||||||
math.max(pos1s.y, pos2s.y) + 0.5,
|
math.max(pos1s.x, pos2s.x) + 0.5,
|
||||||
math.max(pos1s.z, pos2s.z) + 0.5
|
math.max(pos1s.y, pos2s.y) + 0.5,
|
||||||
)
|
math.max(pos1s.z, pos2s.z) + 0.5
|
||||||
|
)
|
||||||
|
|
||||||
print("DEBUG ************ +Z pos1", posz_pos1, "pos2", posz_pos2)
|
print("DEBUG ************ +Z pos1", posz_pos1, "pos2", posz_pos2)
|
||||||
|
|
||||||
for x = posz_pos2.x, posz_pos1.x, -entity_wall_size do
|
for x = posz_pos2.x, posz_pos1.x, -entity_wall_size do
|
||||||
for y = posz_pos2.y, posz_pos1.y, -entity_wall_size do
|
for y = posz_pos2.y, posz_pos1.y, -entity_wall_size do
|
||||||
local single_pos1 = Vector3.new(
|
local single_pos1 = Vector3.new(
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
posz_pos1.z
|
posz_pos1.z
|
||||||
)
|
)
|
||||||
local single_pos2 = Vector3.new(
|
local single_pos2 = Vector3.new(
|
||||||
math.max(x - entity_wall_size, posz_pos1.x),
|
math.max(x - entity_wall_size, posz_pos1.x),
|
||||||
math.max(y - entity_wall_size, posz_pos1.y),
|
math.max(y - entity_wall_size, posz_pos1.y),
|
||||||
posz_pos1.z
|
posz_pos1.z
|
||||||
)
|
)
|
||||||
|
|
||||||
local entity = create_single(player_name,
|
local entity = create_single(player_name,
|
||||||
single_pos1, single_pos2,
|
single_pos1, single_pos2,
|
||||||
"z"
|
"z"
|
||||||
)
|
)
|
||||||
table.insert(entities, entity)
|
table.insert(entities, entity)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- ███████
|
-- ███████
|
||||||
-- ███
|
-- ███
|
||||||
-- ██████ ███
|
-- ██████ ███
|
||||||
-- ███
|
-- ███
|
||||||
-- ███████
|
-- ███████
|
||||||
-- Finally, negative z. Last one!
|
-- Finally, negative z. Last one!
|
||||||
local negz_pos1 = Vector3.new(
|
if string.find(sides_to_display, "-z") then
|
||||||
math.min(pos1s.x, pos2s.x) - 0.5,
|
local negz_pos1 = Vector3.new(
|
||||||
math.min(pos1s.y, pos2s.y) - 0.5,
|
math.min(pos1s.x, pos2s.x) - 0.5,
|
||||||
math.min(pos1s.z, pos2s.z) - 0.5
|
math.min(pos1s.y, pos2s.y) - 0.5,
|
||||||
)
|
math.min(pos1s.z, pos2s.z) - 0.5
|
||||||
local negz_pos2 = Vector3.new(
|
)
|
||||||
math.max(pos1s.x, pos2s.x) + 0.5,
|
local negz_pos2 = Vector3.new(
|
||||||
math.max(pos1s.y, pos2s.y) + 0.5,
|
math.max(pos1s.x, pos2s.x) + 0.5,
|
||||||
math.min(pos1s.z, pos2s.z) - 0.5
|
math.max(pos1s.y, pos2s.y) + 0.5,
|
||||||
)
|
math.min(pos1s.z, pos2s.z) - 0.5
|
||||||
|
)
|
||||||
|
|
||||||
print("DEBUG ************ -Z pos1", negz_pos1, "pos2", negz_pos2)
|
print("DEBUG ************ -Z pos1", negz_pos1, "pos2", negz_pos2)
|
||||||
|
|
||||||
for x = negz_pos2.x, negz_pos1.x, -entity_wall_size do
|
for x = negz_pos2.x, negz_pos1.x, -entity_wall_size do
|
||||||
for y = negz_pos2.y, negz_pos1.y, -entity_wall_size do
|
for y = negz_pos2.y, negz_pos1.y, -entity_wall_size do
|
||||||
local single_pos1 = Vector3.new(
|
local single_pos1 = Vector3.new(
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
negz_pos1.z
|
negz_pos1.z
|
||||||
)
|
)
|
||||||
local single_pos2 = Vector3.new(
|
local single_pos2 = Vector3.new(
|
||||||
math.max(x - entity_wall_size, negz_pos1.x),
|
math.max(x - entity_wall_size, negz_pos1.x),
|
||||||
math.max(y - entity_wall_size, negz_pos1.y),
|
math.max(y - entity_wall_size, negz_pos1.y),
|
||||||
negz_pos1.z
|
negz_pos1.z
|
||||||
)
|
)
|
||||||
|
|
||||||
local entity = create_single(player_name,
|
local entity = create_single(player_name,
|
||||||
single_pos1, single_pos2,
|
single_pos1, single_pos2,
|
||||||
"-z"
|
"-z"
|
||||||
)
|
)
|
||||||
table.insert(entities, entity)
|
table.insert(entities, entity)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- TODO: All the other sides. For testing we're doing 1 side for now, so we can vaoid having to do everything all over again if we make a mistake.
|
-- TODO: All the other sides. For testing we're doing 1 side for now, so we can vaoid having to do everything all over again if we make a mistake.
|
||||||
|
|
Loading…
Reference in a new issue