allow to activate and deactivate debug mode for variables
This commit is contained in:
parent
eb7d1701a1
commit
7117131207
@ -87,12 +87,49 @@ yl_speak_up.input_fs_manage_variables = function(player, formname, fields)
|
||||
|
||||
|
||||
-- show all stored values for a variable in a table
|
||||
if(fields and fields.show_stored_values_for_var) then
|
||||
if(fields and fields.show_stored_values_for_var and var_name) then
|
||||
yl_speak_up.show_fs(player, "msg", {
|
||||
input_to = "yl_speak_up:manage_variables",
|
||||
formspec = yl_speak_up.fs_show_all_var_values(player, pname, var_name)
|
||||
})
|
||||
return
|
||||
-- enable, disable and list variables in debug mode
|
||||
elseif(fields and fields.enable_debug_mode and var_name) then
|
||||
yl_speak_up.set_variable_metadata(var_name, pname, "debug", pname, true)
|
||||
yl_speak_up.show_fs(player, "msg", {
|
||||
input_to = "yl_speak_up:manage_variables",
|
||||
formspec = "size[10,2]"..
|
||||
"label[0.2,0.0;Activating debug mode for variable \""..
|
||||
minetest.colorize("#FFFF00",
|
||||
minetest.formspec_escape(tostring(var_name)))..
|
||||
"\".\nYou will now receive a chat message whenever the "..
|
||||
"variable changes.]"..
|
||||
"button[1.5,1.5;2,0.9;back_from_msg;Back]"})
|
||||
return
|
||||
elseif(fields and fields.disable_debug_mode and var_name) then
|
||||
yl_speak_up.set_variable_metadata(var_name, pname, "debug", pname, nil)
|
||||
yl_speak_up.show_fs(player, "msg", {
|
||||
input_to = "yl_speak_up:manage_variables",
|
||||
formspec = "size[10,2]"..
|
||||
"label[0.2,0.0;Deactivating debug mode for variable \""..
|
||||
minetest.colorize("#FFFF00",
|
||||
minetest.formspec_escape(tostring(var_name)))..
|
||||
"\".\nYou will no longer receive a chat message whenever the "..
|
||||
"variable changes.]"..
|
||||
"button[1.5,1.5;2,0.9;back_from_msg;Back]"})
|
||||
return
|
||||
elseif(fields and fields.list_debug_mode) then
|
||||
yl_speak_up.show_fs(player, "msg", {
|
||||
input_to = "yl_speak_up:manage_variables",
|
||||
formspec = "size[10,6]"..
|
||||
"label[0.2,0.0;You are currently receiving debug information for the "..
|
||||
"following variables:]"..
|
||||
"tablecolumns[text]"..
|
||||
"table[0.8,0.8;8.8,4.0;list_of_variables_in_debug_mode;"..
|
||||
-- the table entries will already be formspec_escaped
|
||||
table.concat(yl_speak_up.get_list_of_debugged_variables(pname), ",").."]"..
|
||||
"button[1.5,5.5;2,0.9;back_from_msg;Back]"})
|
||||
return
|
||||
-- delete (empty) variable
|
||||
elseif(fields
|
||||
and ((fields.delete_variable and fields.delete_variable ~= "")
|
||||
@ -106,7 +143,6 @@ yl_speak_up.input_fs_manage_variables = function(player, formname, fields)
|
||||
minetest.formspec_escape(tostring(var_name))..
|
||||
"\":\n"..text.."]"..
|
||||
"button[1.5,1.5;2,0.9;back_from_msg;Back]"})
|
||||
|
||||
return
|
||||
|
||||
-- revoke read or write access to a variable
|
||||
@ -306,6 +342,24 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
|
||||
node_pos_users, ", "))
|
||||
end
|
||||
end
|
||||
local debug_button = "button[10.0,8.05;4.0,0.6;list_debug_mode;What am I debugging?]"..
|
||||
"tooltip[list_debug_mode;"..
|
||||
"Show for which variables you currently have "..
|
||||
"\nactivated the debug mode.]"
|
||||
local debuggers = yl_speak_up.get_variable_metadata(k_long, "debug")
|
||||
local i = table.indexof(debuggers, pname)
|
||||
if(i and i > 0) then
|
||||
debug_button = "button[5.0,8.05;4.0,0.6;disable_debug_mode;Deactivate debug mode]"..
|
||||
"tooltip[disable_debug_mode;"..
|
||||
"You will no longer receive a chat message "..
|
||||
"\nwhen this value changes for a player.]"..debug_button
|
||||
else
|
||||
debug_button = "button[5.0,8.05;4.0,0.6;enable_debug_mode;Activate debug mode]"..
|
||||
"tooltip[enable_debug_mode;"..
|
||||
"You will receive a chat message whenever the value "..
|
||||
"\nof this variable changes for one player. The debug\n"..
|
||||
"messages will be sent even after relogin.]"..debug_button
|
||||
end
|
||||
additional_buttons = "button[11.4,1.9;2.5,0.9;show_var_usage;Where is it used?]"..
|
||||
"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
|
||||
@ -351,7 +405,8 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
|
||||
minetest.colorize("#FFFF00", list_of_node_pos_users)..".]"..
|
||||
"button[0.2,8.05;4.0,0.6;show_stored_values_for_var;Show all stored values]"..
|
||||
"tooltip[show_stored_values_for_var;A diffrent value can be stored for each "..
|
||||
"player.\nShow these values in a table.]"
|
||||
"player.\nShow these values in a table.]"..
|
||||
debug_button
|
||||
end
|
||||
return "size[16,11.5]"..
|
||||
"label[5.0,0.0;* Manage your variables *]"..
|
||||
|
@ -461,3 +461,19 @@ yl_speak_up.get_variable_metadata = function(var_name, meta_name)
|
||||
table.sort(meta_list)
|
||||
return meta_list
|
||||
end
|
||||
|
||||
|
||||
-- show which variables the player is currently debugging
|
||||
yl_speak_up.get_list_of_debugged_variables = function(pname)
|
||||
if(not(pname) or pname == "") then
|
||||
return
|
||||
end
|
||||
local res = {}
|
||||
for k, v in pairs(yl_speak_up.player_vars) do
|
||||
if(k and v and v[ "$META$" ] and v[ "$META$" ][ "debug" ]) then
|
||||
-- this will be used in a table presented to the player
|
||||
table.insert(res, minetest.formspec_escape(k))
|
||||
end
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user