3D redstone torches

This commit is contained in:
Wuzzy 2017-02-10 15:38:53 +01:00
parent 41c7b4bd47
commit 971d4f3867
10 changed files with 57 additions and 55 deletions

View file

@ -5,9 +5,9 @@
mcl_torches = {} mcl_torches = {}
mcl_torches.register_torch = function(substring, description, icon, mesh_floor, mesh_wall, tiles, light, groups, sounds) mcl_torches.register_torch = function(substring, description, icon, mesh_floor, mesh_wall, tiles, light, groups, sounds, moredef)
local itemstring = "mcl_torches:"..substring local itemstring = minetest.get_current_modname()..":"..substring
local itemstring_wall = "mcl_torches:"..substring.."_wall" local itemstring_wall = minetest.get_current_modname()..":"..substring.."_wall"
if light == nil then light = 14 end if light == nil then light = 14 end
if mesh_floor == nil then mesh_floor = "mcl_torches_torch_floor.obj" end if mesh_floor == nil then mesh_floor = "mcl_torches_torch_floor.obj" end
@ -18,7 +18,7 @@ mcl_torches.register_torch = function(substring, description, icon, mesh_floor,
groups.torch = 1 groups.torch = 1
groups.dig_by_water = 1 groups.dig_by_water = 1
minetest.register_node(itemstring, { local floordef = {
description = description, description = description,
drawtype = "mesh", drawtype = "mesh",
mesh = mesh_floor, mesh = mesh_floor,
@ -63,25 +63,31 @@ mcl_torches.register_torch = function(substring, description, icon, mesh_floor,
-- Prevent placement of ceiling torches -- Prevent placement of ceiling torches
return itemstack return itemstack
elseif wdir == 1 then elseif wdir == 1 then
retval = fakestack:set_name("mcl_torches:torch") retval = fakestack:set_name(itemstring)
else else
retval = fakestack:set_name("mcl_torches:torch_wall") retval = fakestack:set_name(itemstring_wall)
end end
if not retval then if not retval then
return itemstack return itemstack
end end
itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir) itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir)
itemstack:set_name("mcl_torches:torch") itemstack:set_name(itemstring)
return itemstack return itemstack
end end
}) }
if moredef ~= nil then
for k,v in pairs(moredef) do
floordef[k] = v
end
end
minetest.register_node(itemstring, floordef)
local groups_wall = table.copy(groups) local groups_wall = table.copy(groups)
groups_wall.torch = 2 groups_wall.torch = 2
minetest.register_node(itemstring_wall, { local walldef = {
drawtype = "mesh", drawtype = "mesh",
mesh = mesh_wall, mesh = mesh_wall,
tiles = tiles, tiles = tiles,
@ -99,7 +105,13 @@ mcl_torches.register_torch = function(substring, description, icon, mesh_floor,
wall_side = {-0.5, -0.5, -0.1, -0.2, 0.1, 0.1}, wall_side = {-0.5, -0.5, -0.1, -0.2, 0.1, 0.1},
}, },
sounds = sounds, sounds = sounds,
}) }
if moredef ~= nil then
for k,v in pairs(moredef) do
walldef[k] = v
end
end
minetest.register_node(itemstring_wall, walldef)
end end
mcl_torches.register_torch("torch", "Torch", "default_torch_on_floor.png", mcl_torches.register_torch("torch", "Torch", "default_torch_on_floor.png",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 B

View file

@ -1 +1,2 @@
mesecons mesecons
mcl_torches

View file

@ -41,51 +41,34 @@ minetest.register_craft({
{"mcl_core:stick"},} {"mcl_core:stick"},}
}) })
local torch_selectionbox = mcl_torches.register_torch("mesecon_torch_off", "Mesecon Torch (off)", "jeija_torches_off.png",
{ "mcl_torches_torch_floor.obj", "mcl_torches_torch_wall.obj",
type = "wallmounted", {"jeija_torches_off.png"},
wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1}, 0,
wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, {dig_immediate=3, dig_by_water=1, not_in_creative_inventory=1},
wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1}, mcl_core.node_sound_wood_defaults(),
} {
mesecons = {receptor = {
state = mesecon.state.off,
rules = torch_get_output_rules
}},
drop = "mesecons_torch:mesecon_torch_on",
}
)
minetest.register_node("mesecons_torch:mesecon_torch_off", { mcl_torches.register_torch("mesecon_torch_on", "Mesecon Torch", "jeija_torches_on_inv.png",
drawtype = "torchlike", "mcl_torches_torch_floor.obj", "mcl_torches_torch_wall.obj",
tiles = {"jeija_torches_off.png", "jeija_torches_off_ceiling.png", "jeija_torches_off_side.png"}, {"jeija_torches_on.png"},
inventory_image = "jeija_torches_off.png", 7,
paramtype = "light", {dig_immediate=3, dig_by_water=1},
walkable = false, mcl_core.node_sound_wood_defaults(),
paramtype2 = "wallmounted", {
is_ground_content = false, mesecons = {receptor = {
selection_box = torch_selectionbox, state = mesecon.state.on,
groups = {dig_immediate = 3, dig_by_water=1, not_in_creative_inventory = 1}, rules = torch_get_output_rules
drop = "mesecons_torch:mesecon_torch_on", }}
mesecons = {receptor = { }
state = mesecon.state.off, )
rules = torch_get_output_rules
}}
})
minetest.register_node("mesecons_torch:mesecon_torch_on", {
drawtype = "torchlike",
tiles = {"jeija_torches_on.png", "jeija_torches_on_ceiling.png", "jeija_torches_on_side.png"},
inventory_image = "jeija_torches_on.png",
wield_image = "jeija_torches_on.png",
stack_max = 64,
paramtype = "light",
sunlight_propagates = true,
walkable = false,
paramtype2 = "wallmounted",
is_ground_content = false,
selection_box = torch_selectionbox,
groups = {dig_immediate=3, dig_by_water=1},
light_source = 7,
description="Redstone Torch",
mesecons = {receptor = {
state = mesecon.state.on,
rules = torch_get_output_rules
}},
})
minetest.register_node("mesecons_torch:redstoneblock", { minetest.register_node("mesecons_torch:redstoneblock", {
description = "Block of Redstone", description = "Block of Redstone",
@ -117,7 +100,7 @@ minetest.register_craft({
}) })
minetest.register_abm({ minetest.register_abm({
nodenames = {"mesecons_torch:mesecon_torch_off","mesecons_torch:mesecon_torch_on"}, nodenames = {"mesecons_torch:mesecon_torch_off","mesecons_torch:mesecon_torch_off_wall","mesecons_torch:mesecon_torch_on","mesecons_torch:mesecon_torch_on_wall"},
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node) action = function(pos, node)
@ -133,10 +116,16 @@ minetest.register_abm({
if node.name == "mesecons_torch:mesecon_torch_on" then if node.name == "mesecons_torch:mesecon_torch_on" then
mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_off") mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_off")
mesecon:receptor_off(pos, torch_get_output_rules(node)) mesecon:receptor_off(pos, torch_get_output_rules(node))
elseif node.name == "mesecons_torch:mesecon_torch_on_wall" then
mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_off_wall")
mesecon:receptor_off(pos, torch_get_output_rules(node))
end end
elseif node.name == "mesecons_torch:mesecon_torch_off" then elseif node.name == "mesecons_torch:mesecon_torch_off" then
mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_on") mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_on")
mesecon:receptor_on(pos, torch_get_output_rules(node)) mesecon:receptor_on(pos, torch_get_output_rules(node))
elseif node.name == "mesecons_torch:mesecon_torch_off_wall" then
mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_on_wall")
mesecon:receptor_on(pos, torch_get_output_rules(node))
end end
end end
}) })