summaryrefslogtreecommitdiff
path: root/homedecor_electrical
diff options
context:
space:
mode:
authorVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2019-05-27 15:07:25 -0400
committerVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2019-05-27 15:07:25 -0400
commit65fce91b5c5cd26c945bec2b4073df8664b9a8e4 (patch)
tree719ab3b1594c1b874697536808e635200a15b424 /homedecor_electrical
parent9e49bc6167e9ee9900fdd205026c3143687ed33e (diff)
downloaddreambuilder_modpack-65fce91b5c5cd26c945bec2b4073df8664b9a8e4.tar
dreambuilder_modpack-65fce91b5c5cd26c945bec2b4073df8664b9a8e4.tar.gz
dreambuilder_modpack-65fce91b5c5cd26c945bec2b4073df8664b9a8e4.tar.bz2
dreambuilder_modpack-65fce91b5c5cd26c945bec2b4073df8664b9a8e4.tar.xz
dreambuilder_modpack-65fce91b5c5cd26c945bec2b4073df8664b9a8e4.zip
update digistuff, farming, homedecor, signs_lib, simple streetlights
Diffstat (limited to 'homedecor_electrical')
-rw-r--r--homedecor_electrical/depends.txt2
-rw-r--r--homedecor_electrical/init.lua109
-rw-r--r--homedecor_electrical/textures/homedecor_light_switch_back.pngbin310 -> 368 bytes
-rw-r--r--homedecor_electrical/textures/homedecor_light_switch_edges.pngbin175 -> 167 bytes
-rw-r--r--homedecor_electrical/textures/homedecor_light_switch_front.pngbin142 -> 0 bytes
-rw-r--r--homedecor_electrical/textures/homedecor_light_switch_front_off.pngbin0 -> 281 bytes
-rw-r--r--homedecor_electrical/textures/homedecor_light_switch_front_on.pngbin0 -> 284 bytes
7 files changed, 84 insertions, 27 deletions
diff --git a/homedecor_electrical/depends.txt b/homedecor_electrical/depends.txt
index fb5d601..382015e 100644
--- a/homedecor_electrical/depends.txt
+++ b/homedecor_electrical/depends.txt
@@ -1,3 +1,5 @@
homedecor_common
default
basic_materials
+mesecons?
+mesecons_receiver?
diff --git a/homedecor_electrical/init.lua b/homedecor_electrical/init.lua
index c135021..53c7fbb 100644
--- a/homedecor_electrical/init.lua
+++ b/homedecor_electrical/init.lua
@@ -1,6 +1,40 @@
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", {
description = S("Power Outlet"),
tiles = {
@@ -28,35 +62,52 @@ homedecor.register("power_outlet", {
walkable = false
})
-homedecor.register("light_switch", {
- 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.png"
- },
- 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.03125, -0.3125, 0.40625, 0.03125, -0.25, 0.5 },
+for _, onoff in ipairs ({"on", "off"}) do
+ local model = {
+ { -0.125, -0.1875, 0.4375, 0.125, 0.125, 0.5 },
+ { -0.03125, 0, 0.40625, 0.03125, 0.0625, 0.5 },
+ }
+
+ if onoff == "on" then
+ model = {
+ { -0.125, -0.1875, 0.4375, 0.125, 0.125, 0.5 },
+ { -0.03125, -0.125, 0.40625, 0.03125, -0.0625, 0.5 },
}
- },
- 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
-})
+ end
+ 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.25, 0.375, 0.1875, 0.1875, 0.5 },
+ }
+ },
+ groups = {cracky=3, dig_immediate=2, mesecon_needs_receiver=1, not_in_creative_inventory = (onoff == "on") and 1 or nil},
+ walkable = false,
+ drop = {
+ items = {
+ {items = {"homedecor:light_switch_off"}, inherit_color = true },
+ }
+ },
+ mesecons = switch_receptor,
+ on_rightclick = on_rc
+ })
+end
homedecor.register("doorbell", {
tiles = { "homedecor_doorbell.png" },
@@ -92,7 +143,7 @@ minetest.register_craft( {
})
minetest.register_craft( {
- output = "homedecor:light_switch",
+ output = "homedecor:light_switch_off",
recipe = {
{"", "basic_materials:plastic_sheet", "basic_materials:copper_strip"},
{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:copper_strip"},
@@ -106,3 +157,7 @@ minetest.register_craft( {
{ "homedecor:light_switch", "basic_materials:energy_crystal_simple", "homedecor:speaker_driver" }
},
})
+
+-- aliases
+
+minetest.register_alias("homedecor:light_switch", "homedecor:light_switch_on")
diff --git a/homedecor_electrical/textures/homedecor_light_switch_back.png b/homedecor_electrical/textures/homedecor_light_switch_back.png
index 8ad7c7e..f3357d1 100644
--- a/homedecor_electrical/textures/homedecor_light_switch_back.png
+++ b/homedecor_electrical/textures/homedecor_light_switch_back.png
Binary files differ
diff --git a/homedecor_electrical/textures/homedecor_light_switch_edges.png b/homedecor_electrical/textures/homedecor_light_switch_edges.png
index 0db6f43..db6d618 100644
--- a/homedecor_electrical/textures/homedecor_light_switch_edges.png
+++ b/homedecor_electrical/textures/homedecor_light_switch_edges.png
Binary files differ
diff --git a/homedecor_electrical/textures/homedecor_light_switch_front.png b/homedecor_electrical/textures/homedecor_light_switch_front.png
deleted file mode 100644
index f91ab5e..0000000
--- a/homedecor_electrical/textures/homedecor_light_switch_front.png
+++ /dev/null
Binary files differ
diff --git a/homedecor_electrical/textures/homedecor_light_switch_front_off.png b/homedecor_electrical/textures/homedecor_light_switch_front_off.png
new file mode 100644
index 0000000..eecc8b3
--- /dev/null
+++ b/homedecor_electrical/textures/homedecor_light_switch_front_off.png
Binary files differ
diff --git a/homedecor_electrical/textures/homedecor_light_switch_front_on.png b/homedecor_electrical/textures/homedecor_light_switch_front_on.png
new file mode 100644
index 0000000..1b6c3f6
--- /dev/null
+++ b/homedecor_electrical/textures/homedecor_light_switch_front_on.png
Binary files differ