mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-25 16:43:05 +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,6 +145,7 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
-- ██ ██ ██
|
-- ██ ██ ██
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
-- First, do positive x
|
-- First, do positive x
|
||||||
|
if string.find(sides_to_display, "+x") then
|
||||||
local posx_pos1 = Vector3.new(
|
local posx_pos1 = Vector3.new(
|
||||||
math.max(pos1s.x, pos2s.x) + 0.5,
|
math.max(pos1s.x, pos2s.x) + 0.5,
|
||||||
math.min(pos1s.y, pos2s.y) - 0.5,
|
math.min(pos1s.y, pos2s.y) - 0.5,
|
||||||
|
@ -173,6 +180,8 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
|
@ -180,6 +189,7 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
-- Now, do negative x
|
-- Now, do negative x
|
||||||
|
if string.find(sides_to_display, "-x") then
|
||||||
local negx_pos1 = Vector3.new(
|
local negx_pos1 = Vector3.new(
|
||||||
math.min(pos1s.x, pos2s.x) - 0.5,
|
math.min(pos1s.x, pos2s.x) - 0.5,
|
||||||
math.min(pos1s.y, pos2s.y) - 0.5,
|
math.min(pos1s.y, pos2s.y) - 0.5,
|
||||||
|
@ -213,6 +223,7 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
|
@ -221,6 +232,7 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
-- ██
|
-- ██
|
||||||
-- Now, positive y
|
-- Now, positive y
|
||||||
|
if string.find(sides_to_display, "+y") then
|
||||||
local posy_pos1 = Vector3.new(
|
local posy_pos1 = Vector3.new(
|
||||||
math.min(pos1s.x, pos2s.x) - 0.5,
|
math.min(pos1s.x, pos2s.x) - 0.5,
|
||||||
math.max(pos1s.y, pos2s.y) + 0.5,
|
math.max(pos1s.y, pos2s.y) + 0.5,
|
||||||
|
@ -255,12 +267,15 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
-- ██ ██
|
-- ██ ██
|
||||||
-- ██████ ████
|
-- ██████ ████
|
||||||
-- ██
|
-- ██
|
||||||
-- ██
|
-- ██
|
||||||
-- Now, negative y
|
-- Now, negative y
|
||||||
|
if string.find(sides_to_display, "-y") then
|
||||||
local negy_pos1 = Vector3.new(
|
local negy_pos1 = Vector3.new(
|
||||||
math.min(pos1s.x, pos2s.x) - 0.5,
|
math.min(pos1s.x, pos2s.x) - 0.5,
|
||||||
math.min(pos1s.y, pos2s.y) - 0.5,
|
math.min(pos1s.y, pos2s.y) - 0.5,
|
||||||
|
@ -295,12 +310,15 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-- ███████
|
-- ███████
|
||||||
-- ██ ███
|
-- ██ ███
|
||||||
-- ██████ ███
|
-- ██████ ███
|
||||||
-- ██ ███
|
-- ██ ███
|
||||||
-- ███████
|
-- ███████
|
||||||
-- Now, positive z. Almost there!
|
-- Now, positive z. Almost there!
|
||||||
|
if string.find(sides_to_display, "+z") then
|
||||||
local posz_pos1 = Vector3.new(
|
local posz_pos1 = Vector3.new(
|
||||||
math.min(pos1s.x, pos2s.x) - 0.5,
|
math.min(pos1s.x, pos2s.x) - 0.5,
|
||||||
math.min(pos1s.y, pos2s.y) - 0.5,
|
math.min(pos1s.y, pos2s.y) - 0.5,
|
||||||
|
@ -334,12 +352,17 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
table.insert(entities, entity)
|
table.insert(entities, entity)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- ███████
|
-- ███████
|
||||||
-- ███
|
-- ███
|
||||||
-- ██████ ███
|
-- ██████ ███
|
||||||
-- ███
|
-- ███
|
||||||
-- ███████
|
-- ███████
|
||||||
-- Finally, negative z. Last one!
|
-- Finally, negative z. Last one!
|
||||||
|
if string.find(sides_to_display, "-z") then
|
||||||
local negz_pos1 = Vector3.new(
|
local negz_pos1 = Vector3.new(
|
||||||
math.min(pos1s.x, pos2s.x) - 0.5,
|
math.min(pos1s.x, pos2s.x) - 0.5,
|
||||||
math.min(pos1s.y, pos2s.y) - 0.5,
|
math.min(pos1s.y, pos2s.y) - 0.5,
|
||||||
|
@ -374,6 +397,7 @@ local function create_wall(player_name, pos1, pos2)
|
||||||
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