visuals makeover
This commit is contained in:
parent
631f7270a7
commit
2d1694e735
26
entity.lua
26
entity.lua
@ -19,6 +19,32 @@ minetest.register_entity("building_lib:display", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_entity("building_lib:cube_display", {
|
||||||
|
initial_properties = {
|
||||||
|
physical = false,
|
||||||
|
static_save = false,
|
||||||
|
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||||
|
visual = "cube",
|
||||||
|
backface_culling = false,
|
||||||
|
visual_size = {x=1, y=1, z=1},
|
||||||
|
glow = 10
|
||||||
|
},
|
||||||
|
on_step = function(self)
|
||||||
|
if not active_entities[self.id] then
|
||||||
|
-- not valid anymore
|
||||||
|
self.object:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
function building_lib.add_cube_entity(pos, id)
|
||||||
|
active_entities[id] = true
|
||||||
|
local ent = minetest.add_entity(pos, "building_lib:cube_display")
|
||||||
|
local luaent = ent:get_luaentity()
|
||||||
|
luaent.id = id
|
||||||
|
return ent
|
||||||
|
end
|
||||||
|
|
||||||
function building_lib.add_entity(pos, id)
|
function building_lib.add_entity(pos, id)
|
||||||
active_entities[id] = true
|
active_entities[id] = true
|
||||||
local ent = minetest.add_entity(pos, "building_lib:display")
|
local ent = minetest.add_entity(pos, "building_lib:display")
|
||||||
|
75
preview.lua
75
preview.lua
@ -2,15 +2,6 @@
|
|||||||
-- playername => key
|
-- playername => key
|
||||||
local active_preview = {}
|
local active_preview = {}
|
||||||
|
|
||||||
local function add_preview_entity(texture, key, visual_size, pos, rotation)
|
|
||||||
local ent = building_lib.add_entity(pos, key)
|
|
||||||
ent:set_properties({
|
|
||||||
visual_size = visual_size,
|
|
||||||
textures = {texture}
|
|
||||||
})
|
|
||||||
ent:set_rotation(rotation)
|
|
||||||
end
|
|
||||||
|
|
||||||
function building_lib.show_preview(playername, texture, color, building_def, mapblock_pos1, mapblock_pos2, rotation)
|
function building_lib.show_preview(playername, texture, color, building_def, mapblock_pos1, mapblock_pos2, rotation)
|
||||||
texture = texture .. "^[colorize:" .. color
|
texture = texture .. "^[colorize:" .. color
|
||||||
|
|
||||||
@ -35,47 +26,20 @@ function building_lib.show_preview(playername, texture, color, building_def, map
|
|||||||
local size = vector.multiply(size_mapblocks, 16) -- 16 .. n
|
local size = vector.multiply(size_mapblocks, 16) -- 16 .. n
|
||||||
local half_size = vector.divide(size, 2) -- 8 .. n
|
local half_size = vector.divide(size, 2) -- 8 .. n
|
||||||
|
|
||||||
-- z-
|
local origin = vector.add(min, half_size)
|
||||||
add_preview_entity(texture, key,
|
|
||||||
{x=size.x, y=size.y},
|
|
||||||
vector.add(min, {x=half_size.x-0.5, y=half_size.y-0.5, z=-0.5}),
|
|
||||||
{x=0, y=0, z=0}
|
|
||||||
)
|
|
||||||
|
|
||||||
-- z+
|
local ent = building_lib.add_cube_entity(origin, key)
|
||||||
add_preview_entity(texture, key,
|
ent:set_properties({
|
||||||
{x=size.x, y=size.y},
|
visual_size = size,
|
||||||
vector.add(min, {x=half_size.x-0.5, y=half_size.y-0.5, z=size.z-0.5}),
|
textures = {
|
||||||
{x=0, y=0, z=0}
|
texture,
|
||||||
)
|
texture,
|
||||||
|
texture,
|
||||||
-- x-
|
texture,
|
||||||
add_preview_entity(texture, key,
|
texture,
|
||||||
{x=size.z, y=size.y},
|
texture
|
||||||
vector.add(min, {x=-0.5, y=half_size.y-0.5, z=half_size.z-0.5}),
|
}
|
||||||
{x=0, y=math.pi/2, z=0}
|
})
|
||||||
)
|
|
||||||
|
|
||||||
-- x+
|
|
||||||
add_preview_entity(texture, key,
|
|
||||||
{x=size.z, y=size.y},
|
|
||||||
vector.add(min, {x=size.x-0.5, y=half_size.y-0.5, z=half_size.z-0.5}),
|
|
||||||
{x=0, y=math.pi/2, z=0}
|
|
||||||
)
|
|
||||||
|
|
||||||
-- y-
|
|
||||||
add_preview_entity(texture, key,
|
|
||||||
{x=size.x, y=size.z},
|
|
||||||
vector.add(min, {x=half_size.x-0.5, y=-0.5, z=half_size.z-0.5}),
|
|
||||||
{x=math.pi/2, y=0, z=0}
|
|
||||||
)
|
|
||||||
|
|
||||||
-- y+
|
|
||||||
add_preview_entity(texture, key,
|
|
||||||
{x=size.x, y=size.z},
|
|
||||||
vector.add(min, {x=half_size.x-0.5, y=size.y-0.5, z=half_size.z-0.5}),
|
|
||||||
{x=math.pi/2, y=0, z=0}
|
|
||||||
)
|
|
||||||
|
|
||||||
if building_def and building_def.markers then
|
if building_def and building_def.markers then
|
||||||
-- add markers
|
-- add markers
|
||||||
@ -96,15 +60,16 @@ function building_lib.show_preview(playername, texture, color, building_def, map
|
|||||||
z_rotation = z_rotation + math.pi/2
|
z_rotation = z_rotation + math.pi/2
|
||||||
end
|
end
|
||||||
|
|
||||||
add_preview_entity(
|
ent = building_lib.add_entity(node_pos, key)
|
||||||
marker.texture .. texture_modifier,
|
ent:set_properties({
|
||||||
key, marker.size,
|
visual_size = marker.size,
|
||||||
node_pos, {
|
textures = {marker.texture .. texture_modifier}
|
||||||
|
})
|
||||||
|
ent:set_rotation({
|
||||||
x=marker.rotation.x,
|
x=marker.rotation.x,
|
||||||
y=marker.rotation.y,
|
y=marker.rotation.y,
|
||||||
z=z_rotation
|
z=z_rotation
|
||||||
}
|
})
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 5.0 KiB |
Loading…
x
Reference in New Issue
Block a user