diff --git a/CREDITS.md b/CREDITS.md index 955a5fe3..01f3ebd0 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -291,6 +291,10 @@ so they work in Luanti. - By Breviceps - License: CC0 - +- `lzr_doors_door_locked.ogg` + - by saha213131 + - License: CC0 + - ## Translations diff --git a/mods/lzr_doors/init.lua b/mods/lzr_doors/init.lua index 5b567c05..e94ce1a1 100644 --- a/mods/lzr_doors/init.lua +++ b/mods/lzr_doors/init.lua @@ -2,23 +2,28 @@ local S = minetest.get_translator("lzr_doors") local F = minetest.formspec_escape local FS = function(...) return minetest.formspec_escape(S(...)) end --- Basic doors for Lazarr! +lzr_doors = {} --- The doors in Lazarr! are much simpler than in other games. This --- is neccessary to ensure laser compatibility. +--[[ Basic doors for Lazarr! --- A major limitation is that doors cannot be opened or closed. +The doors in Lazarr! are much simpler than in other games. This +is neccessary to ensure laser compatibility. --- A door is basically just 2 panes (using `lzr_panes`), --- with a top segment and a bottom one. Panes are useful because --- they are laser-compatible. +There are two types of doors: Locked doors play a sound when +interacting with them and exit doors that allow the player +to exit the level. --- Door segments are completely standalone, it is the reponsibility --- of the map author to construct correct doors. +A major limitation is that doors cannot be opened or closed. +A door is basically just 2 panes (using `lzr_panes`), +with a top segment and a bottom one. Panes are useful because +they are laser-compatible. +Door segments are completely standalone, it is the reponsibility +of the map author to construct correct doors. +]] -local on_rightclick_or_punch = function(pos, node, clicker) +local on_rightclick_exit = function(pos, node, clicker) local state = lzr_gamestate.get_state() if state ~= lzr_gamestate.LEVEL then return @@ -38,6 +43,15 @@ local on_rightclick_or_punch = function(pos, node, clicker) minetest.show_formspec(clicker:get_player_name(), "lzr_doors:leave_level", form) end + +local on_rightclick_locked = function(pos, node, clicker) + local state = lzr_gamestate.get_state() + if state ~= lzr_gamestate.LEVEL and state ~= lzr_gamestate.LEVEL_COMPLETE and state ~= lzr_gamestate.LEVEL_TEST then + return + end + minetest.sound_play({name="lzr_doors_door_locked", gain=0.3}, {pos=pos}, true) +end + minetest.register_on_player_receive_fields(function(player, formname, fields) local state = lzr_gamestate.get_state() if state ~= lzr_gamestate.LEVEL then @@ -50,22 +64,58 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end end) -lzr_panes.register_pane("lzr_doors:door_wood_frame_frame_top", { - description = S("Top Wood Frame Door Segment"), - textures = {"lzr_doors_door_wood_frame_top.png", "lzr_doors_door_wood_frame_sides.png", "lzr_doors_door_wood_frame_sides.png", "lzr_doors_door_wood_frame_top.png^[transformFX"}, - inventory_image = "lzr_doors_door_wood_frame_top.png", - wield_image = "lzr_doors_door_wood_frame_top.png", - sounds = lzr_sounds.node_sound_wood_defaults(), - element_group = "laser_element_door_wood_frame_top", - on_rightclick = on_rightclick_or_punch, -}) -lzr_panes.register_pane("lzr_doors:door_wood_frame_frame_bottom", { - description = S("Bottom Wooden Frame Door Segment"), - textures = {"lzr_doors_door_wood_frame_bottom.png", "lzr_doors_door_wood_frame_sides.png", "lzr_doors_door_wood_frame_sides.png", "lzr_doors_door_wood_frame_bottom.png^[transformFX"}, - inventory_image = "lzr_doors_door_wood_frame_bottom.png", - wield_image = "lzr_doors_door_wood_frame_bottom.png", - sounds = lzr_sounds.node_sound_wood_defaults(), - element_group = "laser_element_door_wood_frame_bottom", - on_rightclick = on_rightclick_or_punch, -}) +local help_exit = S("Allows to exit the level") +local help_locked = S("Cannot be opened") +lzr_doors.register_door = function(basename, modname, def) + lzr_panes.register_pane(modname..":door_"..basename.."_exit_top", { + description = S("@1 (top segment, exit)", def.base_description), + _tt_help = help_exit, + def.textures, + textures = def.textures_top, + inventory_image = "("..def.image_top .. ")^lzr_doors_overlay_exit.png", + wield_image = "("..def.image_top .. ")^lzr_doors_overlay_exit.png", + sounds = def.sounds or lzr_sounds.node_sound_wood_defaults(), + element_group = "laser_element_door_"..basename.."_exit_top", + on_rightclick = on_rightclick_exit, + }) + lzr_panes.register_pane(modname..":door_"..basename.."_exit_bottom", { + description = S("@1 (bottom segment, exit)", def.base_description), + _tt_help = help_exit, + textures = def.textures_bottom, + inventory_image = "("..def.image_bottom.. ")^lzr_doors_overlay_exit.png", + wield_image = "("..def.image_bottom.. ")^lzr_doors_overlay_exit.png", + sounds = lzr_sounds.node_sound_wood_defaults(), + element_group = "laser_element_door_"..basename.."_exit_bottom", + on_rightclick = on_rightclick_exit, + }) + + lzr_panes.register_pane(modname..":door_"..basename.."_locked_top", { + description = S("@1 (top segment, locked)", def.base_description), + _tt_help = help_locked, + textures = def.textures_top, + inventory_image = "("..def.image_top .. ")^lzr_doors_overlay_locked.png", + wield_image = "("..def.image_top .. ")^lzr_doors_overlay_locked.png", + sounds = def.sounds or lzr_sounds.node_sound_wood_defaults(), + element_group = "laser_element_door_"..basename.."_locked_top", + on_rightclick = on_rightclick_locked, + }) + lzr_panes.register_pane(modname..":door_"..basename.."_locked_bottom", { + description = S("@1 (bottom segment, locked)", def.base_description), + _tt_help = help_locked, + textures = def.textures_bottom, + inventory_image = "("..def.image_bottom.. ")^lzr_doors_overlay_locked.png", + wield_image = "("..def.image_bottom.. ")^lzr_doors_overlay_locked.png", + sounds = lzr_sounds.node_sound_wood_defaults(), + element_group = "laser_element_door_"..basename.."_locked_bottom", + on_rightclick = on_rightclick_locked, + }) +end + +lzr_doors.register_door("wood_frame", "lzr_doors", { + base_description = S("Wooden Frame Door"), + textures_top = {"lzr_doors_door_wood_frame_top.png", "lzr_doors_door_wood_frame_sides.png", "lzr_doors_door_wood_frame_sides.png", "lzr_doors_door_wood_frame_top.png^[transformFX"}, + textures_bottom = {"lzr_doors_door_wood_frame_bottom.png", "lzr_doors_door_wood_frame_sides.png", "lzr_doors_door_wood_frame_sides.png", "lzr_doors_door_wood_frame_bottom.png^[transformFX"}, + image_top = "lzr_doors_door_wood_frame_top.png", + image_bottom = "lzr_doors_door_wood_frame_bottom.png", +}) diff --git a/mods/lzr_doors/sounds/lzr_doors_door_locked.ogg b/mods/lzr_doors/sounds/lzr_doors_door_locked.ogg new file mode 100644 index 00000000..3bc5b885 Binary files /dev/null and b/mods/lzr_doors/sounds/lzr_doors_door_locked.ogg differ diff --git a/mods/lzr_doors/textures/lzr_doors_overlay_exit.png b/mods/lzr_doors/textures/lzr_doors_overlay_exit.png new file mode 100644 index 00000000..700ebcb9 Binary files /dev/null and b/mods/lzr_doors/textures/lzr_doors_overlay_exit.png differ diff --git a/mods/lzr_doors/textures/lzr_doors_overlay_locked.png b/mods/lzr_doors/textures/lzr_doors_overlay_locked.png new file mode 100644 index 00000000..946720c4 Binary files /dev/null and b/mods/lzr_doors/textures/lzr_doors_overlay_locked.png differ