diff options
-rw-r--r-- | depends.txt | 1 | ||||
-rw-r--r-- | doors.lua | 7 | ||||
-rw-r--r-- | doors_mesecons.lua | 109 | ||||
-rw-r--r-- | init.lua | 21 |
4 files changed, 127 insertions, 11 deletions
diff --git a/depends.txt b/depends.txt index 61602af..d3daf3b 100644 --- a/depends.txt +++ b/depends.txt @@ -7,3 +7,4 @@ moreblocks? glass_stained? pkarcs? vessels? +mesecons? @@ -57,6 +57,7 @@ doors.register("door_iron_bar", { } }) + -- Protected glass doors doors.register("door_glass_protected", { @@ -178,3 +179,9 @@ if minetest.get_modpath("moreblocks") then }) end + +-- Mesecons compatibility + +if minetest.get_modpath("mesecons") then + dofile(minetest_errata.modpath.."/doors_mesecons.lua") +end
\ No newline at end of file diff --git a/doors_mesecons.lua b/doors_mesecons.lua new file mode 100644 index 0000000..e303186 --- /dev/null +++ b/doors_mesecons.lua @@ -0,0 +1,109 @@ +-- Modified, from minetest_game/mods/doors/init.lua +local function on_rightclick(pos, dir, check_name, replace, replace_dir, params) + pos.y = pos.y + dir + if not minetest.get_node(pos).name == check_name then + return + 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}) + + if (minetest.get_meta(pos):get_int("right") ~= 0) == (params[1] ~= 3) then + minetest.sound_play("doors_door_close", {pos = pos, gain = 0.3, max_hear_distance = 10}) + else + minetest.sound_play("doors_door_open", {pos = pos, gain = 0.3, max_hear_distance = 10}) + end +end + +local function meseconify_door(name) + if minetest.registered_items[name .. "_b_1"] then + -- old style double-node doors + local function toggle_state1 (pos, node) + on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0}) + end + + local function toggle_state2 (pos, node) + on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2}) + end + + minetest.override_item(name.."_b_1", { + mesecons = {effector = { + action_on = toggle_state1, + action_off = toggle_state1, + rules = mesecon.rules.pplate + }} + }) + + minetest.override_item(name.."_b_2", { + mesecons = {effector = { + action_on = toggle_state2, + action_off = toggle_state2, + rules = mesecon.rules.pplate + }} + }) + elseif minetest.registered_items[name .. "_a"] then + -- new style mesh node based doors + local override = { + mesecons = {effector = { + action_on = function(pos, node) + local door = doors.get(pos) + if door then + door:open() + end + end, + action_off = function(pos, node) + local door = doors.get(pos) + if door then + door:close() + end + end, + rules = mesecon.rules.pplate + }} + } + minetest.override_item(name .. "_a", override) + minetest.override_item(name .. "_b", override) + end +end + + +meseconify_door("doors:door_wood_solid") +meseconify_door("doors:door_steel_solid") +meseconify_door("doors:door_wood_bar") +meseconify_door("doors:door_iron_bar") +meseconify_door("doors:door_glass_protected") +meseconify_door("doors:door_obsidian_glass_protected") + +if minetest.get_modpath("moreblocks") then + meseconify_door("doors:door_clean_glass") + meseconify_door("doors:door_coal_glass") + meseconify_door("doors:door_iron_glass") + meseconify_door("doors:door_iron_glass_protected") +end + +-- Glass trapdoor + +if doors and doors.get then + local override = { + mesecons = {effector = { + action_on = function(pos, node) + local door = doors.get(pos) + if door then + door:open() + end + end, + action_off = function(pos, node) + local door = doors.get(pos) + if door then + door:close() + end + end, + }}, + } + minetest.override_item("minetest_errata:trapdoor_glass", override) + minetest.override_item("minetest_errata:trapdoor_glass_open", override) + +end @@ -1,22 +1,21 @@ -local modpath = minetest.get_modpath("minetest_errata") - minetest_errata = {} minetest_errata.prefix = "me_" +minetest_errata.modpath = minetest.get_modpath("minetest_errata") -dofile(modpath.."/books.lua") +dofile(minetest_errata.modpath.."/books.lua") -dofile(modpath.."/doors.lua") +dofile(minetest_errata.modpath.."/doors.lua") -dofile(modpath.."/sandstone_cobble.lua") +dofile(minetest_errata.modpath.."/sandstone_cobble.lua") -dofile(modpath.."/flint_block.lua") +dofile(minetest_errata.modpath.."/flint_block.lua") -dofile(modpath.."/missing_groups.lua") +dofile(minetest_errata.modpath.."/missing_groups.lua") -dofile(modpath.."/xpanes.lua") +dofile(minetest_errata.modpath.."/xpanes.lua") -dofile(modpath.."/glass_panes.lua") +dofile(minetest_errata.modpath.."/glass_panes.lua") -dofile(modpath.."/mossy_blocks.lua") +dofile(minetest_errata.modpath.."/mossy_blocks.lua") -dofile(modpath.."/shelves.lua")
\ No newline at end of file +dofile(minetest_errata.modpath.."/shelves.lua")
\ No newline at end of file |