summaryrefslogtreecommitdiff
path: root/mesecons/mesecons_receiver
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2016-04-01 20:02:19 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2016-04-01 21:09:33 -0400
commitda66780a569712c23ae4f2996cfb4608a9f9d69d (patch)
tree217556029a78bc23ad4564720afc86de97228a04 /mesecons/mesecons_receiver
parent615b22df4d423aded3613db7716943a2f389b047 (diff)
downloaddreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.gz
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.bz2
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.xz
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.zip
copy all standard Dreambuilder mods in from the old subgame
(exactly as last supplied there, updates to these mods will follow later)
Diffstat (limited to 'mesecons/mesecons_receiver')
-rw-r--r--mesecons/mesecons_receiver/depends.txt1
-rw-r--r--mesecons/mesecons_receiver/init.lua158
-rw-r--r--mesecons/mesecons_receiver/textures/receiver_bottom_off.pngbin0 -> 494 bytes
-rw-r--r--mesecons/mesecons_receiver/textures/receiver_bottom_on.pngbin0 -> 239 bytes
-rw-r--r--mesecons/mesecons_receiver/textures/receiver_fb_off.pngbin0 -> 494 bytes
-rw-r--r--mesecons/mesecons_receiver/textures/receiver_fb_on.pngbin0 -> 239 bytes
-rw-r--r--mesecons/mesecons_receiver/textures/receiver_lr_off.pngbin0 -> 494 bytes
-rw-r--r--mesecons/mesecons_receiver/textures/receiver_lr_on.pngbin0 -> 239 bytes
-rw-r--r--mesecons/mesecons_receiver/textures/receiver_top_off.pngbin0 -> 494 bytes
-rw-r--r--mesecons/mesecons_receiver/textures/receiver_top_on.pngbin0 -> 239 bytes
10 files changed, 159 insertions, 0 deletions
diff --git a/mesecons/mesecons_receiver/depends.txt b/mesecons/mesecons_receiver/depends.txt
new file mode 100644
index 0000000..acaa924
--- /dev/null
+++ b/mesecons/mesecons_receiver/depends.txt
@@ -0,0 +1 @@
+mesecons
diff --git a/mesecons/mesecons_receiver/init.lua b/mesecons/mesecons_receiver/init.lua
new file mode 100644
index 0000000..4d60365
--- /dev/null
+++ b/mesecons/mesecons_receiver/init.lua
@@ -0,0 +1,158 @@
+rcvboxes = {
+ { -3/16, -3/16, -8/16 , 3/16, 3/16 , -13/32 }, -- the smaller bump
+ { -1/32, -1/32, -3/2 , 1/32, 1/32 , -1/2 }, -- the wire through the block
+ { -2/32, -1/2 , -.5 , 2/32, 0 , -.5002+3/32 }, -- the vertical wire bit
+ { -2/32, -1/2 , -7/16+0.002 , 2/32, -14/32, 16/32+0.001 } -- the horizontal wire
+}
+
+local receiver_get_rules = function (node)
+ local rules = { {x = 1, y = 0, z = 0},
+ {x = -2, y = 0, z = 0}}
+ if node.param2 == 2 then
+ rules = mesecon.rotate_rules_left(rules)
+ elseif node.param2 == 3 then
+ rules = mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules))
+ elseif node.param2 == 0 then
+ rules = mesecon.rotate_rules_right(rules)
+ end
+ return rules
+end
+
+minetest.register_node("mesecons_receiver:receiver_on", {
+ drawtype = "nodebox",
+ tiles = {
+ "receiver_top_on.png",
+ "receiver_bottom_on.png",
+ "receiver_lr_on.png",
+ "receiver_lr_on.png",
+ "receiver_fb_on.png",
+ "receiver_fb_on.png",
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ sunlight_propagates = true,
+ walkable = false,
+ selection_box = {
+ type = "fixed",
+ fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
+ },
+ node_box = {
+ type = "fixed",
+ fixed = rcvboxes
+ },
+ groups = {dig_immediate = 3, not_in_creative_inventory = 1},
+ drop = "mesecons:wire_00000000_off",
+ mesecons = {conductor = {
+ state = mesecon.state.on,
+ rules = receiver_get_rules,
+ offstate = "mesecons_receiver:receiver_off"
+ }}
+})
+
+minetest.register_node("mesecons_receiver:receiver_off", {
+ drawtype = "nodebox",
+ description = "You hacker you",
+ tiles = {
+ "receiver_top_off.png",
+ "receiver_bottom_off.png",
+ "receiver_lr_off.png",
+ "receiver_lr_off.png",
+ "receiver_fb_off.png",
+ "receiver_fb_off.png",
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ sunlight_propagates = true,
+ walkable = false,
+ selection_box = {
+ type = "fixed",
+ fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
+ },
+ node_box = {
+ type = "fixed",
+ fixed = rcvboxes
+ },
+ groups = {dig_immediate = 3, not_in_creative_inventory = 1},
+ drop = "mesecons:wire_00000000_off",
+ mesecons = {conductor = {
+ state = mesecon.state.off,
+ rules = receiver_get_rules,
+ onstate = "mesecons_receiver:receiver_on"
+ }}
+})
+
+function mesecon.receiver_get_pos_from_rcpt(pos, param2)
+ local rules = {{x = 2, y = 0, z = 0}}
+ if param2 == nil then param2 = minetest.get_node(pos).param2 end
+ if param2 == 2 then
+ rules = mesecon.rotate_rules_left(rules)
+ elseif param2 == 3 then
+ rules = mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules))
+ elseif param2 == 0 then
+ rules = mesecon.rotate_rules_right(rules)
+ end
+ local np = { x = pos.x + rules[1].x,
+ y = pos.y + rules[1].y,
+ z = pos.z + rules[1].z}
+ return np
+end
+
+function mesecon.receiver_place(rcpt_pos)
+ local node = minetest.get_node(rcpt_pos)
+ local pos = mesecon.receiver_get_pos_from_rcpt(rcpt_pos, node.param2)
+ local nn = minetest.get_node(pos)
+
+ if string.find(nn.name, "mesecons:wire_") ~= nil then
+ minetest.dig_node(pos)
+ if mesecon.is_power_on(rcpt_pos) then
+ minetest.add_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2})
+ mesecon.receptor_on(pos, receiver_get_rules(node))
+ else
+ minetest.add_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2})
+ end
+ mesecon.update_autoconnect(pos)
+ end
+end
+
+function mesecon.receiver_remove(rcpt_pos, dugnode)
+ local pos = mesecon.receiver_get_pos_from_rcpt(rcpt_pos, dugnode.param2)
+ local nn = minetest.get_node(pos)
+ if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then
+ minetest.dig_node(pos)
+ local node = {name = "mesecons:wire_00000000_off"}
+ minetest.add_node(pos, node)
+ mesecon.update_autoconnect(pos)
+ mesecon.on_placenode(pos, node)
+ end
+end
+
+minetest.register_on_placenode(function (pos, node)
+ if minetest.get_item_group(node.name, "mesecon_needs_receiver") == 1 then
+ mesecon.receiver_place(pos)
+ end
+end)
+
+minetest.register_on_dignode(function(pos, node)
+ if minetest.get_item_group(node.name, "mesecon_needs_receiver") == 1 then
+ mesecon.receiver_remove(pos, node)
+ end
+end)
+
+minetest.register_on_placenode(function (pos, node)
+ if string.find(node.name, "mesecons:wire_") ~=nil then
+ local rules = { {x = 2, y = 0, z = 0},
+ {x =-2, y = 0, z = 0},
+ {x = 0, y = 0, z = 2},
+ {x = 0, y = 0, z =-2}}
+ local i = 1
+ while rules[i] ~= nil do
+ local np = { x = pos.x + rules[i].x,
+ y = pos.y + rules[i].y,
+ z = pos.z + rules[i].z}
+ if minetest.get_item_group(minetest.get_node(np).name, "mesecon_needs_receiver") == 1 then
+ mesecon.receiver_place(np)
+ end
+ i = i + 1
+ end
+ end
+end)
diff --git a/mesecons/mesecons_receiver/textures/receiver_bottom_off.png b/mesecons/mesecons_receiver/textures/receiver_bottom_off.png
new file mode 100644
index 0000000..b95903e
--- /dev/null
+++ b/mesecons/mesecons_receiver/textures/receiver_bottom_off.png
Binary files differ
diff --git a/mesecons/mesecons_receiver/textures/receiver_bottom_on.png b/mesecons/mesecons_receiver/textures/receiver_bottom_on.png
new file mode 100644
index 0000000..d0b7006
--- /dev/null
+++ b/mesecons/mesecons_receiver/textures/receiver_bottom_on.png
Binary files differ
diff --git a/mesecons/mesecons_receiver/textures/receiver_fb_off.png b/mesecons/mesecons_receiver/textures/receiver_fb_off.png
new file mode 100644
index 0000000..aed3008
--- /dev/null
+++ b/mesecons/mesecons_receiver/textures/receiver_fb_off.png
Binary files differ
diff --git a/mesecons/mesecons_receiver/textures/receiver_fb_on.png b/mesecons/mesecons_receiver/textures/receiver_fb_on.png
new file mode 100644
index 0000000..0916736
--- /dev/null
+++ b/mesecons/mesecons_receiver/textures/receiver_fb_on.png
Binary files differ
diff --git a/mesecons/mesecons_receiver/textures/receiver_lr_off.png b/mesecons/mesecons_receiver/textures/receiver_lr_off.png
new file mode 100644
index 0000000..1fb2b3a
--- /dev/null
+++ b/mesecons/mesecons_receiver/textures/receiver_lr_off.png
Binary files differ
diff --git a/mesecons/mesecons_receiver/textures/receiver_lr_on.png b/mesecons/mesecons_receiver/textures/receiver_lr_on.png
new file mode 100644
index 0000000..087c0b4
--- /dev/null
+++ b/mesecons/mesecons_receiver/textures/receiver_lr_on.png
Binary files differ
diff --git a/mesecons/mesecons_receiver/textures/receiver_top_off.png b/mesecons/mesecons_receiver/textures/receiver_top_off.png
new file mode 100644
index 0000000..ae50106
--- /dev/null
+++ b/mesecons/mesecons_receiver/textures/receiver_top_off.png
Binary files differ
diff --git a/mesecons/mesecons_receiver/textures/receiver_top_on.png b/mesecons/mesecons_receiver/textures/receiver_top_on.png
new file mode 100644
index 0000000..5b48cac
--- /dev/null
+++ b/mesecons/mesecons_receiver/textures/receiver_top_on.png
Binary files differ