forked from Sokomine/yl_speak_up
completed turning dialog into alternate text
This commit is contained in:
parent
784ac2af71
commit
6fe510026d
@ -469,6 +469,7 @@ yl_speak_up.input_fs_show_what_points_to_this_dialog = function(player, formname
|
||||
return
|
||||
end
|
||||
-- fields.turn_dialog_into_alternate_text is set
|
||||
local n_id = yl_speak_up.speak_to[pname].n_id
|
||||
local this_dialog = yl_speak_up.speak_to[pname].d_id
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
if(not(dialog)
|
||||
@ -524,7 +525,7 @@ yl_speak_up.input_fs_show_what_points_to_this_dialog = function(player, formname
|
||||
end
|
||||
end
|
||||
|
||||
local error_msg = "This should work."
|
||||
local error_msg = ""
|
||||
if(count_options > 0) then
|
||||
error_msg = "This dialog still has dialog options.\nConversion not possible."
|
||||
elseif(#found < 1) then
|
||||
@ -544,18 +545,44 @@ yl_speak_up.input_fs_show_what_points_to_this_dialog = function(player, formname
|
||||
-- all fine so far; this is the text we want to set as alternate text
|
||||
local d_text = dialog.n_dialogs[ this_dialog ].d_text
|
||||
local f = found[1]
|
||||
--[[ TODO: implement properly
|
||||
-- TODO: there may already be alternate texts stored there, which may or may not reference d_text
|
||||
-- normal switching to the next dialog
|
||||
if( f.element.r_id and f.element.r_type == "dialog") then
|
||||
dialog.n_dialogs[ f.d_id ].d_options[ f.o_id ].o_results[ f.id ].alternate_text = d_text
|
||||
-- the previous effect failed
|
||||
elseif(f.element.r_id and f.element.r_type == "on_failure") then
|
||||
dialog.n_dialogs[ f.d_id ].d_options[ f.o_id ].o_results[ f.id ].alternate_text = d_text
|
||||
-- an action failed
|
||||
elseif(f.element.a_id) then
|
||||
dialog.n_dialogs[ f.d_id ].d_options[ f.o_id ].actions[ f.id ].alternate_text = d_text
|
||||
-- are we dealing with a result/effect or an action?
|
||||
t = "o_results"
|
||||
if(f.element.a_id) then
|
||||
t = "actions"
|
||||
end
|
||||
-- there may already be an alternate text stored there
|
||||
local alternate_text = dialog.n_dialogs[ f.d_id ].d_options[ f.o_id ][ t ][ f.id ].alternate_text
|
||||
if(not(alternate_text)) then
|
||||
-- no old text found
|
||||
alternate_text = d_text
|
||||
else
|
||||
-- the old text may reference this d_text
|
||||
alternate_text = string.gsub(alternate_text, "%$TEXT%$", d_text)
|
||||
end
|
||||
-- log the change
|
||||
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||
"Dialog "..tostring(this_dialog)..": Deleted this dialog and turned it into an "..
|
||||
"alternate text for dialog \""..tostring(f.d_id).."\" option \""..tostring(f.o_id)..
|
||||
"\" element \""..tostring(f.id).."\".")
|
||||
|
||||
-- actually set the new alternate_text
|
||||
dialog.n_dialogs[ f.d_id ].d_options[ f.o_id ][ t ][ f.id ].alternate_text = alternate_text
|
||||
-- delete this dialog
|
||||
dialog.n_dialogs[ this_dialog ] = nil
|
||||
-- we need to show a new/diffrent dialog to the player now - because the old one was deleted
|
||||
yl_speak_up.speak_to[pname].d_id = f.d_id
|
||||
yl_speak_up.speak_to[pname].o_id = f.o_id
|
||||
if(t == "o_results") then
|
||||
-- we can't really know where this ought to point to - the old dialog is gone, so
|
||||
-- let's point to the current dialog to avoid errors
|
||||
dialog.n_dialogs[ f.d_id ].d_options[ f.o_id ][ t ][ f.id ].r_value = f.d_id
|
||||
-- dialog - normal switching to the next dialog or on_failure - the previous effect failed:
|
||||
yl_speak_up.show_fs(player, "edit_effects", f.id)
|
||||
else
|
||||
-- the player may have to change this manually; we really can't know what would fit
|
||||
-- (but the old dialog is gone)
|
||||
dialog.n_dialogs[ f.d_id ].d_options[ f.o_id ][ t ][ f.id ].a_on_failure = f.d_id
|
||||
-- an action failed:
|
||||
yl_speak_up.show_fs(player, "edit_actions", f.id)
|
||||
end
|
||||
-- TODO: where shall these dialogs point to?
|
||||
--]]
|
||||
end
|
||||
|
||||
@ -654,7 +654,7 @@ yl_speak_up.save_element_p_or_a_or_e = function(
|
||||
yl_speak_up.speak_to[pname][ id_prefix.."id" ] = nil
|
||||
yl_speak_up.speak_to[pname][ tmp_data_cache ] = nil
|
||||
-- record this as a change, but do not save do disk yet
|
||||
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||
"Dialog "..tostring(d_id)..": "..element_desc.." "..tostring(x_id)..
|
||||
" added/changed for option "..tostring(o_id)..".")
|
||||
if(show_save_msg) then
|
||||
|
||||
Loading…
Reference in New Issue
Block a user