1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2025-07-27 01:10:18 +02:00

Compare commits

..

1 Commits

Author SHA1 Message Date
6c6cb347fd move door 3d models to "3d extras" mod
by extension, require its presence to cause doors to be 3d

for consistency with the appearance/style of mtg doors in worlds that
wouldn't normally use the 3d extras mod
2019-05-28 07:57:23 -04:00
2 changed files with 102 additions and 171 deletions

View File

@ -7,4 +7,3 @@ moreblocks?
building_blocks? building_blocks?
darkage? darkage?
mesecons? mesecons?
digilines?

View File

@ -11,23 +11,26 @@ local function is_protected(pos, clicker)
return false return false
end end
-- control and brightness for dimmable lamps local actions = {
action_off = function(pos, node)
local repl = { local sep = string.find(node.name, "_o", -5)
["off"] = "low", local onoff = string.sub(node.name, sep + 1)
["low"] = "med", if minetest.get_meta(pos):get_int("toggled") > 0 then
["med"] = "hi", minetest.swap_node(pos, {
["hi"] = "max", name = string.sub(node.name, 1, sep - 1).."_off",
["max"] = "off", param2 = node.param2
["on"] = "off", })
} end
end,
local brightness_tab = { action_on = function(pos, node)
0xffd0d0d0, minetest.get_meta(pos):set_int("toggled", 1)
0xffd8d8d8, local sep = string.find(node.name, "_o", -5)
0xffe0e0e0, local onoff = string.sub(node.name, sep + 1)
0xffe8e8e8, minetest.swap_node(pos, {
0xffffffff, name = string.sub(node.name, 1, sep - 1).."_on",
param2 = node.param2
})
end
} }
local rules_xz = { local rules_xz = {
@ -60,34 +63,7 @@ local rules_toponly = {
{x = 0, y = 1, z = -1}, {x = 0, y = 1, z = -1},
} }
-- mesecons compatibility
local actions
if minetest.get_modpath("mesecons") then if minetest.get_modpath("mesecons") then
actions = {
action_off = function(pos, node)
local sep = string.find(node.name, "_", -5)
local onoff = string.sub(node.name, sep + 1)
if minetest.get_meta(pos):get_int("toggled") > 0 then
minetest.swap_node(pos, {
name = string.sub(node.name, 1, sep - 1).."_off",
param2 = node.param2
})
end
end,
action_on = function(pos, node)
minetest.get_meta(pos):set_int("toggled", 1)
local sep = string.find(node.name, "_", -5)
local onoff = string.sub(node.name, sep + 1)
minetest.swap_node(pos, {
name = string.sub(node.name, 1, sep - 1).."_on",
param2 = node.param2
})
end
}
homedecor.mesecon_wall_light = { homedecor.mesecon_wall_light = {
effector = table.copy(actions) effector = table.copy(actions)
} }
@ -111,15 +87,19 @@ if minetest.get_modpath("mesecons") then
end end
-- digilines compatibility -- digilines compatibility
-- this one is based on the so-named one in Jeija's digilines mod -- the following functions are based on the so-named ones in Jeija's digilines mod
local player_last_clicked = {} local on_digiline_receive_std = function(pos, node, channel, msg)
local meta = minetest.get_meta(pos)
local setchan = meta:get_string("channel")
if setchan ~= channel then return end
local num = tonumber(msg)
if msg == "colon" or msg == "period" or msg == "off" or (num and (num >= 0 and num <= 9)) then
minetest.swap_node(pos, { name = "led_marquee:marquee_"..msg, param2 = node.param2})
end
end
local digiline_on_punch local on_digiline_receive_string = function(pos, node, channel, msg)
if minetest.get_modpath("digilines") then
local on_digiline_receive_string = function(pos, node, channel, msg)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local setchan = meta:get_string("channel") local setchan = meta:get_string("channel")
@ -129,16 +109,35 @@ if minetest.get_modpath("digilines") then
or msg == "low" or msg == "low"
or msg == "med" or msg == "med"
or msg == "hi" or msg == "hi"
or msg == "max" or msg == "max" then
or msg == "on" then
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 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})
end end
end end
end end
end
local repl = {
["off"] ="low",
["low"] ="med",
["med"] ="hi",
["hi"] ="max",
["max"] ="off",
}
local player_last_clicked = {}
local dl_onreceive
local dl_digiline
local dl_on_punch
local function dl_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.set_node(pos, {name = basename.."_"..repl[suffix], param2 = node.param2})
end
if minetest.get_modpath("digilines") then
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name() local name = player:get_player_name()
local pos = player_last_clicked[name] local pos = player_last_clicked[name]
@ -151,54 +150,14 @@ if minetest.get_modpath("digilines") then
end end
end) end)
if minetest.get_modpath("mesecons") then dl_digiline = {
homedecor.digiline_wall_light = {
effector = { effector = {
action = on_digiline_receive_string, action = on_digiline_receive_string,
}, },
wire = {
rules = mesecon.rules.wallmounted_get
}
}
else
homedecor.digiline_wall_light = {
effector = {
action = on_digiline_receive_string,
},
wire = {
rules = rules_alldir
}
}
end
homedecor.digiline_xz_light = {
effector = {
action = on_digiline_receive_string,
},
wire = {
rules = rules_xz rules = rules_xz
} }
}
homedecor.digiline_alldir_light = { function dl_on_punch(pos, node, puncher, pointed_thing)
effector = {
action = on_digiline_receive_string,
},
wire = {
rules = rules_alldir
}
}
homedecor.digiline_toponly_light = {
effector = {
action = on_digiline_receive_string,
},
wire = {
rules = rules_toponly
}
}
function digiline_on_punch(pos, node, puncher, pointed_thing)
if is_protected(pos, puncher) then return end if is_protected(pos, puncher) then return end
if puncher:get_player_control().sneak then if puncher:get_player_control().sneak then
@ -209,18 +168,24 @@ if minetest.get_modpath("digilines") then
minetest.show_formspec(name, "homedecor:lamp_set_channel", form) minetest.show_formspec(name, "homedecor:lamp_set_channel", form)
end end
end end
end
-- turn on/off, cycle brightness function dl_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
function on_rightclick(pos, node, clicker, itemstack, pointed_thing)
if is_protected(pos, clicker) then return end if is_protected(pos, clicker) then return end
local delim = string.find(node.name, "_", -5) local delim = string.find(node.name, "_", -5)
local basename = string.sub(node.name, 1, delim - 1) local basename = string.sub(node.name, 1, delim - 1)
local suffix = string.sub(node.name, delim + 1) local suffix = string.sub(node.name, delim + 1)
minetest.swap_node(pos, {name = basename.."_"..repl[suffix], param2 = node.param2}) minetest.swap_node(pos, {name = basename.."_"..repl[suffix], param2 = node.param2})
end
end end
local brightness_tab = {
0xffd0d0d0,
0xffd8d8d8,
0xffe0e0e0,
0xffe8e8e8,
0xffffffff,
}
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)
@ -229,9 +194,6 @@ 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! :-)
for _, onoff in ipairs({"on", "off"}) do for _, onoff in ipairs({"on", "off"}) do
local onflag = (onoff == "on") local onflag = (onoff == "on")
@ -315,9 +277,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:glowlight_half_on"}, inherit_color = true }, {items = {"homedecor:glowlight_half_on"}, inherit_color = true },
} }
}, },
mesecons = homedecor.mesecon_wall_light, mesecons = homedecor.mesecon_wall_light
digiline = homedecor.digiline_wall_light,
on_punch = digiline_on_punch
}) })
sides_edges = "homedecor_glowlight_thin_sides_edges.png" sides_edges = "homedecor_glowlight_thin_sides_edges.png"
@ -380,9 +340,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:glowlight_quarter_on"}, inherit_color = true }, {items = {"homedecor:glowlight_quarter_on"}, inherit_color = true },
} }
}, },
mesecons = homedecor.mesecon_wall_light, mesecons = homedecor.mesecon_wall_light
digiline = homedecor.digiline_wall_light,
on_punch = digiline_on_punch
}) })
tb_edges = "homedecor_glowlight_cube_tb_edges.png" tb_edges = "homedecor_glowlight_cube_tb_edges.png"
@ -446,9 +404,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:glowlight_small_cube_on"}, inherit_color = true }, {items = {"homedecor:glowlight_small_cube_on"}, inherit_color = true },
} }
}, },
mesecons = homedecor.mesecon_wall_light, mesecons = homedecor.mesecon_wall_light
digiline = homedecor.digiline_wall_light,
on_punch = digiline_on_punch
}) })
local lighttex local lighttex
@ -481,9 +437,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:plasma_lamp_on"}}, {items = {"homedecor:plasma_lamp_on"}},
} }
}, },
mesecons = homedecor.mesecon_alldir_light, mesecons = homedecor.mesecon_alldir_light
digiline = homedecor.digiline_alldir_light,
on_punch = digiline_on_punch
}) })
local lighttex = "homedecor_blanktile.png" local lighttex = "homedecor_blanktile.png"
@ -519,9 +473,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:plasma_ball_on"}}, {items = {"homedecor:plasma_ball_on"}},
} }
}, },
mesecons = homedecor.mesecon_xz_light, mesecons = homedecor.mesecon_xz_light
digiline = homedecor.digiline_xz_light,
on_punch = digiline_on_punch
}) })
local gl_cbox = { local gl_cbox = {
@ -553,9 +505,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:ground_lantern_on"}}, {items = {"homedecor:ground_lantern_on"}},
} }
}, },
mesecons = homedecor.mesecon_xz_light, mesecons = homedecor.mesecon_xz_light
digiline = homedecor.digiline_xz_light,
on_punch = digiline_on_punch
}) })
local hl_cbox = { local hl_cbox = {
@ -580,9 +530,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:hanging_lantern_on"}}, {items = {"homedecor:hanging_lantern_on"}},
} }
}, },
mesecons = homedecor.mesecon_alldir_light, mesecons = homedecor.mesecon_alldir_light
digiline = homedecor.digiline_alldir_light,
on_punch = digiline_on_punch
}) })
local cl_cbox = { local cl_cbox = {
@ -607,9 +555,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:ceiling_lantern_on"}}, {items = {"homedecor:ceiling_lantern_on"}},
} }
}, },
mesecons = homedecor.mesecon_toponly_light, mesecons = homedecor.mesecon_toponly_light
digiline = homedecor.digiline_toponly_light,
on_punch = digiline_on_punch
}) })
if minetest.get_modpath("darkage") then if minetest.get_modpath("darkage") then
@ -634,9 +580,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:lattice_lantern_large_on"}}, {items = {"homedecor:lattice_lantern_large_on"}},
} }
}, },
mesecons = homedecor.mesecon_alldir_light, mesecons = homedecor.mesecon_alldir_light
digiline = homedecor.digiline_alldir_light,
on_punch = digiline_on_punch
}) })
end end
@ -676,9 +620,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:lattice_lantern_small_on"}}, {items = {"homedecor:lattice_lantern_small_on"}},
} }
}, },
mesecons = homedecor.mesecon_alldir_light, mesecons = homedecor.mesecon_wall_light
digiline = homedecor.digiline_alldir_light,
on_punch = digiline_on_punch
}) })
-- "gooseneck" style desk lamps -- "gooseneck" style desk lamps
@ -716,9 +658,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:desk_lamp_on"}, inherit_color = true }, {items = {"homedecor:desk_lamp_on"}, inherit_color = true },
} }
}, },
mesecons = homedecor.mesecon_xz_light, mesecons = homedecor.mesecon_xz_light
digiline = homedecor.digiline_xz_light,
on_punch = digiline_on_punch
}) })
-- "kitchen"/"dining room" ceiling lamp -- "kitchen"/"dining room" ceiling lamp
@ -742,9 +682,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:ceiling_lamp_on"}}, {items = {"homedecor:ceiling_lamp_on"}},
} }
}, },
mesecons = homedecor.mesecon_toponly_light, mesecons = homedecor.mesecon_toponly_light
digiline = homedecor.digiline_toponly_light,
on_punch = digiline_on_punch
}) })
-- rope lighting -- rope lighting
@ -1129,10 +1067,9 @@ local function reg_lamp(suffix, nxt, light, brightness)
{items = {"homedecor:table_lamp_hi"}, inherit_color = true }, {items = {"homedecor:table_lamp_hi"}, inherit_color = true },
} }
}, },
digiline = homedecor.digiline_xz_light, digiline = dl_digiline,
mesecons = homedecor.mesecon_wall_light, on_rightclick = dl_on_rightclick,
on_rightclick = on_rightclick, on_punch = dl_on_punch
on_punch = digiline_on_punch
}) })
homedecor.register("standing_lamp_"..suffix, { homedecor.register("standing_lamp_"..suffix, {
@ -1162,13 +1099,11 @@ local function reg_lamp(suffix, nxt, light, brightness)
{items = {"homedecor:standing_lamp_hi"}, inherit_color = true }, {items = {"homedecor:standing_lamp_hi"}, inherit_color = true },
} }
}, },
digiline = homedecor.digiline_xz_light, digiline = dl_digiline,
mesecons = homedecor.mesecon_wall_light, on_rightclick = dl_on_rightclick,
on_rightclick = on_rightclick, on_punch = dl_on_punch
on_punch = digiline_on_punch
}) })
-- for old maps that had the original 3dforniture mod -- for old maps that had the original 3dforniture mod
minetest.register_alias("3dforniture:table_lamp_"..suffix, "homedecor:table_lamp_"..suffix) minetest.register_alias("3dforniture:table_lamp_"..suffix, "homedecor:table_lamp_"..suffix)
end end
@ -1179,9 +1114,6 @@ reg_lamp("med", "hi", 7, 3 )
reg_lamp("hi", "max", 11, 4 ) reg_lamp("hi", "max", 11, 4 )
reg_lamp("max", "off", 14, 5 ) 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