add personal_log integration in default discovery popup
This commit is contained in:
parent
579a9bf221
commit
528735b4b2
43
init.lua
43
init.lua
@ -395,13 +395,54 @@ named_waypoints.default_discovery_popup = function(player, pos, data, waypoint_d
|
||||
local formspec = "formspec_version[2]" ..
|
||||
"size[10,2]" ..
|
||||
"label[1.25,0.75;" .. minetest.formspec_escape(discovery_note) ..
|
||||
"]button_exit[1.0,1.25;3,0.5;btn_ok;".. S("OK") .."]"
|
||||
"]button_exit[3.5,1.25;3,0.5;btn_ok;".. S("OK") .."]"
|
||||
minetest.show_formspec(player_name, "named_waypoints:discovery_popup", formspec)
|
||||
minetest.chat_send_player(player_name, discovery_note)
|
||||
minetest.log("action", "[named_waypoints] " .. player_name .. " discovered " .. discovery_name)
|
||||
minetest.sound_play({name = "named_waypoints_chime01", gain = 0.25}, {to_player=player_name})
|
||||
end
|
||||
|
||||
local player_log_formspec_open
|
||||
|
||||
if minetest.get_modpath("personal_log") and personal_log ~= nil then
|
||||
player_log_formspec_open = {}
|
||||
|
||||
named_waypoints.default_discovery_popup = function(player, pos, data, waypoint_def)
|
||||
local player_name = player:get_player_name()
|
||||
local discovery_name = data.name or waypoint_def.default_name
|
||||
local discovery_note = S("You've discovered @1", discovery_name)
|
||||
local formspec = "formspec_version[2]" ..
|
||||
"size[10,2]" ..
|
||||
"label[1.25,0.75;" .. minetest.formspec_escape(discovery_note) ..
|
||||
"]button_exit[2.0,1.25;3,0.5;btn_ok;".. S("OK") .."]" ..
|
||||
"button_exit[5.0,1.25;3,0.5;btn_log;"..S("Log location").."]"
|
||||
|
||||
minetest.show_formspec(player_name, "named_waypoints:discovery_popup_log", formspec)
|
||||
minetest.chat_send_player(player_name, discovery_note)
|
||||
minetest.log("action", "[named_waypoints] " .. player_name .. " discovered " .. discovery_name)
|
||||
minetest.sound_play({name = "named_waypoints_chime01", gain = 0.25}, {to_player=player_name})
|
||||
player_log_formspec_open[player_name] = {data=data, waypoint_def=waypoint_def, pos=pos}
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "named_waypoints:discovery_popup_log" then
|
||||
return
|
||||
end
|
||||
local player_name = player:get_player_name()
|
||||
local waypoint_data = player_log_formspec_open[player_name]
|
||||
if not waypoint_data then
|
||||
return
|
||||
end
|
||||
|
||||
if fields.btn_log then
|
||||
local discovery_name = waypoint_data.data.name or waypoint_data.waypoint_def.default_name
|
||||
personal_log.add_location_entry(player_name, discovery_name, waypoint_data.pos)
|
||||
minetest.chat_send_player(player_name, S("Location of @1 added to your personal log", discovery_name))
|
||||
end
|
||||
|
||||
player_log_formspec_open[player_name] = nil
|
||||
end)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
--- Admin commands
|
||||
|
@ -7,6 +7,10 @@
|
||||
Delete=Supprimer
|
||||
#warning that incorrect data was entered for a waypoint in the UI
|
||||
Invalid syntax.=Syntaxe incorrecte.
|
||||
#WARNING: AUTOTRANSLATED BY GOOGLE TRANSLATE
|
||||
Location of @1 added to your personal log=Emplacement de @ 1 ajouté à votre journal personnel
|
||||
#WARNING: AUTOTRANSLATED BY GOOGLE TRANSLATE
|
||||
Log location=Emplacement du journal
|
||||
#button label
|
||||
New=Nouveau
|
||||
#button label
|
||||
|
@ -7,6 +7,8 @@
|
||||
Delete=
|
||||
#warning that incorrect data was entered for a waypoint in the UI
|
||||
Invalid syntax.=
|
||||
Location of @1 added to your personal log=
|
||||
Log location=
|
||||
#button label
|
||||
New=
|
||||
#button label
|
||||
|
3
mod.conf
3
mod.conf
@ -1,2 +1,3 @@
|
||||
name = named_waypoints
|
||||
description = A library mod for managing waypoints shown in player HUDs that can be discovered by exploration.
|
||||
description = A library mod for managing waypoints shown in player HUDs that can be discovered by exploration.
|
||||
optional_depends = personal_log
|
@ -85,6 +85,10 @@ Caution: This interface lets you access the guts of the data stored for each way
|
||||
|
||||
"``/named_waypoints_discover_all <waypoints_type>``" and "``/named_waypoints_undiscover_all <waypoints_type>``" will set all existing waypoints of the provided type to be either discovered or not discovered by you. It can be useful for a server administrator to "know all and see all" as it were. Note that visibility item and range limitations still apply.
|
||||
|
||||
## personal_log integration
|
||||
|
||||
If you have the personal_log mod installed, the default waypoint-discovery notification popup will include an option to log the location of the just-discovered waypoint. It will create a log entry for that player with the waypoint's name as its content.
|
||||
|
||||
## License
|
||||
|
||||
This mod is released under the MIT license.
|
Loading…
x
Reference in New Issue
Block a user