make torches into nodeboxes until meshnodes are around, also clear torch entities on server step

This commit is contained in:
Jordach 2015-01-03 22:36:47 +00:00
parent 56f423a37a
commit de8e8bbc44
11 changed files with 26 additions and 112 deletions

View File

@ -169,10 +169,11 @@ end
minetest.register_node("deco:torch", {
description = "Torch",
drawtype = "airlike",
tiles = {"xfences_space.png"},
inventory_image = "deco_torch_ng_wield.png",
wield_image = "deco_torch_ng_wield.png",
drawtype = "nodebox",
tiles = {"deco_torch_top.png", "deco_torch_bottom.png", "deco_torch_side.png"},
inventory_image = "deco_torch_wield.png",
wield_image = "deco_torch_wield.png",
ield_scale = {x = 1, y = 1, z = 2},
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
@ -181,118 +182,19 @@ minetest.register_node("deco:torch", {
light_source = 15,
selection_box = {
type = "wallmounted",
wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
wall_top = {-0.0625, 0.5, -0.0625, 0.0625, -0.0625, 0.0625},
wall_bottom = {-0.0625, -0.5, -0.0625, 0.0625, 0+0.0625, 0.0625},
wall_side = {-0.5, -0.5, -0.0625, -0.375, 0.0625, 0.0625},
},
groups = {choppy=2,dig_immediate=3,flammable=1,attached_node=1,hot=2},
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
after_place_node = function(pos, placer)
--print (minetest.get_node(pos).param2)
local entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
if entity_remove[1] == nil then
if minetest.get_node(pos).param2 == 4 then --done
--list of rad to 90 degree: 3.142/2 = 90; 3.142 = 180; 3*3.142 = 270
minetest.add_entity({x=pos.x, y=pos.y, z=pos.z}, "deco:mesh_torch_w") --+(0.0625*10)
entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
entity_remove[1]:setyaw(3.142)
elseif minetest.get_node(pos).param2 == 2 then --done
minetest.add_entity({x=pos.x, y=pos.y, z=pos.z}, "deco:mesh_torch_w") --+(0.0625*10)
entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
entity_remove[1]:setyaw(3.142/2)
elseif minetest.get_node(pos).param2 == 3 then -- done
minetest.add_entity({x=pos.x, y=pos.y, z=pos.z}, "deco:mesh_torch_w") --+(0.0625*10)
entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
entity_remove[1]:setyaw(-3.142/2)
elseif minetest.get_node(pos).param2 == 5 then --done
minetest.add_entity({x=pos.x, y=pos.y, z=pos.z}, "deco:mesh_torch_w") --+(0.0625*10)
entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
entity_remove[1]:setyaw(0)
elseif minetest.get_node(pos).param2 == 0 then
minetest.add_entity({x=pos.x, y=pos.y, z=pos.z}, "deco:mesh_torch_c") --+(0.0625*10)
entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
entity_remove[1]:setyaw(0)
else
minetest.add_entity({x=pos.x, y=pos.y, z=pos.z}, "deco:mesh_torch_f") --+(0.0625*10)
entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
entity_remove[1]:setyaw(0)
end
end
end,
on_punch = function(pos, node)
local entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
if entity_remove[1] == nil then
if minetest.get_node(pos).param2 == 4 then --done
--list of rad to 90 degree: 3.142/2 = 90; 3.142 = 180; 3*3.142 = 270
minetest.add_entity({x=pos.x, y=pos.y, z=pos.z}, "deco:mesh_torch_w") --+(0.0625*10)
entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
entity_remove[1]:setyaw(3.142)
elseif minetest.get_node(pos).param2 == 2 then --done
minetest.add_entity({x=pos.x, y=pos.y, z=pos.z}, "deco:mesh_torch_w") --+(0.0625*10)
entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
entity_remove[1]:setyaw(3.142/2)
elseif minetest.get_node(pos).param2 == 3 then -- done
minetest.add_entity({x=pos.x, y=pos.y, z=pos.z}, "deco:mesh_torch_w") --+(0.0625*10)
entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
entity_remove[1]:setyaw(-3.142/2)
elseif minetest.get_node(pos).param2 == 5 then --done
minetest.add_entity({x=pos.x, y=pos.y, z=pos.z}, "deco:mesh_torch_w") --+(0.0625*10)
entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
entity_remove[1]:setyaw(0)
elseif minetest.get_node(pos).param2 == 0 then
minetest.add_entity({x=pos.x, y=pos.y, z=pos.z}, "deco:mesh_torch_c") --+(0.0625*10)
entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
entity_remove[1]:setyaw(0)
else
minetest.add_entity({x=pos.x, y=pos.y, z=pos.z}, "deco:mesh_torch_f") --+(0.0625*10)
entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
entity_remove[1]:setyaw(0)
end
end
end,
after_dig_node = function(pos)
local entity_remove = minetest.get_objects_inside_radius(pos, 0.1)
if entity_remove == nil then
--nothing
else
entity_remove[1]:remove()
end
end,
})
minetest.register_abm({
nodenames = {"deco:torch"},
interval = 60*60,
chance = 1,
action = function(pos, node)
minetest.punch_node(pos)
end,
})
minetest.register_entity("deco:mesh_torch_f", {
collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = "mesh",
mesh = "TorchNG_Floor.b3d",
textures = {"deco_torch_ng.png"},
visual_size = {x=20, y=20},
})
minetest.register_entity("deco:mesh_torch_c", {
collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = "mesh",
mesh = "TorchNG_Ceiling.b3d",
textures = {"deco_torch_ng.png"},
visual_size = {x=20, y=20},
})
minetest.register_entity("deco:mesh_torch_w", {
collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = "mesh",
mesh = "TorchNG_Wall.b3d",
textures = {"deco_torch_ng.png"},
visual_size = {x=20, y=20},
node_box = {
type = "wallmounted",
wall_top = {-0.0625, 0.5, -0.0625, 0.0625, -0.0625, 0.0625},
wall_bottom = {-0.0625, -0.5, -0.0625, 0.0625, 0+0.0625, 0.0625},
wall_side = {-0.5, -0.5, -0.0625, -0.375, 0.0625, 0.0625},
},
})
minetest.register_craft({
@ -311,6 +213,18 @@ minetest.register_craft({
}
})
-- saving worlds with too many torches
local old_entities = {"deco:mesh_torch_c", "deco:mesh_torch_f", "deco:mesh_torch_w"}
for _,entity_name in ipairs(old_entities) do
minetest.register_entity(":"..entity_name, {
on_activate = function(self, staticdata)
self.object:remove()
end,
})
end
--
-- Furnace
--

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B