1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2025-07-26 08:50: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?
darkage?
mesecons?
digilines?

View File

@ -11,23 +11,26 @@ local function is_protected(pos, clicker)
return false
end
-- control and brightness for dimmable lamps
local repl = {
["off"] = "low",
["low"] = "med",
["med"] = "hi",
["hi"] = "max",
["max"] = "off",
["on"] = "off",
}
local brightness_tab = {
0xffd0d0d0,
0xffd8d8d8,
0xffe0e0e0,
0xffe8e8e8,
0xffffffff,
local actions = {
action_off = function(pos, node)
local sep = string.find(node.name, "_o", -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, "_o", -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
}
local rules_xz = {
@ -60,34 +63,7 @@ local rules_toponly = {
{x = 0, y = 1, z = -1},
}
-- mesecons compatibility
local actions
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 = {
effector = table.copy(actions)
}
@ -111,34 +87,57 @@ if minetest.get_modpath("mesecons") then
end
-- 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 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 on_digiline_receive_string = function(pos, node, channel, msg)
local meta = minetest.get_meta(pos)
local setchan = meta:get_string("channel")
if setchan ~= channel then return end
if msg and msg ~= "" and type(msg) == "string" then
if msg == "off"
or msg == "low"
or msg == "med"
or msg == "hi"
or msg == "max" then
local basename = string.sub(node.name, 1, string.find(node.name, "_", -5) - 1)
minetest.swap_node(pos, {name = basename.."_"..msg, param2 = node.param2})
end
end
end
local repl = {
["off"] ="low",
["low"] ="med",
["med"] ="hi",
["hi"] ="max",
["max"] ="off",
}
local player_last_clicked = {}
local digiline_on_punch
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
local on_digiline_receive_string = function(pos, node, channel, msg)
local meta = minetest.get_meta(pos)
local setchan = meta:get_string("channel")
if setchan ~= channel then return end
if msg and msg ~= "" and type(msg) == "string" then
if msg == "off"
or msg == "low"
or msg == "med"
or msg == "hi"
or msg == "max"
or msg == "on" then
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})
end
end
end
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name()
local pos = player_last_clicked[name]
@ -151,54 +150,14 @@ if minetest.get_modpath("digilines") then
end
end)
if minetest.get_modpath("mesecons") then
homedecor.digiline_wall_light = {
effector = {
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 = {
dl_digiline = {
effector = {
action = on_digiline_receive_string,
},
wire = {
rules = rules_xz
}
rules = rules_xz
}
homedecor.digiline_alldir_light = {
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)
function dl_on_punch(pos, node, puncher, pointed_thing)
if is_protected(pos, puncher) then return end
if puncher:get_player_control().sneak then
@ -209,17 +168,23 @@ if minetest.get_modpath("digilines") then
minetest.show_formspec(name, "homedecor:lamp_set_channel", form)
end
end
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.swap_node(pos, {name = basename.."_"..repl[suffix], param2 = node.param2})
end
end
-- 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
local brightness_tab = {
0xffd0d0d0,
0xffd8d8d8,
0xffe0e0e0,
0xffe8e8e8,
0xffffffff,
}
function homedecor.toggle_light(pos, node, clicker, itemstack, pointed_thing)
if is_protected(pos, clicker) then return end
@ -229,9 +194,6 @@ function homedecor.toggle_light(pos, node, clicker, itemstack, pointed_thing)
minetest.swap_node(pos, {name = newname, param2 = node.param2})
end
-----
-- The actual lights! :-)
for _, onoff in ipairs({"on", "off"}) do
local onflag = (onoff == "on")
@ -315,9 +277,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:glowlight_half_on"}, inherit_color = true },
}
},
mesecons = homedecor.mesecon_wall_light,
digiline = homedecor.digiline_wall_light,
on_punch = digiline_on_punch
mesecons = homedecor.mesecon_wall_light
})
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 },
}
},
mesecons = homedecor.mesecon_wall_light,
digiline = homedecor.digiline_wall_light,
on_punch = digiline_on_punch
mesecons = homedecor.mesecon_wall_light
})
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 },
}
},
mesecons = homedecor.mesecon_wall_light,
digiline = homedecor.digiline_wall_light,
on_punch = digiline_on_punch
mesecons = homedecor.mesecon_wall_light
})
local lighttex
@ -481,9 +437,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:plasma_lamp_on"}},
}
},
mesecons = homedecor.mesecon_alldir_light,
digiline = homedecor.digiline_alldir_light,
on_punch = digiline_on_punch
mesecons = homedecor.mesecon_alldir_light
})
local lighttex = "homedecor_blanktile.png"
@ -519,9 +473,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:plasma_ball_on"}},
}
},
mesecons = homedecor.mesecon_xz_light,
digiline = homedecor.digiline_xz_light,
on_punch = digiline_on_punch
mesecons = homedecor.mesecon_xz_light
})
local gl_cbox = {
@ -553,9 +505,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:ground_lantern_on"}},
}
},
mesecons = homedecor.mesecon_xz_light,
digiline = homedecor.digiline_xz_light,
on_punch = digiline_on_punch
mesecons = homedecor.mesecon_xz_light
})
local hl_cbox = {
@ -580,9 +530,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:hanging_lantern_on"}},
}
},
mesecons = homedecor.mesecon_alldir_light,
digiline = homedecor.digiline_alldir_light,
on_punch = digiline_on_punch
mesecons = homedecor.mesecon_alldir_light
})
local cl_cbox = {
@ -607,9 +555,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:ceiling_lantern_on"}},
}
},
mesecons = homedecor.mesecon_toponly_light,
digiline = homedecor.digiline_toponly_light,
on_punch = digiline_on_punch
mesecons = homedecor.mesecon_toponly_light
})
if minetest.get_modpath("darkage") then
@ -634,9 +580,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:lattice_lantern_large_on"}},
}
},
mesecons = homedecor.mesecon_alldir_light,
digiline = homedecor.digiline_alldir_light,
on_punch = digiline_on_punch
mesecons = homedecor.mesecon_alldir_light
})
end
@ -676,9 +620,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:lattice_lantern_small_on"}},
}
},
mesecons = homedecor.mesecon_alldir_light,
digiline = homedecor.digiline_alldir_light,
on_punch = digiline_on_punch
mesecons = homedecor.mesecon_wall_light
})
-- "gooseneck" style desk lamps
@ -716,9 +658,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:desk_lamp_on"}, inherit_color = true },
}
},
mesecons = homedecor.mesecon_xz_light,
digiline = homedecor.digiline_xz_light,
on_punch = digiline_on_punch
mesecons = homedecor.mesecon_xz_light
})
-- "kitchen"/"dining room" ceiling lamp
@ -742,9 +682,7 @@ for _, onoff in ipairs({"on", "off"}) do
{items = {"homedecor:ceiling_lamp_on"}},
}
},
mesecons = homedecor.mesecon_toponly_light,
digiline = homedecor.digiline_toponly_light,
on_punch = digiline_on_punch
mesecons = homedecor.mesecon_toponly_light
})
-- rope lighting
@ -1129,10 +1067,9 @@ local function reg_lamp(suffix, nxt, light, brightness)
{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
digiline = dl_digiline,
on_rightclick = dl_on_rightclick,
on_punch = dl_on_punch
})
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 },
}
},
digiline = homedecor.digiline_xz_light,
mesecons = homedecor.mesecon_wall_light,
on_rightclick = on_rightclick,
on_punch = digiline_on_punch
digiline = dl_digiline,
on_rightclick = dl_on_rightclick,
on_punch = dl_on_punch
})
-- for old maps that had the original 3dforniture mod
minetest.register_alias("3dforniture:table_lamp_"..suffix, "homedecor:table_lamp_"..suffix)
end
@ -1179,9 +1114,6 @@ 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