mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-08-20 13:34:05 +02:00
wall markers: it shouldn't work, but it does
....I'll take it!
This commit is contained in:
parent
c622fb554f
commit
a173edfbc4
@ -47,11 +47,13 @@ minetest.register_entity(
|
||||
--- Updates the properties of a single wall to match it's side and size
|
||||
local function single_setup(entity, size, side)
|
||||
local new_props = {
|
||||
visual_size = {
|
||||
x = math.min(10, math.abs(size.x)+1),
|
||||
y = math.min(10, math.abs(size.y)+1),
|
||||
z = math.min(10, math.abs(size.z)+1)
|
||||
}
|
||||
visual_size = Vector3.min(
|
||||
Vector3.new(10, 10, 10),
|
||||
size:abs()
|
||||
)
|
||||
-- x = math.min(10, math.abs(size.x)),
|
||||
-- y = math.min(10, math.abs(size.y)),
|
||||
-- z = math.min(10, math.abs(size.z))
|
||||
}
|
||||
|
||||
local cthick = Vector3.new(
|
||||
@ -63,7 +65,9 @@ local function single_setup(entity, size, side)
|
||||
local cpos2 = Vector3.clone(new_props.visual_size):divide(2):subtract(cthick)
|
||||
|
||||
if side == "x" or side == "-x" then
|
||||
new_props.visual_size.x = collision_thickness - 0.1
|
||||
new_props.visual_size = new_props.visual_size + Vector3.new(
|
||||
collision_thickness - 0.1
|
||||
)
|
||||
cpos1.x = -collision_thickness
|
||||
cpos2.x = collision_thickness
|
||||
end
|
||||
@ -83,7 +87,7 @@ local function single_setup(entity, size, side)
|
||||
cpos2.x, cpos2.y, cpos2.z
|
||||
}
|
||||
|
||||
print("DEBUG:marker_wall setup_single new_props", wea_c.inspect(new_props))
|
||||
print("DEBUG:setup_single size", size, "side", side, "new_props", wea_c.inspect(new_props))
|
||||
|
||||
entity:set_properties(new_props)
|
||||
end
|
||||
@ -95,7 +99,6 @@ end
|
||||
-- @param side string The side that this wall is on. Valid values: x, -x, y, -y, z, -z.
|
||||
-- @returns Entity<WEAPositionMarkerWall>
|
||||
local function create_single(player_name, pos1, pos2, side)
|
||||
print("DEBUG:marker_wall create_single --> START player_name", player_name, "pos1", pos1, "pos2", pos2, "side", side)
|
||||
|
||||
local offset = Vector3.new()
|
||||
if side == "x" then offset.x = 0.5
|
||||
@ -107,7 +110,7 @@ local function create_single(player_name, pos1, pos2, side)
|
||||
|
||||
local pos_centre = ((pos2 - pos1) / 2) + pos1 + offset
|
||||
local entity = minetest.add_entity(pos_centre, "worldeditadditions:marker_wall")
|
||||
print("DEBUG:marker_wall create_single --> spawned at", pos_centre)
|
||||
print("DEBUG:marker_wall create_single --> START player_name", player_name, "pos1", pos1, "pos2", pos2, "side", side, "SPAWN", pos_centre)
|
||||
|
||||
entity:get_luaentity().player_name = player_name
|
||||
|
||||
@ -142,19 +145,20 @@ local function create_wall(player_name, pos1, pos2)
|
||||
-- ██████ ███
|
||||
-- ██ ██ ██
|
||||
-- ██ ██
|
||||
|
||||
-- First, do positive x
|
||||
local posx_pos1 = Vector3.new(
|
||||
math.max(pos1s.x, pos2s.x),
|
||||
math.min(pos1s.y, pos2s.y),
|
||||
math.min(pos1s.z, pos2s.z)
|
||||
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),
|
||||
math.max(pos1s.y, pos2s.y),
|
||||
math.max(pos1s.z, pos2s.z)
|
||||
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)
|
||||
|
||||
for z = posx_pos2.z, posx_pos1.z, -entity_wall_size do
|
||||
for y = posx_pos2.y, posx_pos1.y, -entity_wall_size do
|
||||
local single_pos1 = Vector3.new(
|
||||
@ -167,13 +171,56 @@ local function create_wall(player_name, pos1, pos2)
|
||||
math.max(y - entity_wall_size, posx_pos1.y),
|
||||
math.max(z - entity_wall_size, posx_pos1.z)
|
||||
)
|
||||
|
||||
local entity = create_single(player_name, single_pos1, single_pos2, "x")
|
||||
|
||||
local entity = create_single(player_name,
|
||||
single_pos1, single_pos2,
|
||||
"x"
|
||||
)
|
||||
table.insert(entities, entity)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- ██ ██
|
||||
-- ██ ██
|
||||
-- ██████ ███
|
||||
-- ██ ██
|
||||
-- ██ ██
|
||||
-- Now, do negative x
|
||||
local negx_pos1 = Vector3.new(
|
||||
math.min(pos1s.x, pos2s.x),
|
||||
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),
|
||||
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)
|
||||
|
||||
for z = negx_pos2.z, negx_pos1.z, -entity_wall_size do
|
||||
for y = negx_pos2.y, negx_pos1.y, -entity_wall_size do
|
||||
local single_pos1 = Vector3.new(
|
||||
negx_pos1.x,
|
||||
y,
|
||||
z
|
||||
)
|
||||
local single_pos2 = Vector3.new(
|
||||
negx_pos1.x,
|
||||
math.max(y - entity_wall_size, negx_pos1.y),
|
||||
math.max(z - entity_wall_size, negx_pos1.z)
|
||||
)
|
||||
|
||||
local entity = create_single(player_name,
|
||||
single_pos1, single_pos2,
|
||||
"-x"
|
||||
)
|
||||
table.insert(entities, entity)
|
||||
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.
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ end
|
||||
-- @returns void
|
||||
local function do_delete(event)
|
||||
if not wall_entity_lists[event.player_name] then return end
|
||||
print("DEBUG:marker_wall_manage do_delete --> deleting pre-existing wall with "..tostring(#wall_entity_lists[event.player_name]).." entities")
|
||||
-- print("DEBUG:marker_wall_manage do_delete --> deleting pre-existing wall with "..tostring(#wall_entity_lists[event.player_name]).." entities")
|
||||
if #wall_entity_lists[event.player_name] > 0 then
|
||||
weac.entities.pos_marker_wall.delete(wall_entity_lists[event.player_name])
|
||||
end
|
||||
@ -30,17 +30,17 @@ end
|
||||
-- @param event EventArgs<wea_c.pos.set> The event args for the set, push, or pop events on wea_c.pos.
|
||||
-- @returns void
|
||||
local function do_update(event)
|
||||
print("DEBUG:marker_wall_manage do_update --> START")
|
||||
-- print("DEBUG:marker_wall_manage do_update --> START")
|
||||
-- We don't dynamically update, as that'd be too much work.
|
||||
-- Instead, we just delete & recreate each time.
|
||||
if wall_entity_lists[event.player_name] then
|
||||
print("DEBUG:marker_wall_manage do_update --> do_delete")
|
||||
-- print("DEBUG:marker_wall_manage do_update --> do_delete")
|
||||
do_delete(event)
|
||||
end
|
||||
|
||||
local pos1 = weac.pos.get1(event.player_name)
|
||||
local pos2 = weac.pos.get2(event.player_name)
|
||||
print("DEBUG:marker_wall_manage do_update --> pos1", pos1, "pos2", pos2)
|
||||
-- print("DEBUG:marker_wall_manage do_update --> pos1", pos1, "pos2", pos2)
|
||||
|
||||
if not pos1 or not pos2 then return end
|
||||
|
||||
@ -49,7 +49,7 @@ local function do_update(event)
|
||||
pos1,
|
||||
pos2
|
||||
)
|
||||
print("DEBUG:marker_wall_manage do_update --> entitylist", weac.inspect(wall_entity_lists[event.player_name]))
|
||||
-- print("DEBUG:marker_wall_manage do_update --> entitylist", weac.inspect(wall_entity_lists[event.player_name]))
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user