minetest-meseconductors/lightstones.lua

136 lines
3.9 KiB
Lua

local lightstone_rules = {
{x=0, y=0, z=-1},
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
{x=0, y=0, z=1},
{x=1, y=1, z=0},
{x=1, y=-1, z=0},
{x=-1, y=1, z=0},
{x=-1, y=-1, z=0},
{x=0, y=1, z=1},
{x=0, y=-1, z=1},
{x=0, y=1, z=-1},
{x=0, y=-1, z=-1},
{x=0, y=-1, z=0},
}
local rules_all_directions =
{
{x = 1, y = 0, z = 0},
{x =-1, y = 0, z = 0},
{x = 0, y = 1, z = 0},
{x = 0, y =-1, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z =-1},
}
function meseconductors:lightstone_add(name, base_item, texture_off, texture_on)
minetest.register_node("meseconductors:lightstone_" .. name .. "_off", {
tiles = {texture_off},
groups = {cracky=2, mesecon_effector_off = 1, mesecon = 2},
description=name.." Lightstone",
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
rules = rules_all_directions,
action_on = function (pos, node)
minetest.swap_node(pos, {name = "meseconductors:lightstone_" .. name .. "_on", param2 = node.param2})
end,
}}
})
minetest.register_node("meseconductors:lightstone_" .. name .. "_on", {
tiles = {texture_on},
groups = {cracky=2,not_in_creative_inventory=1, mesecon = 2},
drop = "meseconductors:lightstone_" .. name .. "_off",
light_source = LIGHT_MAX-1,
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
rules = rules_all_directions,
action_off = function (pos, node)
minetest.swap_node(pos, {name = "meseconductors:lightstone_" .. name .. "_off", param2 = node.param2})
end,
}}
})
minetest.register_craft({
output = "meseconductors:lightstone_" .. name .. "_off",
recipe = {
{"mesecons_materials:glue","default:glass","mesecons_materials:glue"},
{base_item,"mesecons_torch:mesecon_torch_on",base_item},
{"default:glass","mesecons:mesecon","default:glass"}
}
})
end
meseconductors:lightstone_add("red", "default:clay_brick", "lightstone_red_off.png", "lightstone_red_on.png")
meseconductors:lightstone_add("green", "default:cactus", "lightstone_green_off.png", "lightstone_green_on.png")
meseconductors:lightstone_add("blue", "mesecons_materials:fiber", "lightstone_blue_off.png", "lightstone_blue_on.png")
meseconductors:lightstone_add("yellow", "default:gold_ingot", "lightstone_yellow_off.png", "lightstone_yellow_on.png")
local lamp_cbox = {
type = "wallmounted",
fixed = { -11/32, -8/16, -11/32, 11/32, 4/16, 11/32 }
}
-- Node Definition
minetest.register_node("meseconductors:mese_light_off", {
drawtype = "mesh",
mesh = "mese_light.obj",
tiles = {"mese_light.png"},
groups = {cracky=3},
paramtype = "light",
paramtype2 = "wallmounted",
description = "Mese Light",
selection_box = lamp_cbox,
collision_box = lamp_cbox,
mesecons = {effector = {
rules = rules_all_directions,
action_on = function (pos, node)
minetest.swap_node(pos, {name = "meseconductors:mese_light_on", param2 = node.param2})
--on_place = minetest.rotate_node
end
}}
})
minetest.register_node("meseconductors:mese_light_on", {
drawtype = "mesh",
mesh = "mese_light.obj",
tiles = {"mese_light_on.png"},
groups = {cracky=3, not_in_creative_inventory=1},
paramtype = "light",
paramtype2 = "wallmounted",
description = "Mese Light On (hey - cheated???)",
selection_box = lamp_cbox,
collision_box = lamp_cbox,
on_place = minetest.rotate_node,
light_source = 15,
drop = "meseconductors:mese_light_off",
mesecons = {effector = {
rules = rules_all_directions,
action_off = function (pos, node)
minetest.swap_node(pos, {name = "meseconductors:mese_light_off", param2 = node.param2})
end
}}
})
minetest.register_craft({
output = "meseconductors:mese_light_off 2",
recipe = {
{ "", "default:glass", ""},
{ "mesecons:mesecon", "default:torch", "mesecons:mesecon"},
{ "", "default:glass", ""}
},
})