summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorh-v-smacker <hans-von-smacker+github@gmail.com>2018-05-13 07:59:31 +0300
committerh-v-smacker <hans-von-smacker+github@gmail.com>2018-05-13 07:59:31 +0300
commit8f342ec824b1db32cb884c6304d14352ca22e2cb (patch)
tree9e779fd92db3988998639d89cda52d59d93db040
parentb0484272fe934aff2141f3c46b9f22a73336ae64 (diff)
locked switch
-rw-r--r--extranodes/depends.txt1
-rw-r--r--extranodes/extramesecons.lua57
-rw-r--r--extranodes/init.lua1
-rw-r--r--extranodes/textures/mesecons_switch_locked_frame.pngbin0 -> 178 bytes
4 files changed, 59 insertions, 0 deletions
diff --git a/extranodes/depends.txt b/extranodes/depends.txt
index 2ded643..fa27879 100644
--- a/extranodes/depends.txt
+++ b/extranodes/depends.txt
@@ -1,6 +1,7 @@
default
technic?
pipeworks?
+mesecons?
technic_worldgen
concrete
unifieddyes?
diff --git a/extranodes/extramesecons.lua b/extranodes/extramesecons.lua
new file mode 100644
index 0000000..1dd712d
--- /dev/null
+++ b/extranodes/extramesecons.lua
@@ -0,0 +1,57 @@
+local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
+
+if minetest.get_modpath("mesecons") then
+
+ mesecon.register_node("extranodes:mesecon_switch_protected", {
+ paramtype2="facedir",
+ description="Switch (protected)",
+ is_ground_content = false,
+ sounds = default.node_sound_stone_defaults(),
+ after_place_node = function(pos, placer, itemstack, pointed_thing)
+ local meta = minetest:get_meta(pos)
+ meta:set_string("owner", placer:get_player_name() or "")
+ end,
+ on_rightclick = function (pos, node, player)
+ local meta = minetest:get_meta(pos)
+ local owner = meta:get_string("owner")
+ local pname = player:get_player_name();
+ if owner ~= pname then
+ minetest.chat_send_player(pname, "This switch can only be used by " .. owner)
+ return
+ end
+ if(mesecon.flipstate(pos, node) == "on") then
+ mesecon.receptor_on(pos)
+ else
+ mesecon.receptor_off(pos)
+ end
+ minetest.sound_play("mesecons_switch", {pos=pos})
+ end
+ },{
+ groups = {dig_immediate=2},
+ tiles = { "mesecons_switch_side.png", "mesecons_switch_side.png",
+ "mesecons_switch_side.png^default_key.png", "mesecons_switch_side.png^default_key.png",
+ "mesecons_switch_side.png", "mesecons_switch_off.png^mesecons_switch_locked_frame.png"},
+ mesecons = {receptor = { state = mesecon.state.off }}
+ },{
+ groups = {dig_immediate=2, not_in_creative_inventory=1},
+ tiles = { "mesecons_switch_side.png", "mesecons_switch_side.png",
+ "mesecons_switch_side.png^default_key.png", "mesecons_switch_side.png^default_key.png",
+ "mesecons_switch_side.png", "mesecons_switch_on.png^mesecons_switch_locked_frame.png"},
+ mesecons = {receptor = { state = mesecon.state.on }}
+ })
+
+ minetest.register_craft({
+ output = "extranodes:mesecon_switch_protected_off 2",
+ recipe = {
+ {"default:steel_ingot", "default:cobble", "default:steel_ingot"},
+ {"group:mesecon_conductor_craftable","default:skeleton_key", "group:mesecon_conductor_craftable"},
+ }
+ })
+
+ minetest.register_craft({
+ output = "extranodes:mesecon_switch_protected_off",
+ type = "shapeless",
+ recipe = {"default:skeleton_key", "mesecons_switch:mesecon_switch_off"}
+ })
+
+end \ No newline at end of file
diff --git a/extranodes/init.lua b/extranodes/init.lua
index 118dc0a..69cb820 100644
--- a/extranodes/init.lua
+++ b/extranodes/init.lua
@@ -8,6 +8,7 @@ local path = string.gsub(technic.modpath, "technic/technic", "technic/extranodes
dofile(path.."/aspirin.lua")
dofile(path.."/trampoline.lua")
dofile(path.."/extratubes.lua")
+dofile(path.."/extramesecons.lua")
dofile(path.."/lox.lua")
if minetest.get_modpath("bakedclay") then
diff --git a/extranodes/textures/mesecons_switch_locked_frame.png b/extranodes/textures/mesecons_switch_locked_frame.png
new file mode 100644
index 0000000..239f97e
--- /dev/null
+++ b/extranodes/textures/mesecons_switch_locked_frame.png
Binary files differ