forked from your-land-mirror/yl_speak_up
#5295 allow to write internal notes
This commit is contained in:
parent
a735a9a86f
commit
a33b52f0d8
58
fs_notes.lua
Normal file
58
fs_notes.lua
Normal file
@ -0,0 +1,58 @@
|
||||
|
||||
|
||||
yl_speak_up.input_fs_notes = function(player, formname, fields)
|
||||
if(fields and fields.back) then
|
||||
return yl_speak_up.show_fs(player, "talk")
|
||||
elseif(fields and fields.store_notes and fields.notes_text) then
|
||||
local pname = player:get_player_name()
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
local n_id = yl_speak_up.speak_to[pname].n_id
|
||||
-- update the dialog data the player sees
|
||||
dialog.d_notes = fields.notes_text
|
||||
-- actually store/update it on disc as well
|
||||
local stored_dialog = yl_speak_up.load_dialog(n_id, false)
|
||||
stored_dialog.d_notes = dialog.d_notes
|
||||
yl_speak_up.save_dialog(n_id, stored_dialog)
|
||||
-- log the change
|
||||
yl_speak_up.log_change(pname, n_id, "Updated notes to: ", tostring(dialog.d_notes))
|
||||
return yl_speak_up.show_fs(player, "msg", {
|
||||
input_to = "yl_speak_up:notes",
|
||||
formspec = "size[10,3]"..
|
||||
"label[0.5,1.0;Notes successfully updated.]"..
|
||||
"button[3.5,2.0;2,0.9;back_from_error_msg;Back]"
|
||||
})
|
||||
else
|
||||
return yl_speak_up.show_fs(player, "notes")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
yl_speak_up.get_fs_notes = function(player, param)
|
||||
local pname = player:get_player_name()
|
||||
local n_id = yl_speak_up.speak_to[pname].n_id
|
||||
-- generic dialogs are not part of the NPC
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
return table.concat({"size[20,20]",
|
||||
"label[2,0.5;Internal notes on NPC ",
|
||||
minetest.formspec_escape(n_id or "- ? -"),
|
||||
", named ",
|
||||
minetest.formspec_escape(dialog.n_npc) or "- ? -",
|
||||
"]",
|
||||
"button[17.8,0.2;2.0,0.9;back;Back]",
|
||||
"button[15.0,0.2;2.0,0.9;store_notes;Save]",
|
||||
"textarea[0.2,2;19.6,13;notes_text;Notes (shown only to those who can edit this NPC):;",
|
||||
minetest.formspec_escape(dialog.d_notes or "Enter text here."),
|
||||
"]",
|
||||
"textarea[0.2,15.2;19.6,4.8;;;",
|
||||
"This can be used to make your NPC more intresting by storing information about..\n"..
|
||||
"* its character\n"..
|
||||
"* special characteristics of the NPC\n"..
|
||||
"* linguistic peculiarities and habits\n"..
|
||||
"* origin, relationships, lots of lore\n"..
|
||||
"* friendships / enmities\n"..
|
||||
"* personal goals / motivations / background\n"..
|
||||
"* planned quests\n"..
|
||||
"* trades\n"..
|
||||
"and whatever else you want to keep notes on for this NPC.]"
|
||||
})
|
||||
end
|
@ -125,6 +125,11 @@ yl_speak_up.input_talk = function(player, formname, fields)
|
||||
return
|
||||
end
|
||||
|
||||
if(edit_mode and fields.button_edit_notes) then
|
||||
yl_speak_up.show_fs(player, "notes")
|
||||
return
|
||||
end
|
||||
|
||||
-- start edit mode (requires npc_talk_owner)
|
||||
if fields.button_start_edit_mode then
|
||||
-- check if this particular NPC is really owned by this player or if the player has global privs
|
||||
@ -402,17 +407,22 @@ yl_speak_up.get_fs_talkdialog_main_text_in_edit_mode = function(
|
||||
"Create a new dialog.",
|
||||
true)
|
||||
yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
|
||||
"button", "13.4,0.3;2,0.9", "button_edit_name_and_description",
|
||||
"button", "11.0,0.3;2,1.0", "button_edit_notes",
|
||||
"Notes",
|
||||
"Keep notes of what this NPC is for, how his character is etc.",
|
||||
true)
|
||||
yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
|
||||
"button", "13.2,0.3;2,0.9", "button_edit_name_and_description",
|
||||
"Edit",
|
||||
"Edit name and description of your NPC.",
|
||||
true)
|
||||
yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
|
||||
"button", "15.7,0.3;2,0.9", "button_save_dialog",
|
||||
"button", "15.4,0.3;2,0.9", "button_save_dialog",
|
||||
"Save",
|
||||
"Save this dialog.",
|
||||
true)
|
||||
yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
|
||||
"button", "17.9,0.3;2,0.9", "button_export_dialog",
|
||||
"button", "17.5,0.3;2.4,0.9", "button_export_dialog",
|
||||
"Export",
|
||||
"Export: Show the dialog in .json format which you can copy and store on your computer.",
|
||||
true)
|
||||
|
2
init.lua
2
init.lua
@ -235,6 +235,8 @@ yl_speak_up.reload = function(modpath, log_entry)
|
||||
dofile(modpath .. "fs_quest_gui.lua")
|
||||
-- export dialog for cut&paste in .json format
|
||||
dofile(modpath .. "fs_export.lua")
|
||||
-- take notes regarding what the NPC is for
|
||||
dofile(modpath .. "fs_notes.lua")
|
||||
|
||||
-- show a list of all NPC the player can edit
|
||||
dofile(modpath .. "fs_npc_list.lua")
|
||||
|
@ -127,6 +127,10 @@ yl_speak_up.input_handler = function(player, formname, fields)
|
||||
elseif formname == "yl_speak_up:export" then
|
||||
yl_speak_up.input_fs_export(player, formname, fields)
|
||||
return true
|
||||
-- take notes on what the NPC is for
|
||||
elseif formname == "yl_speak_up:notes" then
|
||||
yl_speak_up.input_fs_notes(player, formname, fields)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
@ -442,6 +446,10 @@ yl_speak_up.show_fs = function(player, fs_name, param)
|
||||
yl_speak_up.show_fs_ver(pname, "yl_speak_up:export",
|
||||
yl_speak_up.get_fs_export(player, param))
|
||||
|
||||
elseif(fs_name == "notes") then
|
||||
yl_speak_up.show_fs_ver(pname, "yl_speak_up:notes",
|
||||
yl_speak_up.get_fs_notes(player, param))
|
||||
|
||||
-- fallback in case of wrong call
|
||||
else
|
||||
minetest.chat_send_player(pname, "Error: Trying to show wrong "..
|
||||
|
Loading…
Reference in New Issue
Block a user