allow to show usage of internal variables again

This commit is contained in:
Sokomine 2021-07-15 04:40:25 +02:00
parent cbaf8d4640
commit 58b5aa2cbb
2 changed files with 16 additions and 6 deletions

View File

@ -983,7 +983,9 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
"back_from_show_var_usage",
"Back to select "..effect_name.." "..tostring(x_id)..
" of option "..tostring(o_id)..
" of dialog "..tostring(d_id))
" of dialog "..tostring(d_id),
-- internal variable?
(data and data.variable and data.variable < 3))
})
return
end
@ -1007,7 +1009,9 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
"back_from_error_msg",
"Back to select "..effect_name.." "..tostring(x_id)..
" of option "..tostring(o_id)..
" of dialog "..tostring(d_id))
" of dialog "..tostring(d_id),
-- internal variable?
(data and data.variable and data.variable < 3))
})
return
end

View File

@ -384,7 +384,6 @@ end
-- which NPC do use this variable?
yl_speak_up.get_npc_users_of_variable = function(var_name)
var_name = yl_speak_up.restore_complete_var_name(var_name, pname)
-- no variable, or nothing stored? then it's not used by any NPC either
if(not(var_name)
or not(yl_speak_up.player_vars[ var_name ])
@ -427,9 +426,13 @@ end
-- find out where this variable is used in NPCs
yl_speak_up.get_list_of_usage_of_variable = function(var_name, pname, check_preconditions,
back_button_name, back_button_text)
var_name = yl_speak_up.restore_complete_var_name(var_name, pname)
back_button_name, back_button_text, is_internal_var)
-- TODO: check if the player really has read access to this variable
if(not(is_internal_var)) then
var_name = yl_speak_up.restore_complete_var_name(var_name, pname)
end
-- which NPC (might be several) is using this variable?
-- TODO: ..or if the player at least is owner of these NPC or has extended privs
local npc_list = yl_speak_up.get_npc_users_of_variable(var_name)
-- list of all relevant preconditions, actions and effects
local res = {}
@ -552,12 +555,15 @@ yl_speak_up.get_list_of_usage_of_variable = function(var_name, pname, check_prec
" and changed in "..
minetest.colorize("#55FF55", tostring(count_changed).." (Ef)fects")..
".]")
else
elseif(not(is_internal_var)) then
-- TODO: make delete_unused_variable work
table.insert(formspec,
"button[0.2,30.6;56.6,1.2;delete_unused_variable;"..
minetest.formspec_escape("Delete this unused variable \""..
tostring(var_name or "- ? -")).."\".]")
else
table.insert(formspec,
"label[16.0,31.0;This is an internal variable and cannot be deleted.]")
end
return table.concat(formspec, "\n")
end