1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2024-12-23 00:20:17 +01:00

make most presently non-dimmable lights dimmable

merge table and standing lamps into the new code

of all the relevant lights, the plasma ball is the only one that remains
on/off-only, since dimmable doesn't make sense there.

That one, and any future lights that get the on/off-only treatment, will
use the previous on/off behavior, i.e. turn off with the messages "off"
or "low" or a number < 4, and turn on with "med", "hi", "max", "on" or
a number > 3

This alters the behavior of table/standing lamps - they will no longer
cycle brightnesses by right-click.  Like all other controllable lights,
they'll just toggle on/off.  If there's enough demand for it, I'll add
that feature back in at a later date.
This commit is contained in:
Vanessa Dannenberg 2019-06-02 02:01:54 -04:00
parent 11771e12cb
commit 4174737a1a

View File

@ -13,7 +13,7 @@ end
-- control and brightness for dimmable lamps -- control and brightness for dimmable lamps
local repl = { local brightn_cycle = {
["off"] = "low", ["off"] = "low",
["low"] = "med", ["low"] = "med",
["med"] = "hi", ["med"] = "hi",
@ -22,7 +22,16 @@ local repl = {
["on"] = "off", ["on"] = "off",
} }
local brightness_tab = { local brightn_light_source = {
["off"] = 0,
["low"] = 3,
["med"] = 7,
["hi"] = 11,
["on"] = 14,
["max"] = 14,
}
local brightn_hex = {
0xffd0d0d0, 0xffd0d0d0,
0xffd8d8d8, 0xffd8d8d8,
0xffe0e0e0, 0xffe0e0e0,
@ -31,21 +40,21 @@ local brightness_tab = {
} }
local bright_to_word = { local bright_to_word = {
[0] = "off", [0] = "off",
[1] = "low", [1] = "low",
[2] = "low", [2] = "low",
[3] = "low", [3] = "low",
[4] = "med", [4] = "med",
[5] = "med", [5] = "med",
[6] = "med", [6] = "med",
[7] = "med", [7] = "med",
[8] = "hi", [8] = "hi",
[9] = "hi", [9] = "hi",
[10] = "hi", [10] = "hi",
[11] = "hi", [11] = "hi",
[12] = "on", [12] = "on",
[13] = "on", [13] = "on",
[14] = "on", [14] = "on",
} }
local rules_xz = { local rules_xz = {
@ -145,9 +154,10 @@ if minetest.get_modpath("digilines") then
if msg and msg ~= "" then if msg and msg ~= "" then
local n = tonumber(msg) local n = tonumber(msg)
local msg = bright_to_word[n] or msg local msg = bright_to_word[n] or msg
print(node.name, dump(msg))
local basename = string.sub(node.name, 1, string.find(node.name, "_", -5) - 1) local basename = string.sub(node.name, 1, string.find(node.name, "_", -5) - 1)
if repl[msg] then if brightn_light_source[msg] then
if minetest.registered_nodes[basename.."_"..msg] then if minetest.registered_nodes[basename.."_"..msg] then
minetest.swap_node(pos, {name = basename.."_"..msg, param2 = node.param2}) minetest.swap_node(pos, {name = basename.."_"..msg, param2 = node.param2})
elseif (n and n > 3) or msg == "hi" or msg == "max" or msg == "med" then elseif (n and n > 3) or msg == "hi" or msg == "max" or msg == "med" then
@ -233,14 +243,6 @@ end
-- turn on/off, cycle brightness -- turn on/off, cycle brightness
function on_rightclick(pos, node, clicker, itemstack, pointed_thing)
if is_protected(pos, clicker) then return end
local delim = string.find(node.name, "_", -5)
local basename = string.sub(node.name, 1, delim - 1)
local suffix = string.sub(node.name, delim + 1)
minetest.swap_node(pos, {name = basename.."_"..repl[suffix], param2 = node.param2})
end
function homedecor.toggle_light(pos, node, clicker, itemstack, pointed_thing) function homedecor.toggle_light(pos, node, clicker, itemstack, pointed_thing)
if is_protected(pos, clicker) then return end if is_protected(pos, clicker) then return end
local sep = string.find(node.name, "_o", -5) local sep = string.find(node.name, "_o", -5)
@ -249,19 +251,24 @@ function homedecor.toggle_light(pos, node, clicker, itemstack, pointed_thing)
minetest.swap_node(pos, {name = newname, param2 = node.param2}) minetest.swap_node(pos, {name = newname, param2 = node.param2})
end end
----- ------------------
-- The actual lights! :-) -- Dimmable lights
for _, onoff in ipairs({"on", "off"}) do for light_brightn_name in pairs(brightn_light_source) do
local onflag = (onoff == "on") if brightn_light_source ~= "max" then
local offon = "on" -- always the inverse of 'onoff'
if onoff == "on" then offon = "off" end
local tiles local tiles
local overlay local overlay
local nici
if not onflag then nici = 1 end local onflag = (light_brightn_name ~= "off")
local nici = (light_brightn_name ~= "on") and 1 or nil
local gen_ls_tex_white = "homedecor_table_generic_light_source_off.png"
if onflag then gen_ls_tex_white = "homedecor_table_generic_light_source_on.png" end
local gen_ls_tex_yellow = "homedecor_table_generic_light_source_off.png"
if onflag then gen_ls_tex_yellow = "homedecor_light.png" end
local glowlight_nodebox = { local glowlight_nodebox = {
half = homedecor.nodebox.slab_y(1/2), half = homedecor.nodebox.slab_y(1/2),
@ -307,7 +314,7 @@ for _, onoff in ipairs({"on", "off"}) do
overlay = nil overlay = nil
end end
minetest.register_node(":homedecor:glowlight_half_"..onoff, { minetest.register_node(":homedecor:glowlight_half_"..light_brightn_name, {
description = S("Thick Glowlight"), description = S("Thick Glowlight"),
tiles = tiles, tiles = tiles,
overlay_tiles = overlay, overlay_tiles = overlay,
@ -324,7 +331,7 @@ for _, onoff in ipairs({"on", "off"}) do
}, },
node_box = glowlight_nodebox.half, node_box = glowlight_nodebox.half,
groups = { snappy = 3, ud_param2_colorable = 1, not_in_creative_inventory = nici }, groups = { snappy = 3, ud_param2_colorable = 1, not_in_creative_inventory = nici },
light_source = onflag and default.LIGHT_MAX or nil, light_source = brightn_light_source[light_brightn_name],
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
after_place_node = function(pos, placer, itemstack, pointed_thing) after_place_node = function(pos, placer, itemstack, pointed_thing)
unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing) unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing)
@ -372,7 +379,7 @@ for _, onoff in ipairs({"on", "off"}) do
overlay = nil overlay = nil
end end
minetest.register_node(":homedecor:glowlight_quarter_"..onoff, { minetest.register_node(":homedecor:glowlight_quarter_"..light_brightn_name, {
description = S("Thin Glowlight"), description = S("Thin Glowlight"),
tiles = tiles, tiles = tiles,
overlay_tiles = overlay, overlay_tiles = overlay,
@ -389,7 +396,7 @@ for _, onoff in ipairs({"on", "off"}) do
}, },
node_box = glowlight_nodebox.quarter, node_box = glowlight_nodebox.quarter,
groups = { snappy = 3, ud_param2_colorable = 1, not_in_creative_inventory = nici }, groups = { snappy = 3, ud_param2_colorable = 1, not_in_creative_inventory = nici },
light_source = onflag and (default.LIGHT_MAX - 1) or nil, light_source = brightn_light_source[light_brightn_name],
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
after_place_node = function(pos, placer, itemstack, pointed_thing) after_place_node = function(pos, placer, itemstack, pointed_thing)
unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing) unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing)
@ -438,7 +445,7 @@ for _, onoff in ipairs({"on", "off"}) do
overlay = nil overlay = nil
end end
minetest.register_node(":homedecor:glowlight_small_cube_"..onoff, { minetest.register_node(":homedecor:glowlight_small_cube_"..light_brightn_name, {
description = S("Small Glowlight Cube"), description = S("Small Glowlight Cube"),
tiles = tiles, tiles = tiles,
overlay_tiles = overlay, overlay_tiles = overlay,
@ -455,7 +462,7 @@ for _, onoff in ipairs({"on", "off"}) do
}, },
node_box = glowlight_nodebox.small_cube, node_box = glowlight_nodebox.small_cube,
groups = { snappy = 3, ud_param2_colorable = 1, not_in_creative_inventory = nici }, groups = { snappy = 3, ud_param2_colorable = 1, not_in_creative_inventory = nici },
light_source = onflag and (default.LIGHT_MAX - 1) or nil, light_source = brightn_light_source[light_brightn_name],
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
after_place_node = function(pos, placer, itemstack, pointed_thing) after_place_node = function(pos, placer, itemstack, pointed_thing)
unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing) unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing)
@ -482,7 +489,7 @@ for _, onoff in ipairs({"on", "off"}) do
lighttex = "homedecor_plasma_lamp_off.png" lighttex = "homedecor_plasma_lamp_off.png"
end end
homedecor.register("plasma_lamp_"..onoff, { homedecor.register("plasma_lamp_"..light_brightn_name, {
description = S("Plasma Lamp/Light"), description = S("Plasma Lamp/Light"),
drawtype = "mesh", drawtype = "mesh",
mesh = "plasma_lamp.obj", mesh = "plasma_lamp.obj",
@ -491,7 +498,7 @@ for _, onoff in ipairs({"on", "off"}) do
lighttex lighttex
}, },
use_texture_alpha = true, use_texture_alpha = true,
light_source = onflag and (default.LIGHT_MAX - 1) or nil, light_source = brightn_light_source[light_brightn_name],
sunlight_propagates = true, sunlight_propagates = true,
groups = {cracky=3, oddly_breakable_by_hand=3, not_in_creative_inventory = nici}, groups = {cracky=3, oddly_breakable_by_hand=3, not_in_creative_inventory = nici},
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
@ -506,65 +513,20 @@ for _, onoff in ipairs({"on", "off"}) do
on_punch = digiline_on_punch on_punch = digiline_on_punch
}) })
local lighttex = "homedecor_blanktile.png"
if onflag then
lighttex = {
name = "homedecor_plasma_ball_streamers.png",
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0},
}
end
homedecor.register("plasma_ball_"..onoff, {
description = S("Plasma Ball"),
mesh = "homedecor_plasma_ball.obj",
tiles = {
{ name = "homedecor_generic_plastic.png", color = homedecor.color_black },
lighttex,
"homedecor_plasma_ball_glass.png"
},
inventory_image = "homedecor_plasma_ball_inv.png",
selection_box = {
type = "fixed",
fixed = { -0.1875, -0.5, -0.1875, 0.1875, 0, 0.1875 }
},
walkable = false,
use_texture_alpha = true,
light_source = onflag and (default.LIGHT_MAX - 5) or nil,
sunlight_propagates = true,
groups = {cracky=3, oddly_breakable_by_hand=3, not_in_creative_inventory = nici},
sounds = default.node_sound_glass_defaults(),
on_rightclick = homedecor.toggle_light,
drop = {
items = {
{items = {"homedecor:plasma_ball_on"}},
}
},
mesecons = homedecor.mesecon_xz_light,
digiline = homedecor.digiline_xz_light,
on_punch = digiline_on_punch
})
local gl_cbox = { local gl_cbox = {
type = "fixed", type = "fixed",
fixed = { -0.25, -0.5, -0.25, 0.25, 0.45, 0.25 }, fixed = { -0.25, -0.5, -0.25, 0.25, 0.45, 0.25 },
} }
local lighttex homedecor.register("ground_lantern_"..light_brightn_name, {
if onflag then
lighttex = "homedecor_light.png"
else
lighttex = "homedecor_table_generic_light_source_off.png"
end
homedecor.register("ground_lantern_"..onoff, {
description = S("Ground Lantern/Light"), description = S("Ground Lantern/Light"),
mesh = "homedecor_ground_lantern.obj", mesh = "homedecor_ground_lantern.obj",
tiles = { lighttex, "homedecor_generic_metal_wrought_iron.png" }, tiles = { gen_ls_tex_yellow, "homedecor_generic_metal_wrought_iron.png" },
use_texture_alpha = true, use_texture_alpha = true,
inventory_image = "homedecor_ground_lantern_inv.png", inventory_image = "homedecor_ground_lantern_inv.png",
wield_image = "homedecor_ground_lantern_inv.png", wield_image = "homedecor_ground_lantern_inv.png",
groups = {snappy=3, not_in_creative_inventory = nici}, groups = {snappy=3, not_in_creative_inventory = nici},
light_source = onflag and (default.LIGHT_MAX - 3) or nil, light_source = brightn_light_source[light_brightn_name],
selection_box = gl_cbox, selection_box = gl_cbox,
walkable = false, walkable = false,
on_rightclick = homedecor.toggle_light, on_rightclick = homedecor.toggle_light,
@ -583,7 +545,7 @@ for _, onoff in ipairs({"on", "off"}) do
fixed = { -0.25, -0.5, -0.2, 0.25, 0.5, 0.5 }, fixed = { -0.25, -0.5, -0.2, 0.25, 0.5, 0.5 },
} }
homedecor.register("hanging_lantern_"..onoff, { homedecor.register("hanging_lantern_"..light_brightn_name, {
description = S("Hanging Lantern/Light"), description = S("Hanging Lantern/Light"),
mesh = "homedecor_hanging_lantern.obj", mesh = "homedecor_hanging_lantern.obj",
tiles = { "homedecor_generic_metal_wrought_iron.png", lighttex }, tiles = { "homedecor_generic_metal_wrought_iron.png", lighttex },
@ -591,7 +553,7 @@ for _, onoff in ipairs({"on", "off"}) do
inventory_image = "homedecor_hanging_lantern_inv.png", inventory_image = "homedecor_hanging_lantern_inv.png",
wield_image = "homedecor_hanging_lantern_inv.png", wield_image = "homedecor_hanging_lantern_inv.png",
groups = {snappy=3, not_in_creative_inventory = nici}, groups = {snappy=3, not_in_creative_inventory = nici},
light_source = onflag and (default.LIGHT_MAX - 3) or nil, light_source = brightn_light_source[light_brightn_name],
selection_box = hl_cbox, selection_box = hl_cbox,
walkable = false, walkable = false,
on_rightclick = homedecor.toggle_light, on_rightclick = homedecor.toggle_light,
@ -610,7 +572,7 @@ for _, onoff in ipairs({"on", "off"}) do
fixed = { -0.35, -0.45, -0.35, 0.35, 0.5, 0.35 } fixed = { -0.35, -0.45, -0.35, 0.35, 0.5, 0.35 }
} }
homedecor.register("ceiling_lantern_"..onoff, { homedecor.register("ceiling_lantern_"..light_brightn_name, {
drawtype = "mesh", drawtype = "mesh",
mesh = "homedecor_ceiling_lantern.obj", mesh = "homedecor_ceiling_lantern.obj",
tiles = { lighttex, "homedecor_generic_metal_wrought_iron.png" }, tiles = { lighttex, "homedecor_generic_metal_wrought_iron.png" },
@ -618,7 +580,7 @@ for _, onoff in ipairs({"on", "off"}) do
inventory_image = "homedecor_ceiling_lantern_inv.png", inventory_image = "homedecor_ceiling_lantern_inv.png",
description = S("Ceiling Lantern/Light"), description = S("Ceiling Lantern/Light"),
groups = {snappy=3, not_in_creative_inventory = nici}, groups = {snappy=3, not_in_creative_inventory = nici},
light_source = onflag and (default.LIGHT_MAX - 3) or nil, light_source = brightn_light_source[light_brightn_name],
selection_box = cl_cbox, selection_box = cl_cbox,
walkable = false, walkable = false,
on_rightclick = homedecor.toggle_light, on_rightclick = homedecor.toggle_light,
@ -635,18 +597,12 @@ for _, onoff in ipairs({"on", "off"}) do
if minetest.get_modpath("darkage") then if minetest.get_modpath("darkage") then
sm_light = default.LIGHT_MAX-5 sm_light = default.LIGHT_MAX-5
else else
local lighttex
if onflag then
lighttex = "homedecor_lattice_lantern_large_light.png"
else
lighttex = "homedecor_table_generic_light_source_off.png"
end
homedecor.register("lattice_lantern_large_"..onoff, { homedecor.register("lattice_lantern_large_"..light_brightn_name, {
description = S("Lattice lantern/Light (large)"), description = S("Lattice lantern/Light (large)"),
tiles = { lighttex.."^homedecor_lattice_lantern_large_overlay.png" }, tiles = { gen_ls_tex_yellow.."^homedecor_lattice_lantern_large_overlay.png" },
groups = { snappy = 3, not_in_creative_inventory = nici }, groups = { snappy = 3, not_in_creative_inventory = nici },
light_source = onflag and default.LIGHT_MAX or nil, light_source = brightn_light_source[light_brightn_name],
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
on_rightclick = homedecor.toggle_light, on_rightclick = homedecor.toggle_light,
drop = { drop = {
@ -671,7 +627,7 @@ for _, onoff in ipairs({"on", "off"}) do
lighttex_sides = "homedecor_table_generic_light_source_off.png" lighttex_sides = "homedecor_table_generic_light_source_off.png"
end end
homedecor.register("lattice_lantern_small_"..onoff, { homedecor.register("lattice_lantern_small_"..light_brightn_name, {
description = S("Lattice lantern/light (small)"), description = S("Lattice lantern/light (small)"),
tiles = { tiles = {
lighttex_tb.."^homedecor_lattice_lantern_small_tb_overlay.png", lighttex_tb.."^homedecor_lattice_lantern_small_tb_overlay.png",
@ -687,7 +643,7 @@ for _, onoff in ipairs({"on", "off"}) do
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 } fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
}, },
groups = { snappy = 3, not_in_creative_inventory = nici }, groups = { snappy = 3, not_in_creative_inventory = nici },
light_source = onflag and (default.LIGHT_MAX - 2) or nil, light_source = brightn_light_source[light_brightn_name],
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
on_place = minetest.rotate_node, on_place = minetest.rotate_node,
on_rightclick = homedecor.toggle_light, on_rightclick = homedecor.toggle_light,
@ -708,14 +664,14 @@ for _, onoff in ipairs({"on", "off"}) do
wall_side = { -0.2, -0.5, -0.15, 0.32, 0.12, 0.15 }, wall_side = { -0.2, -0.5, -0.15, 0.32, 0.12, 0.15 },
} }
homedecor.register("desk_lamp_"..onoff, { homedecor.register("desk_lamp_"..light_brightn_name, {
description = S("Desk Lamp/Light"), description = S("Desk Lamp/Light"),
mesh = "homedecor_desk_lamp.obj", mesh = "homedecor_desk_lamp.obj",
tiles = { tiles = {
"homedecor_generic_metal.png", "homedecor_generic_metal.png",
"homedecor_generic_metal.png", "homedecor_generic_metal.png",
{ name = "homedecor_generic_metal.png", color = homedecor.color_med_grey }, { name = "homedecor_generic_metal.png", color = homedecor.color_med_grey },
{ name = "homedecor_table_generic_light_source_"..onoff..".png", color = brightness_tab[5] }, { name = gen_ls_tex_white, color = brightn_hex[5] },
}, },
inventory_image = "homedecor_desk_lamp_inv.png", inventory_image = "homedecor_desk_lamp_inv.png",
paramtype = "light", paramtype = "light",
@ -729,7 +685,7 @@ for _, onoff in ipairs({"on", "off"}) do
unifieddyes.fix_rotation_nsew(pos, placer, itemstack, pointed_thing) unifieddyes.fix_rotation_nsew(pos, placer, itemstack, pointed_thing)
end, end,
on_rotate = unifieddyes.fix_after_screwdriver_nsew, on_rotate = unifieddyes.fix_after_screwdriver_nsew,
light_source = onflag and (default.LIGHT_MAX - 2) or nil, light_source = brightn_light_source[light_brightn_name],
on_rightclick = homedecor.toggle_light, on_rightclick = homedecor.toggle_light,
drop = { drop = {
items = { items = {
@ -743,17 +699,17 @@ for _, onoff in ipairs({"on", "off"}) do
-- "kitchen"/"dining room" ceiling lamp -- "kitchen"/"dining room" ceiling lamp
homedecor.register("ceiling_lamp_"..onoff, { homedecor.register("ceiling_lamp_"..light_brightn_name, {
description = S("Ceiling Lamp/Light"), description = S("Ceiling Lamp/Light"),
mesh = "homedecor_ceiling_lamp.obj", mesh = "homedecor_ceiling_lamp.obj",
tiles = { tiles = {
"homedecor_generic_metal_brass.png", "homedecor_generic_metal_brass.png",
"homedecor_ceiling_lamp_glass.png", "homedecor_ceiling_lamp_glass.png",
"homedecor_table_generic_light_source_"..onoff..".png", gen_ls_tex_white,
{ name = "homedecor_generic_plastic.png", color = 0xff442d04 }, { name = "homedecor_generic_plastic.png", color = 0xff442d04 },
}, },
inventory_image = "homedecor_ceiling_lamp_inv.png", inventory_image = "homedecor_ceiling_lamp_inv.png",
light_source = onflag and default.LIGHT_MAX or nil, light_source = brightn_light_source[light_brightn_name],
groups = {snappy=3, not_in_creative_inventory = nici}, groups = {snappy=3, not_in_creative_inventory = nici},
walkable = false, walkable = false,
on_rightclick = homedecor.toggle_light, on_rightclick = homedecor.toggle_light,
@ -767,16 +723,16 @@ for _, onoff in ipairs({"on", "off"}) do
on_punch = digiline_on_punch on_punch = digiline_on_punch
}) })
-- rope lighting -- rope lighting
minetest.register_node(":homedecor:rope_light_on_floor_"..onoff, { minetest.register_node(":homedecor:rope_light_on_floor_"..light_brightn_name, {
description = "Rope lighting (on floor)", description = "Rope lighting (on floor)",
inventory_image = "homedecor_rope_light_on_floor.png", inventory_image = "homedecor_rope_light_on_floor.png",
paramtype = "light", paramtype = "light",
light_source = onflag and (default.LIGHT_MAX - 3) or nil, light_source = brightn_light_source[light_brightn_name],
walkable = false, walkable = false,
sunlight_propagates = true, sunlight_propagates = true,
tiles = { "homedecor_table_generic_light_source_"..onoff..".png" }, tiles = { gen_ls_tex_white },
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "connected", type = "connected",
@ -816,14 +772,14 @@ for _, onoff in ipairs({"on", "off"}) do
} }
}) })
minetest.register_node(":homedecor:rope_light_on_ceiling_"..onoff, { minetest.register_node(":homedecor:rope_light_on_ceiling_"..light_brightn_name, {
description = "Rope lighting (on ceiling)", description = "Rope lighting (on ceiling)",
inventory_image = "homedecor_rope_light_on_ceiling.png", inventory_image = "homedecor_rope_light_on_ceiling.png",
paramtype = "light", paramtype = "light",
light_source = onflag and (default.LIGHT_MAX - 3) or nil, light_source = brightn_light_source[light_brightn_name],
walkable = false, walkable = false,
sunlight_propagates = true, sunlight_propagates = true,
tiles = { "homedecor_table_generic_light_source_"..onoff..".png" }, tiles = { gen_ls_tex_white },
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "connected", type = "connected",
@ -863,10 +819,128 @@ for _, onoff in ipairs({"on", "off"}) do
} }
}) })
local tlamp_cbox = {
type = "fixed",
fixed = { -0.25, -0.5, -0.25, 0.25, 0.5, 0.25 }
}
local slamp_cbox = {
type = "fixed",
fixed = { -0.25, -0.5, -0.25, 0.25, 1.5, 0.25 }
}
local wool_brightened = "wool_grey.png^[colorize:#ffffff:"..(brightn_light_source[light_brightn_name] * 15)
homedecor.register("table_lamp_"..light_brightn_name, {
description = S("Table Lamp/Light"),
mesh = "homedecor_table_lamp.obj",
tiles = {
wool_brightened,
{ name = gen_ls_tex_white, color = brightn_hex[brightness] },
{ name = "homedecor_generic_wood_red.png", color = 0xffffffff },
{ name = "homedecor_generic_metal.png", color = homedecor.color_black },
},
inventory_image = "homedecor_table_lamp_foot_inv.png^homedecor_table_lamp_top_inv.png",
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette_extended.png",
walkable = false,
light_source = brightn_light_source[light_brightn_name],
selection_box = tlamp_cbox,
sounds = default.node_sound_wood_defaults(),
groups = {cracky=2,oddly_breakable_by_hand=1, ud_param2_colorable = 1, not_in_creative_inventory=nici },
drop = {
items = {
{items = {"homedecor:table_lamp_hi"}, inherit_color = true },
}
},
digiline = homedecor.digiline_xz_light,
mesecons = homedecor.mesecon_wall_light,
on_rightclick = on_rightclick,
on_punch = digiline_on_punch
})
homedecor.register("standing_lamp_"..light_brightn_name, {
description = S("Standing Lamp/Light"),
mesh = "homedecor_standing_lamp.obj",
tiles = {
wool_brightened,
{ name = gen_ls_tex_white, color = brightn_hex[brightness] },
{ name = "homedecor_generic_wood_red.png", color = 0xffffffff },
{ name = "homedecor_generic_metal.png", color = homedecor.color_black },
},
inventory_image = "homedecor_standing_lamp_foot_inv.png^homedecor_standing_lamp_top_inv.png",
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette_extended.png",
walkable = false,
light_source = brightn_light_source[light_brightn_name],
groups = {cracky=2,oddly_breakable_by_hand=1, ud_param2_colorable = 1, not_in_creative_inventory=nici },
selection_box = slamp_cbox,
sounds = default.node_sound_wood_defaults(),
on_rotate = screwdriver.rotate_simple,
--expand = { top="air" },
drop = {
items = {
{items = {"homedecor:standing_lamp_hi"}, inherit_color = true },
}
},
digiline = homedecor.digiline_xz_light,
mesecons = homedecor.mesecon_wall_light,
on_rightclick = on_rightclick,
on_punch = digiline_on_punch
})
end
end end
-- Light sources and other items that either don't turn on/off ------------------------------------------
-- or which need special light-control code. -- Simple non-dimmable, on/off-only lights
for _, light_brightn_name in ipairs({"off", "on"}) do
local onflag = (light_brightn_name == "on")
local lighttex = "homedecor_blanktile.png"
if onflag then
lighttex = {
name = "homedecor_plasma_ball_streamers.png",
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0},
}
end
homedecor.register("plasma_ball_"..light_brightn_name, {
description = S("Plasma Ball"),
mesh = "homedecor_plasma_ball.obj",
tiles = {
{ name = "homedecor_generic_plastic.png", color = homedecor.color_black },
lighttex,
"homedecor_plasma_ball_glass.png"
},
inventory_image = "homedecor_plasma_ball_inv.png",
selection_box = {
type = "fixed",
fixed = { -0.1875, -0.5, -0.1875, 0.1875, 0, 0.1875 }
},
walkable = false,
use_texture_alpha = true,
light_source = onflag and (default.LIGHT_MAX - 5) or nil,
sunlight_propagates = true,
groups = {cracky=3, oddly_breakable_by_hand=3, not_in_creative_inventory = nici},
sounds = default.node_sound_glass_defaults(),
on_rightclick = homedecor.toggle_light,
drop = {
items = {
{items = {"homedecor:plasma_ball_on"}},
}
},
mesecons = homedecor.mesecon_xz_light,
digiline = homedecor.digiline_xz_light,
on_punch = digiline_on_punch
})
end
-------------------------------------------------------
-- Light sources and other items that don't turn on/off
local tc_cbox = { local tc_cbox = {
type = "fixed", type = "fixed",
@ -1109,100 +1183,6 @@ local lamp_colors = {
"violet", "violet",
} }
local tlamp_cbox = {
type = "fixed",
fixed = { -0.25, -0.5, -0.25, 0.25, 0.5, 0.25 }
}
local slamp_cbox = {
type = "fixed",
fixed = { -0.25, -0.5, -0.25, 0.25, 1.5, 0.25 }
}
local function reg_lamp(suffix, nxt, light, brightness)
local wool_brighten = (light or 0) * 15
local onoff = (suffix == "off") and "off" or "on"
homedecor.register("table_lamp_"..suffix, {
description = S("Table Lamp/Light"),
mesh = "homedecor_table_lamp.obj",
tiles = {
"wool_grey.png^[colorize:#ffffff:"..wool_brighten,
{ name = "homedecor_table_generic_light_source_"..onoff..".png", color = brightness_tab[brightness] },
{ name = "homedecor_generic_wood_red.png", color = 0xffffffff },
{ name = "homedecor_generic_metal.png", color = homedecor.color_black },
},
inventory_image = "homedecor_table_lamp_foot_inv.png^homedecor_table_lamp_top_inv.png",
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette_extended.png",
walkable = false,
light_source = light,
selection_box = tlamp_cbox,
sounds = default.node_sound_wood_defaults(),
groups = {cracky=2,oddly_breakable_by_hand=1, ud_param2_colorable = 1,
not_in_creative_inventory=((light ~= nil) and 1) or nil,
},
drop = {
items = {
{items = {"homedecor:table_lamp_hi"}, inherit_color = true },
}
},
digiline = homedecor.digiline_xz_light,
mesecons = homedecor.mesecon_wall_light,
on_rightclick = on_rightclick,
on_punch = digiline_on_punch
})
homedecor.register("standing_lamp_"..suffix, {
description = S("Standing Lamp/Light"),
mesh = "homedecor_standing_lamp.obj",
tiles = {
"wool_grey.png^[colorize:#ffffff:"..wool_brighten,
{ name = "homedecor_table_generic_light_source_"..onoff..".png", color = brightness_tab[brightness] },
{ name = "homedecor_generic_wood_red.png", color = 0xffffffff },
{ name = "homedecor_generic_metal.png", color = homedecor.color_black },
},
inventory_image = "homedecor_standing_lamp_foot_inv.png^homedecor_standing_lamp_top_inv.png",
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette_extended.png",
walkable = false,
light_source = light,
groups = {cracky=2,oddly_breakable_by_hand=1, ud_param2_colorable = 1,
not_in_creative_inventory=((light ~= nil) and 1) or nil,
},
selection_box = slamp_cbox,
sounds = default.node_sound_wood_defaults(),
on_rotate = screwdriver.rotate_simple,
--expand = { top="air" },
drop = {
items = {
{items = {"homedecor:standing_lamp_hi"}, inherit_color = true },
}
},
digiline = homedecor.digiline_xz_light,
mesecons = homedecor.mesecon_wall_light,
on_rightclick = on_rightclick,
on_punch = digiline_on_punch
})
-- for old maps that had the original 3dforniture mod
minetest.register_alias("3dforniture:table_lamp_"..suffix, "homedecor:table_lamp_"..suffix)
end
reg_lamp("off", "low", nil, 1 )
reg_lamp("low", "med", 3, 2 )
reg_lamp("med", "hi", 7, 3 )
reg_lamp("hi", "max", 11, 4 )
reg_lamp("max", "off", 14, 5 )
-- mesecons compatibility
minetest.register_alias("homedecor:table_lamp_on", "homedecor:table_lamp_max")
minetest.register_alias("homedecor:standing_lamp_on", "homedecor:standing_lamp_max")
-- conversion LBM for param2 coloring -- conversion LBM for param2 coloring
homedecor.old_static_nodes = { homedecor.old_static_nodes = {
@ -1801,22 +1781,62 @@ minetest.register_alias("chains:chandelier_steel", "homedecor:chandelier
minetest.register_alias("chains:chandelier_brass", "homedecor:chandelier_brass") minetest.register_alias("chains:chandelier_brass", "homedecor:chandelier_brass")
minetest.register_alias("homedecor:glowlight_half", "homedecor:glowlight_half_on") minetest.register_alias("homedecor:glowlight_half", "homedecor:glowlight_half_on")
minetest.register_alias("homedecor:glowlight_half_max", "homedecor:glowlight_half_on")
minetest.register_alias("homedecor:glowlight_quarter", "homedecor:glowlight_quarter_on") minetest.register_alias("homedecor:glowlight_quarter", "homedecor:glowlight_quarter_on")
minetest.register_alias("homedecor:glowlight_quarter_max", "homedecor:glowlight_quarter_on")
minetest.register_alias("homedecor:glowlight_small_cube", "homedecor:glowlight_small_cube_on") minetest.register_alias("homedecor:glowlight_small_cube", "homedecor:glowlight_small_cube_on")
minetest.register_alias("homedecor:plasma_lamp", "homedecor:plasma_lamp_on") minetest.register_alias("homedecor:glowlight_small_cube_max", "homedecor:glowlight_small_cube_on")
minetest.register_alias("homedecor:plasma_ball", "homedecor:plasma_ball_on")
minetest.register_alias("homedecor:wall_lantern", "homedecor:ground_lantern")
minetest.register_alias("homedecor:ground_lantern", "homedecor:ground_lantern_on")
minetest.register_alias("homedecor:hanging_lantern", "homedecor:hanging_lantern_on")
minetest.register_alias("homedecor:ceiling_lamp", "homedecor:ceiling_lamp_on")
minetest.register_alias("homedecor:ceiling_lantern", "homedecor:ceiling_lantern_on")
minetest.register_alias("homedecor:lattice_lantern_large", "homedecor:lattice_lantern_large_on")
minetest.register_alias("homedecor:lattice_lantern_small", "homedecor:lattice_lantern_small_on")
minetest.register_alias("homedecor:desk_lamp", "homedecor:desk_lamp_on")
minetest.register_alias("homedecor:rope_light_on_floor", "homedecor:rope_light_on_floor_on") minetest.register_alias("homedecor:rope_light_on_floor", "homedecor:rope_light_on_floor_on")
minetest.register_alias("homedecor:rope_light_on_floor_max", "homedecor:rope_light_on_floor_on")
minetest.register_alias("homedecor:rope_light_on_ceiling", "homedecor:rope_light_on_ceiling_on") minetest.register_alias("homedecor:rope_light_on_ceiling", "homedecor:rope_light_on_ceiling_on")
minetest.register_alias("homedecor:rope_light_on_ceiling_max", "homedecor:rope_light_on_ceiling_on")
minetest.register_alias("homedecor:plasma_lamp", "homedecor:plasma_lamp_on")
minetest.register_alias("homedecor:plasma_lamp_max", "homedecor:plasma_lamp_on")
minetest.register_alias("homedecor:plasma_ball", "homedecor:plasma_ball_on")
minetest.register_alias("homedecor:plasma_ball_max", "homedecor:plasma_ball_on")
minetest.register_alias("homedecor:ground_lantern", "homedecor:ground_lantern_on")
minetest.register_alias("homedecor:ground_lantern_max", "homedecor:ground_lantern_on")
minetest.register_alias("homedecor:hanging_lantern", "homedecor:hanging_lantern_on")
minetest.register_alias("homedecor:hanging_lantern_max", "homedecor:hanging_lantern_on")
minetest.register_alias("homedecor:ceiling_lantern", "homedecor:ceiling_lantern_on")
minetest.register_alias("homedecor:ceiling_lantern_max", "homedecor:ceiling_lantern_on")
minetest.register_alias("homedecor:lattice_lantern_large", "homedecor:lattice_lantern_large_on")
minetest.register_alias("homedecor:lattice_lantern_large_max", "homedecor:lattice_lantern_large_on")
minetest.register_alias("homedecor:lattice_lantern_small", "homedecor:lattice_lantern_small_on")
minetest.register_alias("homedecor:lattice_lantern_small_max", "homedecor:lattice_lantern_small_on")
minetest.register_alias("homedecor:desk_lamp", "homedecor:desk_lamp_on")
minetest.register_alias("homedecor:desk_lamp_max", "homedecor:desk_lamp_on")
minetest.register_alias("homedecor:ceiling_lamp", "homedecor:ceiling_lamp_on")
minetest.register_alias("homedecor:ceiling_lamp_max", "homedecor:ceiling_lamp_on")
minetest.register_alias("homedecor:table_lamp", "homedecor:table_lamp_on")
minetest.register_alias("homedecor:table_lamp_max", "homedecor:table_lamp_on")
minetest.register_alias("homedecor:standing_lamp", "homedecor:standing_lamp_on")
minetest.register_alias("homedecor:standing_lamp_max", "homedecor:standing_lamp_on")
-- for old maps that had the original 3dforniture mod
minetest.register_alias("3dforniture:table_lamp", "homedecor:table_lamp_on")
if minetest.get_modpath("darkage") then if minetest.get_modpath("darkage") then
minetest.register_alias("homedecor:lattice_lantern_large_on", "darkage:lamp")
minetest.register_alias("homedecor:lattice_lantern_large_off", "darkage:lamp") minetest.register_alias("homedecor:lattice_lantern_large_off", "darkage:lamp")
minetest.register_alias("homedecor:lattice_lantern_large_low", "darkage:lamp")
minetest.register_alias("homedecor:lattice_lantern_large_med", "darkage:lamp")
minetest.register_alias("homedecor:lattice_lantern_large_hi", "darkage:lamp")
minetest.register_alias("homedecor:lattice_lantern_large_max", "darkage:lamp")
minetest.register_alias("homedecor:lattice_lantern_large_on", "darkage:lamp")
minetest.register_alias("homedecor:lattice_lantern_large", "darkage:lamp")
end end