Fixed bug preventing second formspecs from showing in sequences of interactions

This commit is contained in:
Nathan Schneider 2021-08-03 22:14:01 -06:00
parent 4016aa77cc
commit 97d540715a
2 changed files with 5 additions and 7 deletions

View File

@ -27,7 +27,5 @@ request_id = test_org:make_request(add_josh)
print('\nHave the two members vote on it')
modpol.interactions.org_dashboard("nathan","test_org")
modpol.interactions.org_dashboard("nathan","test_org")
modpol.interactions.org_dashboard("luke","test_org")
-- check a member's dashboard for the process, try to initialize it

View File

@ -3,7 +3,7 @@
-- CONTEXTUAL STUFF
-- ================
-- First, set up contexts to enable passing across formspecs
-- _contexts to enable passing across formspecs
-- https://rubenwardy.com/minetest_modding_book/en/players/formspecs.html#contexts
local _contexts = {}
@ -252,7 +252,6 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
if formname == "modpol:text_query" then
local pname = player:get_player_name()
local input = fields.input
minetest.close_formspec(pname, formname)
if not input then
-- no input, do nothing
else
@ -263,6 +262,7 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
modpol.interactions.message(pname, "text_query: " .. input)
end
end
minetest.close_formspec(pname, formname)
end
end)
@ -291,7 +291,6 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
if formname == "modpol:dropdown_query" then
local pname = player:get_player_name()
local choice = fields.input
minetest.close_formspec(pname, formname)
local func = _contexts[pname]["dropdown_query_func"]
if not choice then
-- no choice, do nothing
@ -300,6 +299,7 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
else
modpol.interactions.message(pname, "dropdown_query: " .. choice)
end
minetest.close_formspec(pname, formname)
end
end)
@ -339,12 +339,12 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
if fields.yes then vote = fields.yes
elseif fields.no then vote = fields.no
end
minetest.close_formspec(pname, formname)
if vote then
modpol.interactions.message(pname, "Voted " .. vote)
local func = _contexts[pname]["binary_poll_func"]
func(vote)
end
minetest.close_formspec(pname, formname)
end
end)