From f199a9d04c26d233ab7ffac483a2d088029309cf Mon Sep 17 00:00:00 2001 From: Sokomine Date: Thu, 3 Jun 2021 01:08:21 +0200 Subject: [PATCH] don't show add button in edit options menu if already max number of options --- fs_edit_options_dialog.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fs_edit_options_dialog.lua b/fs_edit_options_dialog.lua index b998784..42c9ba8 100644 --- a/fs_edit_options_dialog.lua +++ b/fs_edit_options_dialog.lua @@ -219,6 +219,7 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id) -- sort all options by o_sort local sorted_list = yl_speak_up.get_sorted_options(n_dialog.d_options, "o_sort") local o_found = o_id + local anz_options = 0 for i, o in ipairs(sorted_list) do if(o == o_id and sorted_list[ i-1 ]) then button_prev = "".. @@ -232,7 +233,17 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id) "tooltip[edit_option_next;Go to next option/answer ".. "(according to o_sort).]" end + anz_options = anz_options + 1 end + + -- less than yl_speak_up.max_number_of_options_per_dialog options? + local button_add = "".. + "button[2.4,17;2.0,0.9;add_option;Add]".. + "tooltip[add_option;Add a new option/answer to this dialog.]" + if(anz_options >= yl_speak_up.max_number_of_options_per_dialog) then + button_add = "" + end + -- build up the formspec local formspec = "".. "formspec_version[3]".. @@ -297,8 +308,7 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id) "button[0.2,17;2.0,0.9;del_option;Delete]".. "tooltip[del_option;Delete this option/answer.]".. -- button: add new - "button[2.4,17;2.0,0.9;add_option;Add]".. - "tooltip[add_option;Add a new option/answer to this dialog.]".. + button_add.. -- button: prev/next button_prev.. button_next..