visuals makeover
This commit is contained in:
parent
631f7270a7
commit
2d1694e735
28
entity.lua
28
entity.lua
@ -5,7 +5,7 @@ local active_entities = {}
|
||||
minetest.register_entity("building_lib:display", {
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
static_save = false,
|
||||
static_save = false,
|
||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=10, y=10},
|
||||
@ -19,6 +19,32 @@ minetest.register_entity("building_lib:display", {
|
||||
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)
|
||||
active_entities[id] = true
|
||||
local ent = minetest.add_entity(pos, "building_lib:display")
|
||||
|
81
preview.lua
81
preview.lua
@ -2,15 +2,6 @@
|
||||
-- playername => key
|
||||
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)
|
||||
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 half_size = vector.divide(size, 2) -- 8 .. n
|
||||
|
||||
-- z-
|
||||
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}
|
||||
)
|
||||
local origin = vector.add(min, half_size)
|
||||
|
||||
-- z+
|
||||
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=size.z-0.5}),
|
||||
{x=0, y=0, z=0}
|
||||
)
|
||||
|
||||
-- x-
|
||||
add_preview_entity(texture, key,
|
||||
{x=size.z, y=size.y},
|
||||
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}
|
||||
)
|
||||
local ent = building_lib.add_cube_entity(origin, key)
|
||||
ent:set_properties({
|
||||
visual_size = size,
|
||||
textures = {
|
||||
texture,
|
||||
texture,
|
||||
texture,
|
||||
texture,
|
||||
texture,
|
||||
texture
|
||||
}
|
||||
})
|
||||
|
||||
if building_def and building_def.markers then
|
||||
-- add markers
|
||||
@ -96,15 +60,16 @@ function building_lib.show_preview(playername, texture, color, building_def, map
|
||||
z_rotation = z_rotation + math.pi/2
|
||||
end
|
||||
|
||||
add_preview_entity(
|
||||
marker.texture .. texture_modifier,
|
||||
key, marker.size,
|
||||
node_pos, {
|
||||
x=marker.rotation.x,
|
||||
y=marker.rotation.y,
|
||||
z=z_rotation
|
||||
}
|
||||
)
|
||||
ent = building_lib.add_entity(node_pos, key)
|
||||
ent:set_properties({
|
||||
visual_size = marker.size,
|
||||
textures = {marker.texture .. texture_modifier}
|
||||
})
|
||||
ent:set_rotation({
|
||||
x=marker.rotation.x,
|
||||
y=marker.rotation.y,
|
||||
z=z_rotation
|
||||
})
|
||||
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