From 58b5aa2cbbc8c94eac37bd1a09e8b46b1e3de97a Mon Sep 17 00:00:00 2001 From: Sokomine Date: Thu, 15 Jul 2021 04:40:25 +0200 Subject: [PATCH] allow to show usage of internal variables again --- fs_edit_general.lua | 8 ++++++-- quest_api.lua | 14 ++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/fs_edit_general.lua b/fs_edit_general.lua index 9c70656..cdfcebd 100644 --- a/fs_edit_general.lua +++ b/fs_edit_general.lua @@ -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 diff --git a/quest_api.lua b/quest_api.lua index 092bc47..44a4fdb 100644 --- a/quest_api.lua +++ b/quest_api.lua @@ -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