Add trapdoor to mesecons_doors

This commit is contained in:
MT-Modder 2015-02-02 19:20:44 -05:00
parent ac0e062281
commit 94604e890c

View File

@ -49,3 +49,41 @@ meseconify_door("doors:door_wood")
meseconify_door("doors:door_steel") meseconify_door("doors:door_steel")
meseconify_door("doors:door_glass") meseconify_door("doors:door_glass")
meseconify_door("doors:door_obsidian_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
}},
})