diff --git a/print_as_table.lua b/print_as_table.lua index 1f19c59..00f4bfc 100644 --- a/print_as_table.lua +++ b/print_as_table.lua @@ -91,11 +91,22 @@ yl_speak_up.print_as_table_dialog = function(p_text, r_text, dialog, n_id, d_id, end -yl_speak_up.print_as_table_prepare_formspec = function(res, table_name, back_button_name, back_button_text) - local sorted_list = yl_speak_up.get_sorted_options(res, "sort_value") +yl_speak_up.print_as_table_prepare_formspec = function(res, table_name, back_button_name, back_button_text, + is_already_sorted, concat_with, table_columns) local sorted_res = {} - for i, k in pairs(sorted_list) do - table.insert(sorted_res, res[ k ].text) + -- this is the default for "show where a variable is used" + if(not(is_already_sorted)) then + local sorted_list = yl_speak_up.get_sorted_options(res, "sort_value") + for i, k in pairs(sorted_list) do + table.insert(sorted_res, res[ k ].text) + end + table_columns = "color,span=1;text;color,span=1;text;color,span=1;text;color,span=1;text" + else + sorted_res = res + end + if(not(concat_with)) then + -- insert blank lines between lines belonging together + concat_with = ",#FFFFFF,,#FFFFFF,,#FFFFFF,,#FFFFFF,," end local formspec = { "formspec_version[3]", @@ -105,10 +116,10 @@ yl_speak_up.print_as_table_prepare_formspec = function(res, table_name, back_but minetest.formspec_escape(back_button_text).."]", "button[0.2,31.6;56.6,1.2;"..back_button_name..";".. minetest.formspec_escape(back_button_text).."]", - "tablecolumns[color,span=1;text;color,span=1;text;color,span=1;text;color,span=1;text]", - "table[1.2,2.4;55.0,28.0;"..tostring(table_name)..";" + "tablecolumns["..tostring(table_columns).."]", } - -- insert blank lines between lines belonging together - table.insert(formspec, table.concat(sorted_res, ",#FFFFFF,,#FFFFFF,,#FFFFFF,,#FFFFFF,,").."]") + table.insert(formspec, + "table[1.2,2.4;55.0,28.0;"..tostring(table_name)..";".. + table.concat(sorted_res, concat_with).."]") return formspec end