Add locked door

This commit is contained in:
Wuzzy 2024-12-15 13:14:31 +01:00
parent 234788ebde
commit e0fe65765f
5 changed files with 82 additions and 28 deletions

View File

@ -291,6 +291,10 @@ so they work in Luanti.
- By Breviceps - By Breviceps
- License: CC0 - License: CC0
- <https://freesound.org/people/Breviceps/sounds/445119/> - <https://freesound.org/people/Breviceps/sounds/445119/>
- `lzr_doors_door_locked.ogg`
- by saha213131
- License: CC0
- <https://freesound.org/people/saha213131/sounds/730189/>
## Translations ## Translations

View File

@ -2,23 +2,28 @@ local S = minetest.get_translator("lzr_doors")
local F = minetest.formspec_escape local F = minetest.formspec_escape
local FS = function(...) return minetest.formspec_escape(S(...)) end 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 --[[ Basic doors for Lazarr!
-- is neccessary to ensure laser compatibility.
-- 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`), There are two types of doors: Locked doors play a sound when
-- with a top segment and a bottom one. Panes are useful because interacting with them and exit doors that allow the player
-- they are laser-compatible. to exit the level.
-- Door segments are completely standalone, it is the reponsibility A major limitation is that doors cannot be opened or closed.
-- of the map author to construct correct doors.
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() local state = lzr_gamestate.get_state()
if state ~= lzr_gamestate.LEVEL then if state ~= lzr_gamestate.LEVEL then
return 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) minetest.show_formspec(clicker:get_player_name(), "lzr_doors:leave_level", form)
end 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) minetest.register_on_player_receive_fields(function(player, formname, fields)
local state = lzr_gamestate.get_state() local state = lzr_gamestate.get_state()
if state ~= lzr_gamestate.LEVEL then if state ~= lzr_gamestate.LEVEL then
@ -50,22 +64,58 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end end
end) end)
lzr_panes.register_pane("lzr_doors:door_wood_frame_frame_top", { local help_exit = S("Allows to exit the level")
description = S("Top Wood Frame Door Segment"), local help_locked = S("Cannot be opened")
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,
})
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",
})

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B