Add exit dialog when using door
This commit is contained in:
parent
8bc6f4dbb6
commit
234788ebde
@ -1,4 +1,6 @@
|
||||
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!
|
||||
|
||||
@ -15,6 +17,39 @@ local S = minetest.get_translator("lzr_doors")
|
||||
-- of the map author to construct correct doors.
|
||||
|
||||
|
||||
|
||||
local on_rightclick_or_punch = function(pos, node, clicker)
|
||||
local state = lzr_gamestate.get_state()
|
||||
if state ~= lzr_gamestate.LEVEL then
|
||||
return
|
||||
end
|
||||
if not clicker and not clicker:is_player() then
|
||||
return
|
||||
end
|
||||
|
||||
local message = S("Do you want to return to your ship?")
|
||||
|
||||
local form = "formspec_version[7]size[8,2.5]"..
|
||||
"textarea[0.5,0.5;7,1.8;;;"..F(message).."]"..
|
||||
"button_exit[1.25,1.5;2,0.6;return_to_ship;"..FS("Yes").."]"..
|
||||
"set_focus[cancel]"..
|
||||
"button_exit[4.75,1.5;2,0.6;cancel;"..FS("No").."]"
|
||||
|
||||
minetest.show_formspec(clicker:get_player_name(), "lzr_doors:leave_level", form)
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
local state = lzr_gamestate.get_state()
|
||||
if state ~= lzr_gamestate.LEVEL then
|
||||
return
|
||||
end
|
||||
if formname == "lzr_doors:leave_level" then
|
||||
if fields.return_to_ship then
|
||||
lzr_levels.leave_level()
|
||||
end
|
||||
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"},
|
||||
@ -22,6 +57,7 @@ lzr_panes.register_pane("lzr_doors:door_wood_frame_frame_top", {
|
||||
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"),
|
||||
@ -30,5 +66,6 @@ lzr_panes.register_pane("lzr_doors:door_wood_frame_frame_bottom", {
|
||||
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,
|
||||
})
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
name = lzr_doors
|
||||
description = Very basic doors
|
||||
depends = lzr_panes
|
||||
depends = lzr_panes, lzr_gamestate, lzr_levels
|
||||
|
@ -27,6 +27,9 @@ function lzr_panes.register_pane(basename, def)
|
||||
wield_image = def.wield_image,
|
||||
paramtype2 = "facedir",
|
||||
|
||||
on_rightclick = def.on_rightclick,
|
||||
on_punch = def.on_punch,
|
||||
|
||||
__mesh_off = "lzr_panes_pane_on.obj",
|
||||
__mesh_on = "lzr_panes_pane_on.obj",
|
||||
__tiles_off = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user