summaryrefslogtreecommitdiff
path: root/mesecons_insulated
diff options
context:
space:
mode:
authorJeija <norrepli@gmail.com>2012-12-11 19:49:55 +0100
committerJeija <norrepli@gmail.com>2012-12-11 19:49:55 +0100
commitde46729b971b5e59394834b8a01d4a7005318114 (patch)
tree5a2cf1f18b485ddefa8e255ac6d6a600ef2e2e12 /mesecons_insulated
parent31f3c99288355193dc68a6e83dfc63140fd02fa0 (diff)
parent5540fcbcb31eb32003fa0391113ed3b1dea25e47 (diff)
downloadmesecons-de46729b971b5e59394834b8a01d4a7005318114.tar
mesecons-de46729b971b5e59394834b8a01d4a7005318114.tar.gz
mesecons-de46729b971b5e59394834b8a01d4a7005318114.tar.bz2
mesecons-de46729b971b5e59394834b8a01d4a7005318114.tar.xz
mesecons-de46729b971b5e59394834b8a01d4a7005318114.zip
Merge branch 'mesecons_in_nodedef'
Conflicts: mesecons/internal.lua
Diffstat (limited to 'mesecons_insulated')
-rw-r--r--mesecons_insulated/init.lua41
1 files changed, 22 insertions, 19 deletions
diff --git a/mesecons_insulated/init.lua b/mesecons_insulated/init.lua
index 5b48716..8bf75c7 100644
--- a/mesecons_insulated/init.lua
+++ b/mesecons_insulated/init.lua
@@ -1,3 +1,12 @@
+function insulated_wire_get_rules(node)
+ local rules = {{x = 1, y = 0, z = 0},
+ {x =-1, y = 0, z = 0}}
+ if node.param2 == 1 or node.param2 == 3 then
+ return mesecon:rotate_rules_right(rules)
+ end
+ return rules
+end
+
minetest.register_node("mesecons_insulated:insulated_on", {
drawtype = "nodebox",
description = "insulated mesecons",
@@ -21,9 +30,13 @@ minetest.register_node("mesecons_insulated:insulated_on", {
type = "fixed",
fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
},
- groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1, not_in_creative_inventory = 1},
+ groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "mesecons_insulated:insulated_off",
-
+ mesecons = {conductor = {
+ state = mesecon.state.on,
+ offstate = "mesecons_insulated:insulated_off",
+ rules = insulated_wire_get_rules
+ }}
})
minetest.register_node("mesecons_insulated:insulated_off", {
@@ -49,7 +62,12 @@ minetest.register_node("mesecons_insulated:insulated_off", {
type = "fixed",
fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
},
- groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1},
+ groups = {dig_immediate = 3},
+ mesecons = {conductor = {
+ state = mesecon.state.off,
+ onstate = "mesecons_insulated:insulated_on",
+ rules = insulated_wire_get_rules
+ }}
})
minetest.register_craft({
@@ -61,21 +79,6 @@ minetest.register_craft({
}
})
-mesecon:add_rules("insulated_all", { --all possible rules
-{x = 1, y = 0, z = 0},
-{x =-1, y = 0, z = 0},
-{x = 0, y = 0, z = 1},
-{x = 0, y = 0, z =-1},})
-
mesecon:add_rules("insulated", {
{x = 1, y = 0, z = 0},
-{x =-1, y = 0, z = 0},})
-
-function insulated_wire_get_rules(param2)
- if param2 == 1 or param2 == 3 then
- return mesecon:rotate_rules_right(mesecon:get_rules("insulated"))
- end
- return mesecon:get_rules("insulated")
-end
-
-mesecon:register_conductor("mesecons_insulated:insulated_on", "mesecons_insulated:insulated_off", mesecon:get_rules("insulated_all"), insulated_wire_get_rules)
+{x =-1, y = 0, z = 0}})