Not yet successful attempt to convert add_child in Minetest interactions to a request
This commit is contained in:
parent
1be8e8b23d
commit
ebc2f4758e
@ -57,7 +57,7 @@ function modpol.interactions.dashboard(user)
|
|||||||
local formspec = {
|
local formspec = {
|
||||||
"formspec_version[4]",
|
"formspec_version[4]",
|
||||||
"size[10,8]",
|
"size[10,8]",
|
||||||
"label[0.5,0.5;M O D U L A R P O L I T I C S]",
|
"label[0.5,0.5;MODPOL DASHBOARD]",
|
||||||
"label[0.5,2;All orgs:]",
|
"label[0.5,2;All orgs:]",
|
||||||
"dropdown[2,1.5;5,0.8;all_orgs;"..formspec_list(all_orgs)..";;]",
|
"dropdown[2,1.5;5,0.8;all_orgs;"..formspec_list(all_orgs)..";;]",
|
||||||
"label[0.5,3;Your orgs:]",
|
"label[0.5,3;Your orgs:]",
|
||||||
@ -117,11 +117,29 @@ function modpol.interactions.org_dashboard(user, org_name)
|
|||||||
end
|
end
|
||||||
return toggle_code
|
return toggle_code
|
||||||
end
|
end
|
||||||
|
-- prepare children menu
|
||||||
local children = {}
|
local children = {}
|
||||||
for k,v in ipairs(org.children) do
|
for k,v in ipairs(org.children) do
|
||||||
local this_child = modpol.orgs.get_org(v)
|
local this_child = modpol.orgs.get_org(v)
|
||||||
table.insert(children, this_child.name)
|
table.insert(children, this_child.name)
|
||||||
end
|
end
|
||||||
|
-- prepare policies menu
|
||||||
|
-- prepare processes menu
|
||||||
|
local processes = {}
|
||||||
|
for k,v in ipairs(org.processes) do
|
||||||
|
print(k, v)
|
||||||
|
local this_request = org.requests[v.request_id]
|
||||||
|
if type(this_request) == "table" then
|
||||||
|
local active = ''
|
||||||
|
if org.pending[user] then
|
||||||
|
if org.pending[user][v.id] then
|
||||||
|
active = '*'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local req_str = v.id .. " (" .. this_request.type .. " -> " .. table.concat(this_request.params, ", ") .. ")" .. active
|
||||||
|
table.insert(processes, req_str)
|
||||||
|
end
|
||||||
|
end
|
||||||
-- set player context
|
-- set player context
|
||||||
local user_context = {}
|
local user_context = {}
|
||||||
user_context["current_org"] = org_name
|
user_context["current_org"] = org_name
|
||||||
@ -141,7 +159,7 @@ function modpol.interactions.org_dashboard(user, org_name)
|
|||||||
"label[0.5,4;Policies:]",
|
"label[0.5,4;Policies:]",
|
||||||
"dropdown[2,3.5;5,0.8;policies;"..formspec_list(org.policies)..";;]",
|
"dropdown[2,3.5;5,0.8;policies;"..formspec_list(org.policies)..";;]",
|
||||||
"label[0.5,5;Processes:]",
|
"label[0.5,5;Processes:]",
|
||||||
"dropdown[2,4.5;5,0.8;processes;"..formspec_list(org.processes)..";;]",
|
"dropdown[2,4.5;5,0.8;processes;"..formspec_list(processes)..";;]",
|
||||||
"button[0.5,7;1,0.8;test_poll;Test poll]",
|
"button[0.5,7;1,0.8;test_poll;Test poll]",
|
||||||
"button[2,7;1,0.8;add_child;Add child]",
|
"button[2,7;1,0.8;add_child;Add child]",
|
||||||
"button[3.5,7;1.5,0.8;remove_org;Remove org]",
|
"button[3.5,7;1.5,0.8;remove_org;Remove org]",
|
||||||
@ -172,7 +190,17 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
|
|||||||
elseif fields.test_poll then
|
elseif fields.test_poll then
|
||||||
modpol.interactions.binary_poll_org(pname, _contexts.pname.current_org.id, "Poll question (yes/no):")
|
modpol.interactions.binary_poll_org(pname, _contexts.pname.current_org.id, "Poll question (yes/no):")
|
||||||
elseif fields.add_child then
|
elseif fields.add_child then
|
||||||
modpol.interactions.add_org(pname, org.id)
|
--DEPRICATED pre-request version to remove:
|
||||||
|
--modpol.interactions.add_org(pname, org.id)
|
||||||
|
modpol.interactions.text_query(pname, "Org name:")
|
||||||
|
local new_org_name = _contexts[pname]
|
||||||
|
local new_request = {
|
||||||
|
user = player,
|
||||||
|
type = "add_org",
|
||||||
|
params = {new_org_name}
|
||||||
|
}
|
||||||
|
org:make_request(new_request)
|
||||||
|
_contexts[pname] = nil
|
||||||
elseif fields.remove_org then
|
elseif fields.remove_org then
|
||||||
modpol.interactions.remove_org(pname)
|
modpol.interactions.remove_org(pname)
|
||||||
elseif fields.back then
|
elseif fields.back then
|
||||||
@ -182,7 +210,6 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- BASIC INTERACTION FUNCTIONS
|
-- BASIC INTERACTION FUNCTIONS
|
||||||
-- ===========================
|
-- ===========================
|
||||||
|
|
||||||
@ -196,7 +223,7 @@ end
|
|||||||
-- Function: modpol.interactions.text_query
|
-- Function: modpol.interactions.text_query
|
||||||
-- Overrides function at modpol/interactions.lua
|
-- Overrides function at modpol/interactions.lua
|
||||||
-- input: Query (string), User (string)
|
-- input: Query (string), User (string)
|
||||||
-- output: User response (string)
|
-- output: Saves user response (string) to _contexts[pname]
|
||||||
-- TODO Need to switch "user" to index not name
|
-- TODO Need to switch "user" to index not name
|
||||||
function modpol.interactions.text_query(user, query)
|
function modpol.interactions.text_query(user, query)
|
||||||
-- set up formspec
|
-- set up formspec
|
||||||
@ -314,6 +341,7 @@ function modpol.interactions.binary_poll_org(initiator, org)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Function: modpol.interactions.add_org
|
-- Function: modpol.interactions.add_org
|
||||||
|
-- TESTING PURPOSES. SHOULD BE DEPRICATED
|
||||||
-- input: initator (user string), base_org_id (ID)
|
-- input: initator (user string), base_org_id (ID)
|
||||||
-- output: interaction begins
|
-- output: interaction begins
|
||||||
function modpol.interactions.add_org(initiator, base_org_id)
|
function modpol.interactions.add_org(initiator, base_org_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user