forked from your-land-mirror/yl_speak_up
master #4
@ -338,8 +338,9 @@ end
|
||||
-- here as the other dialog options may not even be definied here yet.
|
||||
-- Note: Preconditions, actions and effects are not handled here (apart from the "dialog"
|
||||
-- effect/result for the redirection to the target dialog)
|
||||
yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_name, option_text, target_dialog,
|
||||
alternate_text, visit_only_once, sort_order)
|
||||
yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_name,
|
||||
option_text, option_text_if_preconditions_false,
|
||||
target_dialog, alternate_text, visit_only_once, sort_order)
|
||||
-- does the dialog we want to add to exist?
|
||||
local d_id = yl_speak_up.d_name_to_d_id(dialog, dialog_name)
|
||||
if(not(d_id)) then
|
||||
@ -382,15 +383,9 @@ yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_nam
|
||||
mode = 2
|
||||
option_name = parts[2]
|
||||
o_id = option_name
|
||||
elseif(o_id and parts[1] == "grey_") then
|
||||
-- this sets o_text_when_prerequisites_not_met
|
||||
mode = 3
|
||||
-- strip the out_ part as well
|
||||
option_name = string.sub(parts[2], 5)
|
||||
o_id = option_name
|
||||
-- in this case we don't want to change the old text - just the greyed out one
|
||||
-- (we keep option_text in case the option needs to be created)
|
||||
text_when_prerequisites_not_met = option_text
|
||||
elseif(o_id and parts[1] ~= "o_") then
|
||||
table.insert(log, log_str.."FAILED to create unknown option \""..tostring(o_id).."\".")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
@ -416,21 +411,44 @@ yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_nam
|
||||
return nil
|
||||
end
|
||||
table.insert(log, log_str.."Successfully created new option \""..tostring(o_id).."\".")
|
||||
|
||||
-- do not change the option_text when we want to change the text of the grey_out_ option text
|
||||
elseif(dialog.n_dialogs[d_id].d_options[o_id].o_text_when_prerequisites_met ~= option_text
|
||||
and mode ~= 3) then
|
||||
-- else update the text
|
||||
table.insert(log, log_str.."Changed option text from \""..
|
||||
tostring(dialog.n_dialogs[d_id].d_options[o_id].o_text_when_prerequisites_met)..
|
||||
"\" to \""..tostring(option_text).."\" for option \""..tostring(o_id).."\".")
|
||||
-- actually update the text
|
||||
dialog.n_dialogs[d_id].d_options[o_id].o_text_when_prerequisites_met = option_text
|
||||
end
|
||||
|
||||
-- abbreviate that
|
||||
local o_data = dialog.n_dialogs[d_id].d_options[o_id]
|
||||
|
||||
-- cchnage option_text if needed
|
||||
if(o_data.o_text_when_prerequisites_met ~= option_text) then
|
||||
table.insert(log, log_str.."Changed option text from \""..
|
||||
tostring(o_data.o_text_when_prerequisites_met)..
|
||||
"\" to \""..tostring(option_text).."\" for option \""..tostring(o_id).."\".")
|
||||
end
|
||||
-- actually update the text
|
||||
o_data.o_text_when_prerequisites_met = option_text
|
||||
|
||||
-- chnage greyed out text if needed
|
||||
if(o_data.o_text_when_prerequisites_not_met ~= option_text_if_preconditions_false
|
||||
and option_text_if_preconditions_false) then
|
||||
table.insert(log, log_str.."Changed greyed out text when prerequisites not met from \""..
|
||||
tostring(o_data.o_text_when_prerequisites_not_met)..
|
||||
"\" to \""..tostring(option_text_if_preconditions_false or "")..
|
||||
"\" for option \""..tostring(o_id).."\".")
|
||||
-- make sure the greyed out text gets shown (or not shown)
|
||||
o_data.o_text_when_prerequisites_not_met = option_text_if_preconditions_false or ""
|
||||
end
|
||||
-- make grey_out_ text visible if necessary
|
||||
if(o_data.o_text_when_prerequisites_not_met and o_data.o_text_when_prerequisites_not_met ~= ""
|
||||
and option_text_if_preconditions_false and option_text_if_preconditions_false ~= "") then
|
||||
-- make sure this text is really shown - and greyed out
|
||||
-- (resetting this can only happen through editing the NPC directly; not through import)
|
||||
o_data.o_hide_when_prerequisites_not_met = "false"
|
||||
o_data.o_grey_when_prerequisites_not_met = "true"
|
||||
else
|
||||
-- if this were not set to true, then the player would see a clickable button for
|
||||
-- the option - but that button would do nothing
|
||||
o_data.o_hide_when_prerequisites_not_met = "true"
|
||||
o_data.o_grey_when_prerequisites_not_met = "false"
|
||||
end
|
||||
|
||||
local r_found = false
|
||||
-- the target_dialog may have been changed
|
||||
for r_id, r in pairs(o_data.o_results or {}) do
|
||||
@ -475,22 +493,6 @@ yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_nam
|
||||
elseif(mode == 2 and not(o_data.o_random)) then
|
||||
o_data.o_random = 1
|
||||
table.insert(log, log_str.."Changed option \""..tostring(o_id).."\" to RANDOMLY SELECTED.")
|
||||
-- grey out the given text and show that as answer when preconditions not met?
|
||||
elseif(mode == 3) then
|
||||
if((not(o_data.o_text_when_prerequisites_not_met
|
||||
or o_data.o_text_when_prerequisites_not_met ~= text_when_prerequisites_not_met))) then
|
||||
|
||||
table.insert(log, log_str.."Changed option text WHEN PREREQUISITES NOT MET from \""..
|
||||
tostring(o_data.o_text_when_prerequisites_not_met)..
|
||||
"\" to \""..tostring(text_when_prerequisites_not_met)..
|
||||
"\" for option \""..tostring(o_id).."\".")
|
||||
-- actually change it
|
||||
o_data.o_text_when_prerequisites_not_met = text_when_prerequisites_not_met
|
||||
end
|
||||
-- make sure this text is really shown - and greyed out
|
||||
-- (resetting this can only happen through editing the NPC directly; not through import)
|
||||
o_data.o_hide_when_prerequisites_not_met = "false"
|
||||
o_data.o_grey_when_prerequisites_not_met = "true"
|
||||
else
|
||||
-- mode is 0 - that means everything is normal for this option
|
||||
if(o_data.o_autoanswer) then
|
||||
@ -503,9 +505,6 @@ yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_nam
|
||||
table.insert(log, log_str.."Removed RANDOMLY SELECTED from option \""..
|
||||
tostring(o_id).."\".")
|
||||
end
|
||||
-- set visibility back to default
|
||||
o_data.o_hide_when_prerequisites_not_met = "false"
|
||||
o_data.o_grey_when_prerequisites_not_met = "false"
|
||||
end
|
||||
|
||||
-- the visit_only_once option is handled without logging as it might create too many
|
||||
|
||||
Loading…
Reference in New Issue
Block a user