made formspec for manage variables look good again

This commit is contained in:
Sokomine 2022-10-29 22:13:07 +02:00
parent 5fd501187d
commit c70f61bc38
3 changed files with 27 additions and 25 deletions

View File

@ -5,12 +5,12 @@
-- Note: With the what_is_the_list_about-parameter, it is possible to handle i.e. variables as well -- 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, stretch_x, dropdown_name, what_is_the_list_about, delete_button_text, start_x, start_y, stretch_x, h, dropdown_name, what_is_the_list_about, delete_button_text,
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)..";".. local text = "dropdown["..tostring(start_x)..","..tostring(start_y)..";"..
tostring(3.8 + stretch_x)..";".. tostring(3.8 + stretch_x)..","..tostring(h)..";"..
tostring(dropdown_name)..";Add "..tostring(what_is_the_list_about)..":" 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
@ -27,13 +27,13 @@ yl_speak_up.create_dropdown_playerlist = function(player, pname,
if(index_selected == 1) then if(index_selected == 1) then
-- first index "Add player" selected? Then offer a field for entering the name -- first index "Add player" selected? Then offer a field for entering the name
text = text.."field["..tostring(start_x + 4.0 + stretch_x)..","..tostring(start_y).. text = text.."field["..tostring(start_x + 4.0 + stretch_x)..","..tostring(start_y)..
";"..tostring(3.5 + stretch_x)..",0.9;".. ";"..tostring(3.5 + stretch_x)..","..tostring(h)..";"..
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)..";"..
tostring(explain_add_player).."]" tostring(explain_add_player).."]"
else else
text = text.."button["..tostring(start_x + 3.8 + stretch_x)..","..tostring(start_y).. text = text.."button["..tostring(start_x + 3.8 + stretch_x)..","..tostring(start_y)..
";"..tostring(3.4 + stretch_x)..",0.9;".. ";"..tostring(3.4 + stretch_x)..","..tostring(h)..";"..
tostring(field_name_for_deleting_player)..";".. tostring(field_name_for_deleting_player)..";"..
tostring(delete_button_text).."]".. tostring(delete_button_text).."]"..
"tooltip["..tostring(field_name_for_deleting_player)..";".. "tooltip["..tostring(field_name_for_deleting_player)..";"..

View File

