pos_marker_wall: add support for customising sides displayed

...it's not exposed in the UI yet tho.
This commit is contained in:
Starbeamrainbowlabs 2023-06-30 02:08:46 +01:00
parent 46587164bd
commit b3f7ae9d7c
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2

@ -117,8 +117,14 @@ end
-- @param player_name string The name of the player that the wall belongs to.
-- @param pos1 Vector3 pos1 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.
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)
local pos1s, pos2s = Vector3.sort(pos1, pos2)
@ -139,6 +145,7 @@ local function create_wall(player_name, pos1, pos2)
-- ██ ██ ██
-- ██ ██
-- First, do positive x
if string.find(sides_to_display, "+x") then
local posx_pos1 = Vector3.new(
math.max(pos1s.x, pos2s.x) + 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
-- ██ ██
-- ██ ██
@ -180,6 +189,7 @@ local function create_wall(player_name, pos1, pos2)
-- ██ ██
-- ██ ██
-- Now, do negative x
if string.find(sides_to_display, "-x") then
local negx_pos1 = Vector3.new(
math.min(pos1s.x, pos2s.x) - 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
-- ██ ██
@ -221,6 +232,7 @@ local function create_wall(player_name, pos1, pos2)
-- ██ ██
-- ██
-- Now, positive y
if string.find(sides_to_display, "+y") then
local posy_pos1 = Vector3.new(
math.min(pos1s.x, pos2s.x) - 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
-- ██ ██
-- ██ ██
-- ██████ ████
-- ██
-- ██
-- Now, negative y
if string.find(sides_to_display, "-y") then
local negy_pos1 = Vector3.new(
math.min(pos1s.x, pos2s.x) - 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
-- ███████
-- ██ ███
-- ██████ ███
-- ██ ███
-- ███████
-- Now, positive z. Almost there!
if string.find(sides_to_display, "+z") then
local posz_pos1 = Vector3.new(
math.min(pos1s.x, pos2s.x) - 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)
end
end
end
-- ███████
-- ███
-- ██████ ███
-- ███
-- ███████
-- Finally, negative z. Last one!
if string.find(sides_to_display, "-z") then
local negz_pos1 = Vector3.new(
math.min(pos1s.x, pos2s.x) - 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
-- 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.