A bunch of module bugfixes
This commit is contained in:
@ -223,8 +223,16 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
|
||||
elseif fields.modules
|
||||
and fields.modules ~= "View..." then
|
||||
local module = fields.modules
|
||||
org:call_module(module, pname)
|
||||
modpol.interactions.org_dashboard(pname,org.name)
|
||||
modpol.interactions.binary_poll_user(
|
||||
pname,
|
||||
modpol.modules[module].name.."\n"..
|
||||
modpol.modules[module].desc.."\n"..
|
||||
"Proceed?",
|
||||
function(input)
|
||||
if input == "Yes" then
|
||||
org:call_module(module, pname)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Receiving actions
|
||||
elseif fields.actions
|
||||
@ -258,14 +266,16 @@ function modpol.interactions.policy_dashboard(
|
||||
end
|
||||
|
||||
|
||||
-- BASIC INTERACTION FUNCTIONS
|
||||
-- ===========================
|
||||
-- INTERACTION FUNCTIONS
|
||||
-- =====================
|
||||
|
||||
-- Function: modpol.interactions.message
|
||||
-- input: user (string), message (string)
|
||||
-- output: displays message to specified user
|
||||
function modpol.interactions.message(user, message)
|
||||
minetest.chat_send_player(user, message)
|
||||
if message then
|
||||
minetest.chat_send_player(user, message)
|
||||
end
|
||||
end
|
||||
|
||||
-- Function: modpol.interactions.text_query
|
||||
@ -331,11 +341,13 @@ end
|
||||
minetest.register_on_player_receive_fields(function (player, formname, fields)
|
||||
if formname == "modpol:dropdown_query" then
|
||||
local pname = player:get_player_name()
|
||||
if fields.cancel ~= "cancel" then
|
||||
if fields.cancel == "cancel" then
|
||||
-- cancel, do nothing
|
||||
else
|
||||
local choice = fields.input
|
||||
local func = _contexts[pname]["dropdown_query_func"]
|
||||
if not choice then
|
||||
-- no choice, do nothing
|
||||
-- empty, do nothing
|
||||
elseif func then
|
||||
func(choice)
|
||||
else
|
||||
@ -355,10 +367,10 @@ function modpol.interactions.binary_poll_user(user, question, func)
|
||||
-- set up formspec
|
||||
local formspec = {
|
||||
"formspec_version[4]",
|
||||
"size[5,3]",
|
||||
"size[8,4]",
|
||||
"label[0.375,0.5;",minetest.formspec_escape(question), "]",
|
||||
"button[1,1.5;1,0.8;yes;Yes]",
|
||||
"button[2,1.5;1,0.8;no;No]",
|
||||
"button[1,2.5;1,0.8;yes;Yes]",
|
||||
"button[2,2.5;1,0.8;no;No]",
|
||||
--TODO can we enable text wrapping?
|
||||
--TODO we could use scroll boxes to contain the text
|
||||
}
|
||||
@ -377,7 +389,6 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
|
||||
elseif fields.no then vote = fields.no
|
||||
end
|
||||
if vote then
|
||||
modpol.interactions.message(pname, "Responded " .. vote)
|
||||
local func = _contexts[pname]["binary_poll_func"]
|
||||
if func then func(vote) end
|
||||
end
|
||||
|
Reference in New Issue
Block a user