forked from Sokomine/yl_speak_up
505 lines
23 KiB
Lua
505 lines
23 KiB
Lua
|
|
yl_speak_up.input_fs_manage_variables = function(player, formname, fields)
|
|
local pname = player:get_player_name()
|
|
if(fields and fields.back_from_msg) then
|
|
yl_speak_up.show_fs(player, "manage_variables", fields.stored_value_for_player)
|
|
return
|
|
end
|
|
-- leave this formspec
|
|
if(fields and (fields.quit or fields.exit or fields.back)) then
|
|
local last_fs = yl_speak_up.speak_to[pname][ "working_at" ]
|
|
yl_speak_up.show_fs(player, last_fs)
|
|
return
|
|
-- add a new variable?
|
|
elseif(fields and fields.add_variable) then
|
|
local error_msg = ""
|
|
if(not(fields.add_variable_name) or fields.add_variable_name == ""
|
|
or fields.add_variable_name:trim() == "") then
|
|
error_msg = "Please enter the name of your variable!"
|
|
-- limit names to something more sensible
|
|
elseif(string.len(fields.add_variable_name) > 30) then
|
|
error_msg = "The name of your variable name is too long.\n"..
|
|
"Only up to 30 characters are allowed."
|
|
elseif(string.len(fields.add_variable_name:trim()) < 2) then
|
|
error_msg = "The name of your variable name is too short.\n"..
|
|
"It has to be at least 2 characters long."
|
|
else
|
|
fields.add_variable_name = fields.add_variable_name:trim()
|
|
local res = yl_speak_up.add_quest_variable(pname, fields.add_variable_name)
|
|
-- not really an error msg here - but fascilitates output
|
|
error_msg = "A new variable named\n \""..
|
|
minetest.formspec_escape(fields.add_variable_name)..
|
|
"\"\nhas been created."
|
|
if(not(res)) then
|
|
error_msg = "Failed to create variable named\n \""..
|
|
minetest.formspec_escape(fields.add_variable_name).."\"."
|
|
else
|
|
-- slect this new variable
|
|
local var_list = yl_speak_up.get_quest_variables(pname, true)
|
|
-- make names of own variables shorter
|
|
yl_speak_up.strip_pname_from_varlist(var_list, pname)
|
|
table.sort(var_list)
|
|
local index = table.indexof(var_list, fields.add_variable_name)
|
|
if(index and index > -1) then
|
|
yl_speak_up.speak_to[pname].tmp_index_variable = index + 1
|
|
end
|
|
end
|
|
end
|
|
yl_speak_up.show_fs(player, "msg", {
|
|
input_to = "yl_speak_up:manage_variables",
|
|
formspec = "size[6,2]"..
|
|
"label[0.2,0.0;"..error_msg.."]"..
|
|
"button[1.5,1.5;2,0.9;back_from_msg;Back]"})
|
|
return
|
|
-- show where this variable is used
|
|
elseif(fields and fields.show_var_usage and fields.show_var_usage ~= "") then
|
|
yl_speak_up.show_fs(player, "msg", {
|
|
input_to = "yl_speak_up:manage_variables",
|
|
formspec = yl_speak_up.fs_get_list_of_usage_of_variable(
|
|
fields.list_var_names, pname, true,
|
|
"back_from_msg",
|
|
"Back to manage variables",
|
|
-- not an internal variable
|
|
false)
|
|
})
|
|
return
|
|
end
|
|
|
|
-- which variable is currently selected?
|
|
local var_list = yl_speak_up.get_quest_variables(pname, true)
|
|
-- make names of own variables shorter
|
|
yl_speak_up.strip_pname_from_varlist(var_list, pname)
|
|
table.sort(var_list)
|
|
-- a var name was selected in the dropdown list
|
|
if(fields and fields.list_var_names and fields.list_var_names ~= "") then
|
|
local index = table.indexof(var_list, fields.list_var_names)
|
|
if(fields.list_var_names == "Add variable:") then
|
|
index = 0
|
|
end
|
|
if(index and index > -1) then
|
|
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 - 1]
|
|
if(not(var_name)) then
|
|
var_name = ""
|
|
end
|
|
|
|
|
|
-- show all stored values for a variable in a table
|
|
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
|
|
|
|
-- a player name was given; the value for that player shall be shown
|
|
elseif(fields and fields.show_stored_value_for_player and var_name
|
|
and fields.stored_value_for_player and fields.stored_value_for_player ~= "") then
|
|
yl_speak_up.show_fs(player, "manage_variables", fields.stored_value_for_player)
|
|
return
|
|
-- change the value for a player (possibly to nil)
|
|
elseif(fields and fields.store_new_value_for_player and var_name
|
|
and fields.stored_value_for_player and fields.stored_value_for_player ~= "") then
|
|
yl_speak_up.set_quest_variable_value(fields.stored_value_for_player, var_name,
|
|
fields.current_value_for_player)
|
|
yl_speak_up.show_fs(player, "msg", {
|
|
input_to = "yl_speak_up:manage_variables",
|
|
formspec = "size[10,2]"..
|
|
"label[0.2,0.0;Set variable \""..
|
|
minetest.colorize("#FFFF00",
|
|
minetest.formspec_escape(tostring(var_name)))..
|
|
"\"\nfor player "..
|
|
minetest.formspec_escape(fields.stored_value_for_player)..
|
|
"\nto new value "..
|
|
minetest.colorize("#FFFF00", fields.current_value_for_player)..".]"..
|
|
"button[1.5,1.5;2,0.9;back_from_msg;Back]"})
|
|
return
|
|
-- remove the value for a player (set to nil)
|
|
elseif(fields and fields.unset_value_for_player and var_name
|
|
and fields.stored_value_for_player and fields.stored_value_for_player ~= "") then
|
|
yl_speak_up.set_quest_variable_value(fields.stored_value_for_player, var_name, nil)
|
|
yl_speak_up.show_fs(player, "msg", {
|
|
input_to = "yl_speak_up:manage_variables",
|
|
formspec = "size[10,2]"..
|
|
"label[0.2,0.0;Unset variable \""..
|
|
minetest.colorize("#FFFF00",
|
|
minetest.formspec_escape(tostring(var_name)))..
|
|
"\"\nfor player "..
|
|
minetest.formspec_escape(fields.stored_value_for_player)..
|
|
".]"..
|
|
"button[1.5,1.5;2,0.9;back_from_msg;Back]"})
|
|
return
|
|
|
|
-- delete (empty) variable
|
|
elseif(fields
|
|
and ((fields.delete_variable and fields.delete_variable ~= "")
|
|
or (fields.delete_unused_variable and fields.delete_unused_variable ~= ""))
|
|
and var_name) then
|
|
local text = yl_speak_up.del_quest_variable(pname, var_name, nil)
|
|
yl_speak_up.show_fs(player, "msg", {
|
|
input_to = "yl_speak_up:manage_variables",
|
|
formspec = "size[10,2]"..
|
|
"label[0.2,0.0;Trying to delete variable \""..
|
|
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
|
|
elseif(fields
|
|
and ((fields.revoke_player_var_read_access and fields.revoke_player_var_read_access ~= "")
|
|
or (fields.revoke_player_var_write_access and fields.revoke_player_var_write_access ~= ""))
|
|
and var_name) then
|
|
local right = "read"
|
|
if(fields.revoke_player_var_write_access and fields.revoke_player_var_write_access ~= "") then
|
|
right = "write"
|
|
end
|
|
-- which player are we talking about?
|
|
local selected = yl_speak_up.speak_to[pname]["tmp_index_var_"..right.."_access"]
|
|
local pl_with_access = yl_speak_up.get_access_list_for_var(var_name, pname, right.."_access")
|
|
local tmp_list = {}
|
|
for k, v in pairs(pl_with_access) do
|
|
table.insert(tmp_list, k)
|
|
end
|
|
table.sort(tmp_list)
|
|
local grant_to = ""
|
|
if(selected > 1) then
|
|
grant_to = tmp_list[ selected-1 ]
|
|
end
|
|
local error_msg = ""
|
|
local pl_with_access = yl_speak_up.get_access_list_for_var(var_name, pname, right.."_access")
|
|
if(not(grant_to) or grant_to == "") then
|
|
error_msg = "For which player do you want to revoke "..right.." access?"
|
|
elseif(pname ~= yl_speak_up.npc_owner[ n_id ]
|
|
and not(minetest.check_player_privs(pname, {npc_talk_master=true}))) then
|
|
error_msg = "Only the owner of the NPC or players with\n"..
|
|
"the npc_talk_master priv can change this."
|
|
elseif(not(pl_with_access[ grant_to ])) then
|
|
error_msg = minetest.formspec_escape(grant_to).." doesn't have "..right..
|
|
" access\nto this variable. Nothing changed."
|
|
-- try to revoke access
|
|
elseif(not(yl_speak_up.manage_access_to_quest_variable(var_name, pname, grant_to,
|
|
right.."_access", nil))) then
|
|
error_msg = "An internal error occoured."
|
|
else
|
|
-- not really an error message here...rather a success message
|
|
error_msg = "Revoked "..right.." access to variable\n\""..
|
|
minetest.formspec_escape(var_name)..
|
|
"\"\nfor player "..minetest.formspec_escape(grant_to)..".\n"..
|
|
"Note: This will *not* affect existing preconditions/effects!"
|
|
end
|
|
yl_speak_up.show_fs(player, "msg", {
|
|
input_to = "yl_speak_up:manage_variables",
|
|
formspec = "size[6,2]"..
|
|
"label[0.2,0.0;"..error_msg.."]"..
|
|
"button[1.5,1.5;2,0.9;back_from_msg;Back]"})
|
|
return
|
|
|
|
-- grant read or write access to a variable
|
|
elseif(fields
|
|
and ((fields.grant_player_var_read_access and fields.grant_player_var_read_access ~= "")
|
|
or (fields.grant_player_var_write_access and fields.grant_player_var_write_access ~= ""))
|
|
and var_name) then
|
|
local right = "read"
|
|
if(fields.grant_player_var_write_access and fields.grant_player_var_write_access ~= "") then
|
|
right = "write"
|
|
end
|
|
local grant_to = fields[ "grant_player_var_"..right.."_access"]
|
|
local error_msg = ""
|
|
local pl_with_access = yl_speak_up.get_access_list_for_var(var_name, pname, right.."_access")
|
|
if(pname ~= yl_speak_up.npc_owner[ n_id ]
|
|
and not(minetest.check_player_privs(pname, {npc_talk_master=true}))) then
|
|
error_msg = "Only the owner of the NPC or players with\n"..
|
|
"the npc_talk_master priv can change this."
|
|
elseif(grant_to == pname) then
|
|
error_msg = "You already have "..right.." access to this variable."
|
|
elseif(pl_with_access[ grant_to ]) then
|
|
error_msg = minetest.formspec_escape(grant_to).." already has "..right..
|
|
" access\nto this variable."
|
|
elseif(not(minetest.check_player_privs(grant_to, {interact=true}))) then
|
|
error_msg = "Player \""..minetest.formspec_escape(grant_to).."\" not found."
|
|
-- try to grant access
|
|
elseif(not(yl_speak_up.manage_access_to_quest_variable(var_name, pname, grant_to,
|
|
right.."_access", true))) then
|
|
error_msg = "An internal error occoured."
|
|
else
|
|
-- not really an error message here...rather a success message
|
|
error_msg = "Granted "..right.." access to variable\n\""..
|
|
minetest.formspec_escape(var_name)..
|
|
"\"\nto player "..minetest.formspec_escape(grant_to).."."
|
|
end
|
|
yl_speak_up.show_fs(player, "msg", {
|
|
input_to = "yl_speak_up:manage_variables",
|
|
formspec = "size[6,2]"..
|
|
"label[0.2,0.0;"..error_msg.."]"..
|
|
"button[1.5,1.5;2,0.9;back_from_msg;Back]"})
|
|
return
|
|
|
|
-- the player clicked on a name in the list of players with read or write access
|
|
elseif(fields
|
|
and ((fields.list_var_read_access and fields.list_var_read_access ~= "")
|
|
or (fields.list_var_write_access and fields.list_var_write_access ~= ""))
|
|
and var_name) then
|
|
local right = "read"
|
|
if(fields.list_var_write_access and fields.list_var_write_access ~= "") then
|
|
right = "write"
|
|
end
|
|
local selected = fields[ "list_var_"..right.."_access"]
|
|
local pl_with_access = yl_speak_up.get_access_list_for_var(var_name, pname, right.."_access")
|
|
local tmp_list = {}
|
|
for k, v in pairs(pl_with_access) do
|
|
table.insert(tmp_list, k)
|
|
end
|
|
table.sort(tmp_list)
|
|
local index = table.indexof(tmp_list, selected)
|
|
if(selected == "Add player:") then
|
|
index = 0
|
|
end
|
|
if(index and index > -1) then
|
|
yl_speak_up.speak_to[pname]["tmp_index_var_"..right.."_access"] = index + 1
|
|
end
|
|
yl_speak_up.show_fs(player, "manage_variables")
|
|
return
|
|
|
|
-- a var name was selected in the dropdown list
|
|
elseif(fields and fields.list_var_names and fields.list_var_names ~= "") then
|
|
-- show the same formspec again, with a diffrent variable selected
|
|
yl_speak_up.show_fs(player, "manage_variables")
|
|
return
|
|
end
|
|
-- try to go back to the last formspec shown before this one
|
|
if(not(yl_speak_up.speak_to[pname])) then
|
|
return
|
|
end
|
|
local last_fs = yl_speak_up.speak_to[pname][ "working_at" ]
|
|
yl_speak_up.show_fs(player, last_fs)
|
|
end
|
|
|
|
|
|
yl_speak_up.get_fs_manage_variables = function(player, param)
|
|
local pname = player:get_player_name()
|
|
-- variables owned by the player - including those with write access
|
|
local var_list = yl_speak_up.get_quest_variables(pname, true)
|
|
-- make names of own variables shorter
|
|
yl_speak_up.strip_pname_from_varlist(var_list, pname)
|
|
-- the yl_speak_up.create_dropdown_playerlist function needs a table - not a list
|
|
local table_of_vars = {}
|
|
for i, k in ipairs(var_list) do
|
|
table_of_vars[ k ] = true
|
|
end
|
|
-- "Add variable:" is currently selected
|
|
local additional_buttons = ""
|
|
if(not(yl_speak_up.speak_to[pname].tmp_index_variable)
|
|
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
|
|
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]"..
|
|
"tooltip[add_variable;Create a new varialbe with the name\n"..
|
|
"you entered in the field to the left.]"
|
|
|
|
else
|
|
-- 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 = ""
|
|
local add_write_button = ""
|
|
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
|
|
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]"..
|
|
"tooltip[add_read_access;Grant the player whose name you entered\n"..
|
|
"you entered in the field to the left read access\n"..
|
|
"to your variable.]"
|
|
end
|
|
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
|
|
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]"..
|
|
"tooltip[add_write_access;Grant the player whose name you entered\n"..
|
|
"you entered in the field to the left *write* access\n"..
|
|
"to your variable.]"
|
|
end
|
|
local list_of_npc_users = "- none -"
|
|
local list_of_node_pos_users = "- none -"
|
|
-- 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
|
|
local npc_users = yl_speak_up.get_variable_metadata(k_long, "used_by_npc")
|
|
c1 = #npc_users
|
|
if(npc_users and c1 > 0) then
|
|
list_of_npc_users = minetest.formspec_escape(table.concat(npc_users, ", "))
|
|
end
|
|
local node_pos_users = yl_speak_up.get_variable_metadata(k_long, "used_by_node_pos")
|
|
c2 = #node_pos_users
|
|
if(node_pos_users and c2 > 0) then
|
|
list_of_node_pos_users = minetest.formspec_escape(table.concat(
|
|
node_pos_users, ", "))
|
|
end
|
|
end
|
|
local debug_button = "button[10.0,10.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,10.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,10.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
|
|
-- checking/changing debug value for one specific player
|
|
if(not(param)) then
|
|
param = ""
|
|
end
|
|
debug_button = debug_button..
|
|
"label[0.2,8.05;Show stored value for player:]"..
|
|
"field[4.2,8.15;4.0,0.9;stored_value_for_player;;"..
|
|
minetest.formspec_escape(param).."]"..
|
|
"button[8.2,7.85;4.0,0.9;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"..
|
|
"want to check (or change) the stored value.]"..
|
|
"tooltip[show_stored_value_for_player;Click here to read and the current value"..
|
|
"\nstored for this player.]"
|
|
if(param and param ~= "") then
|
|
local v = yl_speak_up.get_quest_variable_value(param, k_long) or ""
|
|
debug_button = debug_button..
|
|
"label[0.2,9.05;Found stored value:]"..
|
|
"field[4.2,9.15;4.0,0.9;current_value_for_player;;"..
|
|
minetest.formspec_escape(v).."]"..
|
|
"tooltip[current_value_for_player;You can see and change the current "..
|
|
"value here.]"..
|
|
"button[8.2,8.85;4.0,0.9;store_new_value_for_player;"..
|
|
"Store this as new value]"..
|
|
"tooltip[store_new_value_for_player;"..
|
|
"Click here to update the stored value for this player."..
|
|
"\nWARNING: Be very careful here and never do this without"..
|
|
"\n informing the player about this change!]"..
|
|
"button[12.5,8.85;3.0,0.9;unset_value_for_player;"..
|
|
"Remove this entry]"..
|
|
"tooltip[unset_value_for_player;Click here to delete the entry for this "..
|
|
"player.\nSetting the entry to an empty string would not be "..
|
|
"the same!]"
|
|
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
|
|
"label[0.2,3.05;Players with read access to this variable:]"..
|
|
yl_speak_up.create_dropdown_playerlist(player, pname,
|
|
pl_with_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",
|
|
"grant_player_var_read_access",
|
|
"Enter the name of the player that shall\n"..
|
|
"have read access to this variable.",
|
|
"revoke_player_var_read_access",
|
|
"If you click here, the selected player\n"..
|
|
"will no longer be able to add new\n"..
|
|
"pre(C)onditions which read your variable."
|
|
)..add_read_button..
|
|
"label[0.2,4.05;Players with *write* access to this variable:]"..
|
|
yl_speak_up.create_dropdown_playerlist(player, pname,
|
|
pl_with_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",
|
|
"grant_player_var_write_access",
|
|
"Enter the name of the player that shall\n"..
|
|
"have *write* access to this variable.",
|
|
"revoke_player_var_write_access",
|
|
"If you click here, the selected player\n"..
|
|
"will no longer be able to *write* new\n"..
|
|
"values into this variable."
|
|
)..add_write_button..
|
|
"label[0.2,5.05;Type of variable: "..
|
|
-- show variable type
|
|
minetest.colorize("#FFFF00",
|
|
(yl_speak_up.get_variable_metadata(k_long, "var_type")
|
|
or "String/text or numerical value, depending 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)..".]"..
|
|
"button[0.2,10.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.]"..
|
|
debug_button
|
|
end
|
|
return "size[16,11.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"..
|
|
"You can grant read and write access to other players for your "..
|
|
"variables so that they can also use them as well.]"..
|
|
"label[0.2,2.05;Your variables:]"..
|
|
-- offer a dropdown list and a text input field for new varialbe names for adding
|
|
yl_speak_up.create_dropdown_playerlist(player, pname,
|
|
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",
|
|
"add_variable_name",
|
|
"Enter the name of the new variable you\n"..
|
|
"want to create.",
|
|
"delete_variable",
|
|
"If you click here, the selected variable\n"..
|
|
"will be deleted."
|
|
)..
|
|
additional_buttons..
|
|
"button[0.0,0.2;1.0,0.6;back;Back]"..
|
|
"button[6.5,11.0;1.0,0.6;back;Back]"
|
|
end
|