Bugfixes after test with Skylar!
This commit is contained in:
parent
956f9a2635
commit
9a2c72c6a1
2
mod.conf
2
mod.conf
@ -1,7 +1,7 @@
|
|||||||
name = modpol
|
name = modpol
|
||||||
title = Modpol
|
title = Modpol
|
||||||
author = ntnsndr <n@nathanschneider.info>
|
author = ntnsndr <n@nathanschneider.info>
|
||||||
description = Framework that enables diverse governance processes
|
description = A framework that enables diverse governance processes
|
||||||
license = MIT
|
license = MIT
|
||||||
forum = https://forum.minetest.net/viewtopic.php?f=9&t=27598
|
forum = https://forum.minetest.net/viewtopic.php?f=9&t=27598
|
||||||
version = 0.1
|
version = 0.1
|
||||||
|
@ -5,6 +5,7 @@ local localdir = modpol.topdir
|
|||||||
--orgs
|
--orgs
|
||||||
dofile (localdir .. "/orgs/base.lua")
|
dofile (localdir .. "/orgs/base.lua")
|
||||||
dofile (localdir .. "/orgs/process.lua")
|
dofile (localdir .. "/orgs/process.lua")
|
||||||
|
dofile (localdir .. "/orgs/users.lua")
|
||||||
|
|
||||||
--interactions
|
--interactions
|
||||||
dofile (localdir .. "/interactions/interactions.lua")
|
dofile (localdir .. "/interactions/interactions.lua")
|
||||||
|
@ -37,8 +37,10 @@ function modpol.interactions.dashboard(user)
|
|||||||
local user_pending_count = 0
|
local user_pending_count = 0
|
||||||
for k,v in ipairs(modpol.orgs.array) do
|
for k,v in ipairs(modpol.orgs.array) do
|
||||||
if v.pending and v.pending[user] then
|
if v.pending and v.pending[user] then
|
||||||
table.insert(user_pending, v.name)
|
if modpol.util.num_pairs(v.pending[user]) ~= 0 then
|
||||||
user_pending_count = user_pending_count + 1
|
table.insert(user_pending, v.name)
|
||||||
|
user_pending_count = user_pending_count + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -108,7 +110,7 @@ function modpol.interactions.org_dashboard(user, org_string)
|
|||||||
print("Org: " .. org.name)
|
print("Org: " .. org.name)
|
||||||
print("Parent: " .. parent)
|
print("Parent: " .. parent)
|
||||||
print("Members: " .. table.concat(org.members, ", "))
|
print("Members: " .. table.concat(org.members, ", "))
|
||||||
print("Children: " .. table.concat(children, ", "))
|
print("Child orgs: " .. table.concat(children, ", "))
|
||||||
print("Modules: " .. table.concat(modules, ", "))
|
print("Modules: " .. table.concat(modules, ", "))
|
||||||
print("Pending: " .. process_msg)
|
print("Pending: " .. process_msg)
|
||||||
print()
|
print()
|
||||||
|
@ -66,7 +66,8 @@ function add_child_org_consent:create_child_org()
|
|||||||
modpol.interactions.message_org(
|
modpol.interactions.message_org(
|
||||||
self.initiator,
|
self.initiator,
|
||||||
self.org.name,
|
self.org.name,
|
||||||
"Child org created: "..self.data.child_name)
|
"Consent reached: created child org "
|
||||||
|
..self.data.child_name)
|
||||||
if self.data.result then self.data.result() end
|
if self.data.result then self.data.result() end
|
||||||
self.org:delete_process(self.id)
|
self.org:delete_process(self.id)
|
||||||
end
|
end
|
||||||
|
@ -83,7 +83,7 @@ function change_modules:remove_module()
|
|||||||
local available_modules = {}
|
local available_modules = {}
|
||||||
for k,org_mod in pairs(self.org.modules) do
|
for k,org_mod in pairs(self.org.modules) do
|
||||||
if not org_mod.hide then
|
if not org_mod.hide then
|
||||||
available_modules[org_mod.slug] = modpol.copy_table(org_mod)
|
available_modules[org_mod.slug] = modpol.util.copy_table(org_mod)
|
||||||
end end
|
end end
|
||||||
local modules_list = {}
|
local modules_list = {}
|
||||||
local modules_count = 0
|
local modules_count = 0
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
-- A utility module for checking consent
|
-- A utility module for checking consent
|
||||||
|
|
||||||
local consent = {
|
local consent = {
|
||||||
name = "Consent process utility",
|
name = "Consent process",
|
||||||
slug = "consent",
|
slug = "consent",
|
||||||
desc = "A module other modules use for consent decisions",
|
desc = "A utility module other modules use for consent decisions",
|
||||||
hide = true
|
hide = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,8 @@ end
|
|||||||
-- ===========================================
|
-- ===========================================
|
||||||
-- deletes all orgs except for the instance
|
-- deletes all orgs except for the instance
|
||||||
function modpol.orgs.reset()
|
function modpol.orgs.reset()
|
||||||
|
local instance_members =
|
||||||
|
modpol.util.copy_table(modpol.instance.members)
|
||||||
for id, org in ipairs(modpol.orgs.array) do
|
for id, org in ipairs(modpol.orgs.array) do
|
||||||
if id > 1 then
|
if id > 1 then
|
||||||
modpol.orgs.array[id] = "removed"
|
modpol.orgs.array[id] = "removed"
|
||||||
@ -80,9 +82,9 @@ function modpol.orgs.reset()
|
|||||||
|
|
||||||
modpol.orgs.array[1] = nil
|
modpol.orgs.array[1] = nil
|
||||||
modpol.instance = modpol.orgs.init_instance()
|
modpol.instance = modpol.orgs.init_instance()
|
||||||
|
modpol.instance.members = instance_members
|
||||||
|
|
||||||
modpol.ocutil.log('Reset all orgs')
|
modpol.ocutil.log('All orgs reset')
|
||||||
modpol.orgs:record('Resetting all orgs', 'org_reset')
|
modpol.orgs:record('Resetting all orgs', 'org_reset')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
27
modpol_core/orgs/users.lua
Normal file
27
modpol_core/orgs/users.lua
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
-- /users.lua
|
||||||
|
-- User-related functions for Modular Politics
|
||||||
|
|
||||||
|
-- ===================================================================
|
||||||
|
-- Function: modpol.list_users
|
||||||
|
-- Params: org
|
||||||
|
-- Outputs: Table of user names
|
||||||
|
--
|
||||||
|
-- This may be overwritten by the platform-specific interface
|
||||||
|
|
||||||
|
modpol.list_users = function(org)
|
||||||
|
local users = {}
|
||||||
|
if (org == nil) then -- no specified org; all players
|
||||||
|
if modpol.orgs["instance"]
|
||||||
|
and modpol.orgs["instance"]["members"] then
|
||||||
|
-- if instance exists and has membership
|
||||||
|
users = modpol.orgs["instance"]["members"]
|
||||||
|
else
|
||||||
|
users = {}
|
||||||
|
end
|
||||||
|
else -- if an org is specified
|
||||||
|
if (modpol.orgs[org] ~= nil) then -- org exists
|
||||||
|
users = modpol.orgs[org]["members"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return users
|
||||||
|
end
|
@ -10,7 +10,8 @@ function modpol.util.copy_table(t)
|
|||||||
return t2
|
return t2
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @function modpol.copy_table
|
--- @function modpol.num_pairs
|
||||||
|
-- @param t table with pairs
|
||||||
-- Returns the number of elements in a pairs table
|
-- Returns the number of elements in a pairs table
|
||||||
function modpol.util.num_pairs(t)
|
function modpol.util.num_pairs(t)
|
||||||
local i = 0
|
local i = 0
|
||||||
|
@ -9,6 +9,7 @@ local localdir = minetest.get_modpath("modpol") .. "/modpol_minetest"
|
|||||||
|
|
||||||
--overrides
|
--overrides
|
||||||
dofile (localdir .. "/overrides/interactions.lua")
|
dofile (localdir .. "/overrides/interactions.lua")
|
||||||
|
dofile (localdir .. "/overrides/users.lua")
|
||||||
|
|
||||||
--testing command for "singleplayer"
|
--testing command for "singleplayer"
|
||||||
function modpol.msg(text)
|
function modpol.msg(text)
|
||||||
|
@ -35,7 +35,6 @@ regchat(
|
|||||||
privs = {privs=true},
|
privs = {privs=true},
|
||||||
func = function(user)
|
func = function(user)
|
||||||
modpol.orgs.reset()
|
modpol.orgs.reset()
|
||||||
modpol.instance:add_member(user)
|
|
||||||
modpol.interactions.dashboard(user)
|
modpol.interactions.dashboard(user)
|
||||||
return true, "Reset orgs"
|
return true, "Reset orgs"
|
||||||
end,
|
end,
|
||||||
|
@ -53,9 +53,10 @@ function modpol.interactions.dashboard(user)
|
|||||||
local user_pending_count = 0
|
local user_pending_count = 0
|
||||||
for k,v in ipairs(modpol.orgs.array) do
|
for k,v in ipairs(modpol.orgs.array) do
|
||||||
if v.pending and v.pending[user] then
|
if v.pending and v.pending[user] then
|
||||||
modpol.msg(v.name)
|
if modpol.util.num_pairs(v.pending[user]) ~= 0 then
|
||||||
table.insert(user_pending, v.name)
|
table.insert(user_pending, v.name)
|
||||||
user_pending_count = user_pending_count + 1
|
user_pending_count = user_pending_count + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -169,7 +170,7 @@ function modpol.interactions.org_dashboard(user, org_string)
|
|||||||
"label[0.5,1;Parent: "..parent..membership_toggle(parent).."]",
|
"label[0.5,1;Parent: "..parent..membership_toggle(parent).."]",
|
||||||
"label[0.5,2;Members:]",
|
"label[0.5,2;Members:]",
|
||||||
"dropdown[2,1.5;7,0.8;user_orgs;"..formspec_list(org.members)..";;]",
|
"dropdown[2,1.5;7,0.8;user_orgs;"..formspec_list(org.members)..";;]",
|
||||||
"label[0.5,3;Children:]",
|
"label[0.5,3;Child orgs:]",
|
||||||
"dropdown[2,2.5;7,0.8;children;"..formspec_list(children)..";;]",
|
"dropdown[2,2.5;7,0.8;children;"..formspec_list(children)..";;]",
|
||||||
"label[0.5,4;Modules:]",
|
"label[0.5,4;Modules:]",
|
||||||
"dropdown[2,3.5;7,0.8;modules;"..formspec_list(modules)..";;]",
|
"dropdown[2,3.5;7,0.8;modules;"..formspec_list(modules)..";;]",
|
||||||
|
20
modpol_minetest/overrides/users.lua
Normal file
20
modpol_minetest/overrides/users.lua
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Function: modpol.list_users(org)
|
||||||
|
-- Overwrites function at /users.lua
|
||||||
|
-- Params:
|
||||||
|
-- if nil, lists instance members; if an org name, lists its members
|
||||||
|
-- Output: a table with names of players currently in the game
|
||||||
|
modpol.list_users = function(org)
|
||||||
|
local users = {}
|
||||||
|
if (org == nil) then -- no specified org; all players
|
||||||
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
|
local name = player:get_player_name()
|
||||||
|
table.insert(users,name)
|
||||||
|
end
|
||||||
|
else -- if an org is specified
|
||||||
|
if (modpol.orgs[org] ~= nil) then -- org exists
|
||||||
|
users = modpol.orgs[org]["members"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return users
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user