mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-10-02 23:56:25 +02:00
42 lines
1.5 KiB
Lua
42 lines
1.5 KiB
Lua
|
|
-- is the player in edit mode?
|
|
yl_speak_up.in_edit_mode = function(pname)
|
|
return pname
|
|
and yl_speak_up.edit_mode[pname]
|
|
and (yl_speak_up.edit_mode[pname] == yl_speak_up.speak_to[pname].n_id)
|
|
end
|
|
|
|
|
|
-- in edit mode, *all* options are displayed
|
|
local old_calculate_displayable_options = yl_speak_up.calculate_displayable_options
|
|
yl_speak_up.calculate_displayable_options = function(pname, d_options, allow_recursion)
|
|
-- no options - nothing to do
|
|
if(not(d_options)) then
|
|
return {}
|
|
end
|
|
if(yl_speak_up.in_edit_mode(pname)) then
|
|
-- in edit mode: show all options (but sort them first)
|
|
local retval = {}
|
|
local sorted_list = yl_speak_up.get_sorted_options(d_options, "o_sort")
|
|
for i, o_k in ipairs(sorted_list) do
|
|
retval[o_k] = true
|
|
end
|
|
return retval
|
|
end
|
|
-- outside edit mode: really calculate what can be displayed
|
|
return old_calculate_displayable_options(pname, d_options, allow_recursion)
|
|
end
|
|
|
|
|
|
-- in edit mode, autoanswer, random dialogs and d_got_item play no role and are *not* applied
|
|
-- (we want to see and edit all options regardless of preconditions)
|
|
local old_apply_autoanswer_etc = yl_speak_up.apply_autoanswer_and_random_and_d_got_item
|
|
yl_speak_up.apply_autoanswer_and_random_and_d_got_item = function(player, pname, d_id, dialog, allowed, active_dialog, recursion_depth)
|
|
-- no automatic switching in edit_mode
|
|
if(yl_speak_up.in_edit_mode(pname)) then
|
|
return
|
|
end
|
|
return old_apply_autoanswer_etc(player, pname, d_id, dialog, allowed, active_dialog, recursion_depth)
|
|
end
|
|
|