diff --git a/fs_edit_options_dialog.lua b/fs_edit_options_dialog.lua index 122d054..293b6d6 100644 --- a/fs_edit_options_dialog.lua +++ b/fs_edit_options_dialog.lua @@ -102,6 +102,12 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields) -- show the trade with ID " " yl_speak_up.show_fs(player, "trade_simple", tostring(d_id).." "..tostring(o_id)) return + + -- the player clicked on a precondition + elseif(fields.table_of_preconditions) then + + -- the player clicked on an effect + elseif(fields.table_of_effects) then end -- if ESC is pressed or anything else unpredicted happens: go back to the main dialog edit window @@ -132,26 +138,28 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id) local list_of_preconditions = "" local prereq = d_option.o_prerequisites if(prereq) then - for k, v in pairs(prereq) do + local sorted_key_list = yl_speak_up.sort_keys(prereq) + for i, k in ipairs(sorted_key_list) do + local v = prereq[ k ] list_of_preconditions = list_of_preconditions.. minetest.formspec_escape(v.p_id)..",#FFFF00,".. minetest.formspec_escape(v.p_type)..",".. minetest.formspec_escape(v.p_value).."," end end + list_of_preconditions = list_of_preconditions..",#00FF00,add,Add a new pre(C)ondition" local list_of_actions = "" if(dialog.trades and dialog.trades[ tostring(d_id).." "..tostring(o_id) ]) then local tr = dialog.trades[ tostring(d_id).." "..tostring(o_id)] -- show the trade in the result/effects list - list_of_actions = ",#00FF00,trade,".. + list_of_actions = ",#FF8800,trade,".. -- show a reasonable overview of what is traded for what minetest.formspec_escape("NPC sells ".. table.concat(tr.buy, ";").." for ".. table.concat(tr.pay, ";")) else - list_of_actions = ",#00FF00,add,".. - "Add a new effect" + list_of_actions = ",#00FF00,add,Add a new (A)ction" end -- find the right target dialog for this option (if it exists) @@ -160,7 +168,9 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id) local list_of_effects = "" local results = d_option.o_results if(results) then - for k, v in pairs(results) do + local sorted_key_list = yl_speak_up.sort_keys(results) + for i, k in ipairs(sorted_key_list) do + local v = results[ k ] if v.r_type == "dialog" and dialog.n_dialogs[v.r_value] ~= nil then -- there may be more than one in the data structure target_dialog = v.r_value @@ -172,6 +182,7 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id) end end end + list_of_effects = list_of_effects..",#00FF00,add,Add a new (Ef)fect" -- if no target dialog has been selected: default is to go to the dialog with d_sort 0 if(not(target_dialog) or target_dialog == "" or not(dialog.n_dialogs[target_dialog])) then @@ -297,7 +308,7 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id) "apply the following (Ef)fects:]".. -- TODO: perhaps add tooltip for the type of the conditions "tablecolumns[text;color,span=1;text;text]".. - "table[1.2,12.3;21.0,2.0;table_of_effect;".. + "table[1.2,12.3;21.0,2.0;table_of_effects;".. list_of_effects..";0]".. -- ..and what the NPC will reply to that answer "label[0.2,15.1;The NPC will react to this answer with the following dialog:]"..