forked from your-land-mirror/yl_speak_up
disable options that are not included in the current import by adding a 'false' precondition
This commit is contained in:
parent
799233c8a2
commit
9b2aae7fe1
@ -232,6 +232,41 @@ yl_speak_up.update_dialog = function(log, dialog, dialog_name, dialog_text)
|
||||
end
|
||||
|
||||
|
||||
-- helper function for update_dialog_options_completed;
|
||||
-- adds a precondition of p_type "false" to the option so that the option is no longer displayed
|
||||
-- if disable_option is false, then all preconditions of p_type "false" will be changed to p_type "true"
|
||||
-- and thus the option will be shown to the player again
|
||||
yl_speak_up.update_disable_dialog_option = function(o_data, disable_option)
|
||||
-- is this otpion already deactivated?
|
||||
local is_deactivated = false
|
||||
for p_id, p in pairs(o_data.o_prerequisites or {}) do
|
||||
if(p and p_id and p.p_type == "false") then
|
||||
is_deactivated = true
|
||||
-- if we want to re-enable the option, then this here is the place
|
||||
if(not(disable_option)) then
|
||||
-- change the type from false to true - this particular precondition
|
||||
-- will now always be true
|
||||
p.p_type = "true"
|
||||
-- we continue work here because the player may have created multiple
|
||||
-- options of this type
|
||||
end
|
||||
end
|
||||
end
|
||||
-- if not: add a precondition of type "false"
|
||||
if(not(is_deactivated) and disable_option) then
|
||||
-- we need to add a new precondition of type "false"
|
||||
-- make sure we can add the prereq:
|
||||
if(not(o_data.o_prerequisites)) then
|
||||
o_data.o_prerequisites = {}
|
||||
end
|
||||
local future_p_id = "p_"..tostring(yl_speak_up.find_next_id(o_data.o_prerequisites))
|
||||
-- we just added this option; this is the first and for now only precondition for it;
|
||||
-- the player still has to adjust it, but at least it is a reasonable default
|
||||
o_data.o_prerequisites[future_p_id] = { p_id = future_p_id, p_type = "false"}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- call this *after* all dialog options have been updated for dialog_name
|
||||
yl_speak_up.update_dialog_options_completed = function(log, dialog, d_id)
|
||||
local d_data = dialog.n_dialogs[d_id]
|
||||
@ -255,8 +290,9 @@ yl_speak_up.update_dialog_options_completed = function(log, dialog, d_id)
|
||||
end
|
||||
table.insert(log, log_str..", option <"..tostring(o_id)..">: "..
|
||||
"Option exists in old dialog but not in import. Keeping option.")
|
||||
|
||||
-- TODO: this option may need a precondition that sets it to false (if that precondition doesn't already exist)
|
||||
-- add a precondition of p_type "false" to the option so that the option
|
||||
-- is no longer displayed
|
||||
yl_speak_up.update_disable_dialog_option(o_data, true)
|
||||
end
|
||||
end
|
||||
-- clean up the dialog
|
||||
|
Loading…
Reference in New Issue
Block a user