show which npc and node_pos(itions) use a variable; fixed bug in manage_variables formspec
This commit is contained in:
parent
c8345cee4d
commit
e1072f1c72
@ -251,7 +251,10 @@ yl_speak_up.input_fs_manage_variables = function(player, formname, fields)
|
||||
yl_speak_up.speak_to[pname].tmp_index_variable = index + 1
|
||||
end
|
||||
end
|
||||
local var_name = var_list[ yl_speak_up.speak_to[pname].tmp_index_variable ]
|
||||
local var_name = var_list[ yl_speak_up.speak_to[pname].tmp_index_variable - 1]
|
||||
if(not(var_name)) then
|
||||
var_name = ""
|
||||
end
|
||||
|
||||
-- revoke read or write access to a variable
|
||||
if(fields
|
||||
@ -404,8 +407,10 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
|
||||
additional_buttons = "button[11.4,1.9;2.5,0.9;add_variable;Create variable]"..
|
||||
"tooltip[add_variable;Create a new varialbe with the name\n"..
|
||||
"you entered in the field to the left.]"
|
||||
|
||||
else
|
||||
local k = var_list[ yl_speak_up.speak_to[pname].tmp_index_variable ]
|
||||
-- index 1 is "Add variable:"
|
||||
local k = var_list[ yl_speak_up.speak_to[pname].tmp_index_variable - 1]
|
||||
local pl_with_read_access = yl_speak_up.get_access_list_for_var(k, pname, "read_access")
|
||||
local pl_with_write_access = yl_speak_up.get_access_list_for_var(k, pname, "write_access")
|
||||
local add_read_button = ""
|
||||
@ -426,6 +431,43 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
|
||||
"you entered in the field to the left *write* access\n"..
|
||||
"to your variable.]"
|
||||
end
|
||||
local list_of_npc_users = ""
|
||||
local list_of_node_pos_users = ""
|
||||
-- expand name of variable k again
|
||||
local k_long = yl_speak_up.add_pname_to_var(k, pname)
|
||||
-- which npc and which node_pos use this variable? create a list for display
|
||||
local c1 = 0
|
||||
local c2 = 0
|
||||
if(k_long
|
||||
and yl_speak_up.player_vars[ k_long ]
|
||||
and yl_speak_up.player_vars[ k_long ][ "$META$"]) then
|
||||
for key, v in pairs(yl_speak_up.player_vars[ k_long ][ "$META$"][
|
||||
"used_by_npc" ] or {}) do
|
||||
if(c1==0) then
|
||||
list_of_npc_users = minetest.formspec_escape(key)
|
||||
else
|
||||
list_of_npc_users = list_of_npc_users..", "..
|
||||
minetest.formspec_escape(key)
|
||||
end
|
||||
c1 = c1 + 1
|
||||
end
|
||||
for key, v in pairs(yl_speak_up.player_vars[ k_long ][ "$META$" ][
|
||||
"used_by_node_pos" ] or {}) do
|
||||
if(c2==0) then
|
||||
list_of_node_pos_users = minetest.formspec_escape(key)
|
||||
else
|
||||
list_of_node_pos_users = list_of_node_pos_users..", "..
|
||||
minetest.formspec_escape(key)
|
||||
end
|
||||
c2 = c2 + 1
|
||||
end
|
||||
end
|
||||
if(list_of_npc_users == "") then
|
||||
list_of_npc_users = "- none -"
|
||||
end
|
||||
if(list_of_node_pos_users == "") then
|
||||
list_of_node_pos_users = "- none -"
|
||||
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
|
||||
@ -458,9 +500,17 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
|
||||
"label[0.2,5.05;Type of variable: "..
|
||||
-- TODO: show actual type
|
||||
minetest.colorize("#FFFF00","String/text or numerical value, depending "..
|
||||
"on how you use it")..".]"
|
||||
"on how you use it")..".]"..
|
||||
"label[0.2,6.05;This variable is used by the following "..
|
||||
minetest.colorize("#FFFF00", tostring(c1)).." NPC:\n\t"..
|
||||
-- those are only n_id - no need to formspec_escape that
|
||||
minetest.colorize("#FFFF00", list_of_npc_users)..".]"..
|
||||
"label[0.2,7.05;This variable is used by the following "..
|
||||
minetest.colorize("#FFFF00", tostring(c2)).." node positions:\n\t"..
|
||||
-- those are only pos_to_string(..) - no need to formspec_escape that
|
||||
minetest.colorize("#FFFF00", list_of_node_pos_users)..".]"
|
||||
end
|
||||
return "size[14,6.5]"..
|
||||
return "size[16,8.5]"..
|
||||
"label[5.0,0.0;* Manage your variables *]"..
|
||||
"label[0.2,0.8;Note: Each variable will store a diffrent value for each player who "..
|
||||
"interacts with the NPC.\n"..
|
||||
@ -480,7 +530,7 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
|
||||
)..
|
||||
additional_buttons..
|
||||
"button[0.0,0.2;1.0,0.6;back;Back]"..
|
||||
"button[6.0,6.0;1.0,0.6;back;Back]"
|
||||
"button[6.0,8.0;1.0,0.6;back;Back]"
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user