made yl_speak_up.create_dropdown_playerlist more flexible

This commit is contained in:
Sokomine 2021-07-26 19:52:51 +02:00
parent ab87304ed2
commit 4e23d10497

View File

@ -2,14 +2,15 @@
-- helper function: -- helper function:
-- create a formspec dropdown list with player names (first entry: Add player) and -- create a formspec dropdown list with player names (first entry: Add player) and
-- an option to delete players from that list -- an option to delete players from that list
-- Note: With the what_is_the_list_about-parameter, it is possible to handle i.e. variables as well
yl_speak_up.create_dropdown_playerlist = function(player, pname, yl_speak_up.create_dropdown_playerlist = function(player, pname,
table_of_names, index_selected, table_of_names, index_selected,
start_x, start_y, dropdown_name, start_x, start_y, dropdown_name, what_is_the_list_about,
field_name_for_adding_player, explain_add_player, field_name_for_adding_player, explain_add_player,
field_name_for_deleting_player, explain_delete_player) field_name_for_deleting_player, explain_delete_player)
local text = "dropdown["..tostring(start_x)..","..tostring(start_y)..";3.8;".. local text = "dropdown["..tostring(start_x)..","..tostring(start_y)..";3.8;"..
tostring(dropdown_name)..";Add player:" tostring(dropdown_name)..";Add "..tostring(what_is_the_list_about)..":"
-- table_of_names is a table with the playernames as keys -- table_of_names is a table with the playernames as keys
-- we want to work with indices later on; in order to be able to do that reliably, we -- we want to work with indices later on; in order to be able to do that reliably, we
-- need a defined order of names -- need a defined order of names
@ -27,15 +28,13 @@ yl_speak_up.create_dropdown_playerlist = function(player, pname,
text = text.."field["..tostring(start_x + 4.0)..","..tostring(start_y + 0.3)..";3.5,0.9;".. text = text.."field["..tostring(start_x + 4.0)..","..tostring(start_y + 0.3)..";3.5,0.9;"..
tostring(field_name_for_adding_player)..";;]".. tostring(field_name_for_adding_player)..";;]"..
"tooltip["..tostring(field_name_for_adding_player)..";".. "tooltip["..tostring(field_name_for_adding_player)..";"..
"Enter the name of the player whom you\n".. tostring(explain_add_player).."]"
"want to grant the right to "..tostring(explain_add_player).."]"
else else
text = text.."button["..tostring(start_x + 3.8)..","..tostring(start_y)..";3.5,0.9;".. text = text.."button["..tostring(start_x + 3.8)..","..tostring(start_y)..";3.5,0.9;"..
tostring(field_name_for_deleting_player)..";".. tostring(field_name_for_deleting_player)..";"..
"Remove player from list]".. "Remove "..tostring(what_is_the_list_about).." from list]"..
"tooltip["..tostring(field_name_for_deleting_player)..";".. "tooltip["..tostring(field_name_for_deleting_player)..";"..
"If you click here, the player will no\n".. tostring(explain_delete_player).."]"
"longer be able to "..tostring(explain_delete_player).."]"
end end
return text return text
end end