mirror of
https://github.com/mt-mods/homedecor_modpack.git
synced 2024-12-22 16:10:18 +01:00
make wall switch work (mesecons)
This commit is contained in:
parent
cacf04e2d1
commit
b85278fbaa
@ -1,3 +1,5 @@
|
|||||||
homedecor_common
|
homedecor_common
|
||||||
default
|
default
|
||||||
basic_materials
|
basic_materials
|
||||||
|
mesecons?
|
||||||
|
mesecons_receiver?
|
||||||
|
@ -1,6 +1,40 @@
|
|||||||
|
|
||||||
local S = homedecor.gettext
|
local S = homedecor.gettext
|
||||||
|
|
||||||
|
function homedecor.toggle_switch(pos, node, clicker, itemstack, pointed_thing)
|
||||||
|
if minetest.is_protected(pos, clicker:get_player_name()) then
|
||||||
|
minetest.record_protection_violation(pos,
|
||||||
|
sender:get_player_name())
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local sep = string.find(node.name, "_o", -5)
|
||||||
|
local onoff = string.sub(node.name, sep + 1)
|
||||||
|
local newname = string.sub(node.name, 1, sep - 1)..((onoff == "off") and "_on" or "_off")
|
||||||
|
minetest.swap_node(pos, {name = newname, param2 = node.param2})
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local on_rc
|
||||||
|
local switch_receptor
|
||||||
|
|
||||||
|
if minetest.get_modpath("mesecons") then
|
||||||
|
on_rc = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
|
local t = homedecor.toggle_switch(pos, node, clicker, itemstack, pointed_thing)
|
||||||
|
if not t then return end
|
||||||
|
if string.find(node.name, "_on", -5) then
|
||||||
|
mesecon.receptor_off(pos, mesecon.rules.buttonlike_get(node))
|
||||||
|
else
|
||||||
|
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
switch_receptor = {
|
||||||
|
receptor = {
|
||||||
|
state = mesecon.state[onoff],
|
||||||
|
rules = mesecon.rules.buttonlike_get
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
homedecor.register("power_outlet", {
|
homedecor.register("power_outlet", {
|
||||||
description = S("Power Outlet"),
|
description = S("Power Outlet"),
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -28,35 +62,52 @@ homedecor.register("power_outlet", {
|
|||||||
walkable = false
|
walkable = false
|
||||||
})
|
})
|
||||||
|
|
||||||
homedecor.register("light_switch", {
|
for _, onoff in ipairs ({"on", "off"}) do
|
||||||
description = S("Light switch"),
|
|
||||||
tiles = {
|
local model = {
|
||||||
"homedecor_light_switch_edges.png",
|
{ -0.125, -0.5, 0.4375, 0.125, -0.1875, 0.5 },
|
||||||
"homedecor_light_switch_edges.png",
|
{ -0.03125, -0.3125, 0.40625, 0.03125, -0.25, 0.5 },
|
||||||
"homedecor_light_switch_edges.png",
|
}
|
||||||
"homedecor_light_switch_edges.png",
|
|
||||||
"homedecor_light_switch_back.png",
|
if onoff == "on" then
|
||||||
"homedecor_light_switch_front.png"
|
model = {
|
||||||
},
|
|
||||||
inventory_image = "homedecor_light_switch_inv.png",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{ -0.125, -0.5, 0.4375, 0.125, -0.1875, 0.5 },
|
{ -0.125, -0.5, 0.4375, 0.125, -0.1875, 0.5 },
|
||||||
{ -0.03125, -0.3125, 0.40625, 0.03125, -0.25, 0.5 },
|
{ -0.03125, -0.4375, 0.40625, 0.03125, -0.375, 0.5 },
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
end
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{ -0.1875, -0.5625, 0.375, 0.1875, -0.1250, 0.5 },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
groups = {cracky=3,dig_immediate=2},
|
|
||||||
walkable = false
|
|
||||||
})
|
|
||||||
|
|
||||||
|
homedecor.register("light_switch_"..onoff, {
|
||||||
|
description = S("Light switch"),
|
||||||
|
tiles = {
|
||||||
|
"homedecor_light_switch_edges.png",
|
||||||
|
"homedecor_light_switch_edges.png",
|
||||||
|
"homedecor_light_switch_edges.png",
|
||||||
|
"homedecor_light_switch_edges.png",
|
||||||
|
"homedecor_light_switch_back.png",
|
||||||
|
"homedecor_light_switch_front_"..onoff..".png"
|
||||||
|
},
|
||||||
|
inventory_image = "homedecor_light_switch_inv.png",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = model
|
||||||
|
},
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{ -0.1875, -0.5625, 0.375, 0.1875, -0.1250, 0.5 },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
groups = {cracky=3,dig_immediate=2},
|
||||||
|
walkable = false,
|
||||||
|
drop = {
|
||||||
|
items = {
|
||||||
|
{items = {"homedecor:light_switch_off"}, inherit_color = true },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mesecons = switch_receptor,
|
||||||
|
on_rightclick = on_rc
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
homedecor.register("doorbell", {
|
homedecor.register("doorbell", {
|
||||||
tiles = { "homedecor_doorbell.png" },
|
tiles = { "homedecor_doorbell.png" },
|
||||||
@ -106,3 +157,7 @@ minetest.register_craft( {
|
|||||||
{ "homedecor:light_switch", "basic_materials:energy_crystal_simple", "homedecor:speaker_driver" }
|
{ "homedecor:light_switch", "basic_materials:energy_crystal_simple", "homedecor:speaker_driver" }
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- aliases
|
||||||
|
|
||||||
|
minetest.register_alias("homedecor:light_switch", "homedecor:light_switch_on")
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 142 B |
Binary file not shown.
After Width: | Height: | Size: 284 B |
Binary file not shown.
After Width: | Height: | Size: 360 B |
Loading…
Reference in New Issue
Block a user