Added list_processes and began adding process logic to Join button in interactions

This commit is contained in:
Nathan Schneider 2021-05-10 23:24:52 -06:00
parent 592226fe5a
commit 48b5b3070b
2 changed files with 24 additions and 2 deletions

View File

@ -13,6 +13,21 @@
modpol.processes = {}
-- Function: modpol.list_processes
-- output: a table of the names of processes
function modpol.list_processes()
local output = {}
if modpol.processes then
for k,v in ipairs(modpol.processes) do
if v.name then
table.insert(output,v.name)
end
end
end
return output
end
-- ===================================================================
-- Function: modpol.register_process
-- Adds a process to modpol.processes

View File

@ -53,6 +53,7 @@ function modpol.interactions.dashboard(user)
local all_orgs = modpol.orgs.list_all()
local user_orgs = modpol.orgs.user_orgs(user)
local all_users = modpol.list_users()
local all_processes = modpol.list_processes()
-- set up formspec
local formspec = {
"formspec_version[4]",
@ -65,7 +66,7 @@ function modpol.interactions.dashboard(user)
"label[0.5,4;All users:]",
"dropdown[2,3.5;5,0.8;all_users;"..formspec_list(all_users)..";;]",
"label[0.5,5;Processes:]",
"dropdown[2,4.5;5,0.8;processes;TBA;;]",
"dropdown[2,4.5;5,0.8;processes;"..formspec_list(all_processess)..";;]",
"button[0.5,7;1,0.8;test_poll;Test poll]",
"button[2,7;1,0.8;add_org;Add org]",
"button[3.5,7;1.5,0.8;remove_org;Remove org]",
@ -160,7 +161,13 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
local org = modpol.orgs.get_org(_contexts[pname].current_org)
if nil then
elseif fields.join then
org:add_member(pname)
local new_request = {
user = player,
type = "add_member",
params = {player}
}
org:make_request(new_request)
--org:add_member(pname)
modpol.interactions.org_dashboard(pname,org.name)
elseif fields.leave then
org:remove_member(pname)