forked from Sokomine/yl_speak_up
allow to scroll through the variables in manage_variables with prev/next
This commit is contained in:
parent
c70f61bc38
commit
80657b59ee
@ -1028,6 +1028,9 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
|
||||
if(fields.manage_variables) then
|
||||
-- remember which formspec we are comming from
|
||||
yl_speak_up.speak_to[pname][ "working_at" ] = formspec_input_to
|
||||
if(data.variable) then
|
||||
yl_speak_up.speak_to[pname].tmp_index_variable = data.variable - 1
|
||||
end
|
||||
yl_speak_up.show_fs(player, "manage_variables")
|
||||
return
|
||||
end
|
||||
|
@ -8,6 +8,7 @@ yl_speak_up.input_fs_manage_variables = function(player, formname, fields)
|
||||
-- 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.speak_to[pname].tmp_index_variable = nil
|
||||
yl_speak_up.show_fs(player, last_fs)
|
||||
return
|
||||
-- add a new variable?
|
||||
@ -63,6 +64,21 @@ yl_speak_up.input_fs_manage_variables = function(player, formname, fields)
|
||||
false)
|
||||
})
|
||||
return
|
||||
-- scroll through the variables with prev/next buttons
|
||||
elseif(fields and (fields["prev"] or fields["next"])) then
|
||||
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)
|
||||
local index = yl_speak_up.speak_to[pname].tmp_index_variable
|
||||
if(not(index)) then
|
||||
yl_speak_up.speak_to[pname].tmp_index_variable = 1
|
||||
elseif(fields["prev"] and index > 1) then
|
||||
yl_speak_up.speak_to[pname].tmp_index_variable = index - 1
|
||||
elseif(fields["next"] and index <= #var_list) then
|
||||
yl_speak_up.speak_to[pname].tmp_index_variable = index + 1
|
||||
end
|
||||
yl_speak_up.show_fs(player, "manage_variables", fields.stored_value_for_player)
|
||||
return
|
||||
end
|
||||
|
||||
-- which variable is currently selected?
|
||||
@ -482,6 +498,16 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
|
||||
"player.\nShow these values in a table.]"..
|
||||
debug_button
|
||||
end
|
||||
if(yl_speak_up.speak_to[pname].tmp_index_variable > 1) then
|
||||
additional_buttons = additional_buttons..
|
||||
"button[4.0,0.2;2.0,0.6;prev;< Prev]"..
|
||||
"button[4.0,11.0;2.0,0.6;prev;< Prev]"
|
||||
end
|
||||
if(yl_speak_up.speak_to[pname].tmp_index_variable <= #var_list) then
|
||||
additional_buttons = additional_buttons..
|
||||
"button[12.0,0.2;2.0,0.6;next;Next >]"..
|
||||
"button[12.0,11.0;2.0,0.6;next;Next >]"
|
||||
end
|
||||
return "size[18,12]"..
|
||||
"label[7.0,0.4;* Manage your variables *]"..
|
||||
"label[0.2,1.2;Note: Each variable will store a diffrent value for each player who "..
|
||||
|
Loading…
Reference in New Issue
Block a user