forked from Sokomine/yl_speak_up
used helper variable n_id as abbreviation; reformatted code for changelog entries
This commit is contained in:
parent
0d7ae95ab6
commit
a0c3a4c890
@ -1987,12 +1987,13 @@ end
|
|||||||
-- pname player name
|
-- pname player name
|
||||||
-- fields the fields returned from the formspec
|
-- fields the fields returned from the formspec
|
||||||
yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
||||||
|
local n_id = yl_speak_up.edit_mode[pname]
|
||||||
local d_id = yl_speak_up.speak_to[pname].d_id
|
local d_id = yl_speak_up.speak_to[pname].d_id
|
||||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||||
|
|
||||||
-- this way we can store the actual changes and present them to the player for saving
|
-- this way we can store the actual changes and present them to the player for saving
|
||||||
if(not(yl_speak_up.npc_was_changed[ yl_speak_up.edit_mode[pname]])) then
|
if(not(yl_speak_up.npc_was_changed[ n_id ])) then
|
||||||
yl_speak_up.npc_was_changed[ yl_speak_up.edit_mode[pname]] = {}
|
yl_speak_up.npc_was_changed[ n_id ] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -2004,8 +2005,10 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
|||||||
-- detect changes to d_text: text of the dialog (what the npc is saying)
|
-- detect changes to d_text: text of the dialog (what the npc is saying)
|
||||||
if(fields.d_text and dialog.n_dialogs[ d_id ].d_text ~= fields.d_text) then
|
if(fields.d_text and dialog.n_dialogs[ d_id ].d_text ~= fields.d_text) then
|
||||||
-- store that there have been changes to this npc
|
-- store that there have been changes to this npc
|
||||||
table.insert(yl_speak_up.npc_was_changed[ yl_speak_up.edit_mode[pname] ],
|
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||||
"Dialog "..d_id..": d_text (what the NPC says) was changed from \""..tostring( dialog.n_dialogs[ d_id ].d_text).."\" to \""..tostring(fields.d_text).."\".")
|
"Dialog "..d_id..": d_text (what the NPC says) was changed from \""..
|
||||||
|
tostring( dialog.n_dialogs[ d_id ].d_text)..
|
||||||
|
"\" to \""..tostring(fields.d_text).."\".")
|
||||||
-- actually change the text - but do not save to disk yet
|
-- actually change the text - but do not save to disk yet
|
||||||
dialog.n_dialogs[ d_id ].d_text = fields.d_text
|
dialog.n_dialogs[ d_id ].d_text = fields.d_text
|
||||||
-- TODO: option to delete dialogs (when text empty and no options present?)
|
-- TODO: option to delete dialogs (when text empty and no options present?)
|
||||||
@ -2020,8 +2023,8 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
|||||||
end
|
end
|
||||||
dialog.n_dialogs[d_id].d_options[future_o_id] = {
|
dialog.n_dialogs[d_id].d_options[future_o_id] = {
|
||||||
o_id = future_o_id,
|
o_id = future_o_id,
|
||||||
o_hide_when_prerequisites_not_met = false,
|
o_hide_when_prerequisites_not_met = "false",
|
||||||
o_grey_when_prerequisites_not_met = false,
|
o_grey_when_prerequisites_not_met = "false",
|
||||||
o_sort = -1,
|
o_sort = -1,
|
||||||
o_text_when_prerequisites_not_met = "",
|
o_text_when_prerequisites_not_met = "",
|
||||||
o_text_when_prerequisites_met = "",
|
o_text_when_prerequisites_met = "",
|
||||||
@ -2029,7 +2032,7 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
|||||||
-- necessary in order for it to work
|
-- necessary in order for it to work
|
||||||
local s = sanitize_sort(dialog.n_dialogs[d_id].d_options, yl_speak_up.speak_to[pname].o_sort)
|
local s = sanitize_sort(dialog.n_dialogs[d_id].d_options, yl_speak_up.speak_to[pname].o_sort)
|
||||||
dialog.n_dialogs[d_id].d_options[future_o_id].o_sort = s
|
dialog.n_dialogs[d_id].d_options[future_o_id].o_sort = s
|
||||||
table.insert(yl_speak_up.npc_was_changed[ yl_speak_up.edit_mode[pname] ],
|
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||||
"Dialog "..d_id..": Added new option/answer "..future_o_id..".")
|
"Dialog "..d_id..": Added new option/answer "..future_o_id..".")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2042,8 +2045,10 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
|||||||
and fields[ "text_option_"..k ] ~= v.o_text_when_prerequisites_met ) then
|
and fields[ "text_option_"..k ] ~= v.o_text_when_prerequisites_met ) then
|
||||||
-- TODO: delete option if text is empty
|
-- TODO: delete option if text is empty
|
||||||
-- store that there have been changes to this npc
|
-- store that there have been changes to this npc
|
||||||
table.insert(yl_speak_up.npc_was_changed[ yl_speak_up.edit_mode[pname] ],
|
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||||
"Dialog "..d_id..": The text for option "..tostring(k).." was changed from \""..tostring(v.o_text_when_prerequisites_met).."\" to \""..tostring(fields[ "text_option_"..k]).."\".")
|
"Dialog "..d_id..": The text for option "..tostring(k)..
|
||||||
|
" was changed from \""..tostring(v.o_text_when_prerequisites_met)..
|
||||||
|
"\" to \""..tostring(fields[ "text_option_"..k]).."\".")
|
||||||
-- actually change the text of the option
|
-- actually change the text of the option
|
||||||
dialog.n_dialogs[ d_id ].d_options[ k ].o_text_when_prerequisites_met = fields[ "text_option_"..k ]
|
dialog.n_dialogs[ d_id ].d_options[ k ].o_text_when_prerequisites_met = fields[ "text_option_"..k ]
|
||||||
end
|
end
|
||||||
@ -2060,8 +2065,11 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
|||||||
fields[ "d_id_"..k ] = yl_speak_up.add_new_dialog(dialog, pname)
|
fields[ "d_id_"..k ] = yl_speak_up.add_new_dialog(dialog, pname)
|
||||||
end
|
end
|
||||||
-- store that there have been changes to this npc
|
-- store that there have been changes to this npc
|
||||||
table.insert(yl_speak_up.npc_was_changed[ yl_speak_up.edit_mode[pname] ],
|
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||||
"Dialog "..d_id..": The target dialog for option "..tostring(k).." was changed from "..tostring(vr.r_value).." to "..tostring(fields[ "d_id_"..k])..".")
|
"Dialog "..d_id..": The target dialog for option "..
|
||||||
|
tostring(k).." was changed from "..
|
||||||
|
tostring(vr.r_value)..
|
||||||
|
" to "..tostring(fields[ "d_id_"..k])..".")
|
||||||
-- actually change the target dialog
|
-- actually change the target dialog
|
||||||
vr.r_value = fields[ "d_id_"..k ]
|
vr.r_value = fields[ "d_id_"..k ]
|
||||||
end
|
end
|
||||||
@ -2074,7 +2082,7 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
|||||||
fields[ "d_id_"..k ] = yl_speak_up.add_new_dialog(dialog, pname)
|
fields[ "d_id_"..k ] = yl_speak_up.add_new_dialog(dialog, pname)
|
||||||
end
|
end
|
||||||
-- store that a new option has been added to this dialog
|
-- store that a new option has been added to this dialog
|
||||||
table.insert(yl_speak_up.npc_was_changed[ yl_speak_up.edit_mode[pname] ],
|
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||||
"Dialog "..d_id..": The target dialog for option "..tostring(k).." was changed from -default- to "..tostring(fields[ "d_id_"..k])..".")
|
"Dialog "..d_id..": The target dialog for option "..tostring(k).." was changed from -default- to "..tostring(fields[ "d_id_"..k])..".")
|
||||||
|
|
||||||
-- create a new result (first the id, then the actual result)
|
-- create a new result (first the id, then the actual result)
|
||||||
@ -2201,6 +2209,7 @@ minetest.register_on_player_receive_fields(
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: change of o_sort, change of target_dialog, button delete, buton add, (button save?)
|
-- TODO: change of o_sort, change of target_dialog, button delete, buton add, (button save?)
|
||||||
|
--yl_speak_up.edit_mode_apply_changes(pname, fields)
|
||||||
|
|
||||||
-- back to the main dialog window?
|
-- back to the main dialog window?
|
||||||
if(fields.show_current_dialog or fields.quit or fields.button_exit or not(d_option)) then
|
if(fields.show_current_dialog or fields.quit or fields.button_exit or not(d_option)) then
|
||||||
|
Loading…
Reference in New Issue
Block a user