diff options
author | MT-Modder <thomas.waits148@gmail.com> | 2015-02-02 19:20:44 -0500 |
---|---|---|
committer | MT-Modder <thomas.waits148@gmail.com> | 2015-02-02 19:20:44 -0500 |
commit | 94604e890c08d54e69abd5507f5b92bc1bb9d31f (patch) | |
tree | 16ecd377bb3a382d8a910a58739a7eb602b4766a | |
parent | ac0e062281e452713154b22821843012202402e6 (diff) | |
download | mesecons-94604e890c08d54e69abd5507f5b92bc1bb9d31f.tar mesecons-94604e890c08d54e69abd5507f5b92bc1bb9d31f.tar.gz mesecons-94604e890c08d54e69abd5507f5b92bc1bb9d31f.tar.bz2 mesecons-94604e890c08d54e69abd5507f5b92bc1bb9d31f.tar.xz mesecons-94604e890c08d54e69abd5507f5b92bc1bb9d31f.zip |
Add trapdoor to mesecons_doors
-rw-r--r-- | mesecons_doors/init.lua | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/mesecons_doors/init.lua b/mesecons_doors/init.lua index 80548f2..a1f172c 100644 --- a/mesecons_doors/init.lua +++ b/mesecons_doors/init.lua @@ -6,9 +6,9 @@ local function on_rightclick(pos, dir, check_name, replace, replace_dir, params) end local p2 = minetest.get_node(pos).param2 p2 = params[p2 + 1] - + minetest.swap_node(pos, {name = replace_dir, param2 = p2}) - + pos.y = pos.y - dir minetest.swap_node(pos, {name = replace, param2 = p2}) @@ -49,3 +49,41 @@ meseconify_door("doors:door_wood") meseconify_door("doors:door_steel") meseconify_door("doors:door_glass") meseconify_door("doors:door_obsidian_glass") + +-- Trapdoor +local function punch(pos) + local meta = minetest.get_meta(pos) + local state = meta:get_int("state") + local me = minetest.get_node(pos) + local tmp_node + local tmp_node2 + if state == 1 then + state = 0 + minetest.sound_play("doors_door_close", {pos = pos, gain = 0.3, max_hear_distance = 10}) + tmp_node = {name="doors:trapdoor", param1=me.param1, param2=me.param2} + else + state = 1 + minetest.sound_play("doors_door_open", {pos = pos, gain = 0.3, max_hear_distance = 10}) + tmp_node = {name="doors:trapdoor_open", param1=me.param1, param2=me.param2} + end + minetest.set_node(pos, tmp_node) + meta:set_int("state", state) +end + +minetest.override_item("doors:trapdoor", { + mesecons = {effector = { + action_on = function(pos) + punch(pos) + end, + rules = mesecon.rules.pplate + }}, +}) + +minetest.override_item("doors:trapdoor_open", { + mesecons = {effector = { + action_off = function(pos) + punch(pos) + end, + rules = mesecon.rules.pplate + }}, +}) |