@ -277,7 +277,7 @@ yl_speak_up.get_fs_initial_config = function(player, n_id, d_id, is_initial_conf
-- offer a dropdown list and a text input field for player names for adding -- offer a dropdown list and a text input field for player names for adding
yl_speak_up.create_dropdown_playerlist(player, pname, yl_speak_up.create_dropdown_playerlist(player, pname,
table_of_names, yl_speak_up.speak_to[pname].tmp_index, table_of_names, yl_speak_up.speak_to[pname].tmp_index,
3.0, 4.3, 0.0, "list_may_edit", "player", "Remove player from list", 3.0, 4.3, 0.0, 1.0, "list_may_edit", "player", "Remove player from list",
"add_may_edit", "add_may_edit",
"Enter the name of the player whom you\n".. "Enter the name of the player whom you\n"..
"want to grant the right to edit your NPC.\n".. "want to grant the right to edit your NPC.\n"..

View File

@ -332,7 +332,7 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
or yl_speak_up.speak_to[pname].tmp_index_variable == 1 or yl_speak_up.speak_to[pname].tmp_index_variable == 1
or not(var_list[ yl_speak_up.speak_to[pname].tmp_index_variable - 1])) then or not(var_list[ yl_speak_up.speak_to[pname].tmp_index_variable - 1])) then
yl_speak_up.speak_to[pname].tmp_index_variable = 1 yl_speak_up.speak_to[pname].tmp_index_variable = 1
additional_buttons = "button[11.4,1.9;2.5,0.9;add_variable;Create variable]".. additional_buttons = "button[12.2,2.15;2.5,0.6;add_variable;Create variable]"..
"tooltip[add_variable;Create a new varialbe with the name\n".. "tooltip[add_variable;Create a new varialbe with the name\n"..
"you entered in the field to the left.]" "you entered in the field to the left.]"
@ -346,7 +346,7 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
if(not(yl_speak_up.speak_to[pname].tmp_index_var_read_access) if(not(yl_speak_up.speak_to[pname].tmp_index_var_read_access)
or yl_speak_up.speak_to[pname].tmp_index_var_read_access == 1) then or yl_speak_up.speak_to[pname].tmp_index_var_read_access == 1) then
yl_speak_up.speak_to[pname].tmp_index_var_read_access = 1 yl_speak_up.speak_to[pname].tmp_index_var_read_access = 1
add_read_button = "button[12.9,2.9;1.0,0.9;add_read_access;Add]".. add_read_button = "button[14.6,2.95;1.0,0.6;add_read_access;Add]"..
"tooltip[add_read_access;Grant the player whose name you entered\n".. "tooltip[add_read_access;Grant the player whose name you entered\n"..
"you entered in the field to the left read access\n".. "you entered in the field to the left read access\n"..
"to your variable.]" "to your variable.]"
@ -354,7 +354,7 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
if(not(yl_speak_up.speak_to[pname].tmp_index_var_write_access) if(not(yl_speak_up.speak_to[pname].tmp_index_var_write_access)
or yl_speak_up.speak_to[pname].tmp_index_var_write_access == 1) then or yl_speak_up.speak_to[pname].tmp_index_var_write_access == 1) then
yl_speak_up.speak_to[pname].tmp_index_var_write_access = 1 yl_speak_up.speak_to[pname].tmp_index_var_write_access = 1
add_write_button = "button[12.9,3.9;1.0,0.9;add_write_access;Add]".. add_write_button = "button[14.6,3.95;1.0,0.6;add_write_access;Add]"..
"tooltip[add_write_access;Grant the player whose name you entered\n".. "tooltip[add_write_access;Grant the player whose name you entered\n"..
"you entered in the field to the left *write* access\n".. "you entered in the field to the left *write* access\n"..
"to your variable.]" "to your variable.]"
@ -405,9 +405,9 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
end end
debug_button = debug_button.. debug_button = debug_button..
"label[0.2,8.05;Show stored value for player:]".. "label[0.2,8.05;Show stored value for player:]"..
"field[4.2,8.15;4.0,0.9;stored_value_for_player;;".. "field[4.9,7.75;4.0,0.6;stored_value_for_player;;"..
minetest.formspec_escape(param).."]".. minetest.formspec_escape(param).."]"..
"button[8.2,7.85;4.0,0.9;show_stored_value_for_player;Show value for this player]".. "button[9.0,7.75;4.5,0.6;show_stored_value_for_player;Show value for this player]"..
"tooltip[stored_value_for_player;Enter the name of the player for which you\n".. "tooltip[stored_value_for_player;Enter the name of the player for which you\n"..
"want to check (or change) the stored value.]".. "want to check (or change) the stored value.]"..
"tooltip[show_stored_value_for_player;Click here to read and the current value".. "tooltip[show_stored_value_for_player;Click here to read and the current value"..
@ -416,30 +416,31 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
local v = yl_speak_up.get_quest_variable_value(param, k_long) or "" local v = yl_speak_up.get_quest_variable_value(param, k_long) or ""
debug_button = debug_button.. debug_button = debug_button..
"label[0.2,9.05;Found stored value:]".. "label[0.2,9.05;Found stored value:]"..
"field[4.2,9.15;4.0,0.9;current_value_for_player;;".. "field[4.9,8.75;4.0,0.6;current_value_for_player;;"..
minetest.formspec_escape(v).."]".. minetest.formspec_escape(v).."]"..
"tooltip[current_value_for_player;You can see and change the current ".. "tooltip[current_value_for_player;You can see and change the current "..
"value here.]".. "value here.]"..
"button[8.2,8.85;4.0,0.9;store_new_value_for_player;".. "button[9.0,8.75;4.5,0.6;store_new_value_for_player;"..
"Store this as new value]".. "Store this as new value]"..
"tooltip[store_new_value_for_player;".. "tooltip[store_new_value_for_player;"..
"Click here to update the stored value for this player.".. "Click here to update the stored value for this player."..
"\nWARNING: Be very careful here and never do this without".. "\nWARNING: Be very careful here and never do this without"..
"\n informing the player about this change!]".. "\n informing the player about this change!]"..
"button[12.5,8.85;3.0,0.9;unset_value_for_player;".. "button[13.9,8.75;3.0,0.6;unset_value_for_player;"..
"Remove this entry]".. "Remove this entry]"..
"tooltip[unset_value_for_player;Click here to delete the entry for this ".. "tooltip[unset_value_for_player;Click here to delete the entry for this "..
"player.\nSetting the entry to an empty string would not be ".. "player.\nSetting the entry to an empty string would not be "..
"the same!]" "the same!]"
end end
additional_buttons = "button[11.4,1.9;2.5,0.9;show_var_usage;Where is it used?]".. additional_buttons = "button[12.2,2.15;3.0,0.6;show_var_usage;Where is it used?]"..
"tooltip[show_var_usage;Show which NPC use this variable in which context.]".. "tooltip[show_var_usage;Show which NPC use this variable in which context.]"..
-- offer a dropdown list and a text input field for new varialbe names for adding -- offer a dropdown list and a text input field for new varialbe names for adding
"label[0.2,3.05;Players with read access to this variable:]".. "label[0.2,3.25;Players with read access to this variable:]"..
yl_speak_up.create_dropdown_playerlist(player, pname, yl_speak_up.create_dropdown_playerlist(player, pname,
pl_with_read_access, pl_with_read_access,
yl_speak_up.speak_to[pname].tmp_index_var_read_access, yl_speak_up.speak_to[pname].tmp_index_var_read_access,
5.5, 2.9, 0.0, "list_var_read_access", "player", "Remove player from list", 6.9, 2.95, 0.0, 0.6, "list_var_read_access", "player",
"Remove player from list",
"grant_player_var_read_access", "grant_player_var_read_access",
"Enter the name of the player that shall\n".. "Enter the name of the player that shall\n"..
"have read access to this variable.", "have read access to this variable.",
@ -448,11 +449,12 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
"will no longer be able to add new\n".. "will no longer be able to add new\n"..
"pre(C)onditions which read your variable." "pre(C)onditions which read your variable."
)..add_read_button.. )..add_read_button..
"label[0.2,4.05;Players with *write* access to this variable:]".. "label[0.2,4.25;Players with *write* access to this variable:]"..
yl_speak_up.create_dropdown_playerlist(player, pname, yl_speak_up.create_dropdown_playerlist(player, pname,
pl_with_write_access, pl_with_write_access,
yl_speak_up.speak_to[pname].tmp_index_var_write_access, yl_speak_up.speak_to[pname].tmp_index_var_write_access,
5.5, 3.9, 0.0, "list_var_write_access", "player", "Remove player from list", 6.9, 3.95, 0.0, 0.6,
"list_var_write_access", "player", "Remove player from list",
"grant_player_var_write_access", "grant_player_var_write_access",
"Enter the name of the player that shall\n".. "Enter the name of the player that shall\n"..
"have *write* access to this variable.", "have *write* access to this variable.",
@ -480,17 +482,17 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
"player.\nShow these values in a table.]".. "player.\nShow these values in a table.]"..
debug_button debug_button
end end
return "size[16,11.5]".. return "size[18,12]"..
"label[5.0,0.0;* Manage your variables *]".. "label[7.0,0.4;* Manage your variables *]"..
"label[0.2,0.8;Note: Each variable will store a diffrent value for each player who ".. "label[0.2,1.2;Note: Each variable will store a diffrent value for each player who "..
"interacts with the NPC.\n".. "interacts with the NPC.\n"..
"You can grant read and write access to other players for your ".. "You can grant read and write access to other players for your "..
"variables so that they can also use them as well.]".. "variables so that they can also use them as well.]"..
"label[0.2,2.05;Your variables:]".. "label[0.2,2.45;Your variables:]"..
-- offer a dropdown list and a text input field for new varialbe names for adding -- offer a dropdown list and a text input field for new varialbe names for adding
yl_speak_up.create_dropdown_playerlist(player, pname, yl_speak_up.create_dropdown_playerlist(player, pname,
table_of_vars, yl_speak_up.speak_to[pname].tmp_index_variable, table_of_vars, yl_speak_up.speak_to[pname].tmp_index_variable,
2.2, 1.9, 1.0, "list_var_names", "variable", "Delete selected variable", 2.6, 2.15, 1.0, 0.6, "list_var_names", "variable", "Delete selected variable",
"add_variable_name", "add_variable_name",
"Enter the name of the new variable you\n".. "Enter the name of the new variable you\n"..
"want to create.", "want to create.",
@ -499,6 +501,6 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
"will be deleted." "will be deleted."
).. )..
additional_buttons.. additional_buttons..
"button[0.0,0.2;1.0,0.6;back;Back]".. "button[0.0,0.2;2.0,0.6;back;Back]"..
"button[6.5,11.0;1.0,0.6;back;Back]" "button[8.0,11.0;2.0,0.6;back;Back]"
end end