diff --git a/README.md b/README.md index ca858a4..353cfb4 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Modular Politics can also be used independently of Minetest as a command-line to The command-line version is in the `modpol` subdirectory. To interact with the interpreter on Unix systems in CLI mode, install lua or luajit and execute the following in this directory: ``` -$ cd modpol/interacctions/ +$ cd modpol/interactions/ $ lua [or luajit] > dofile("login.lua") ``` diff --git a/modpol/api.lua b/modpol/api.lua index 70e4eb2..8c2bc48 100644 --- a/modpol/api.lua +++ b/modpol/api.lua @@ -13,7 +13,7 @@ dofile (localdir .. "/orgs/process.lua") dofile (localdir .. "/interactions/interactions.lua") --modules -dofile (localdir .. "/modules/join_org.lua") dofile (localdir .. "/modules/consent.lua") ---dofile (localdir .. "/modules/remove_org.lua") +dofile (localdir .. "/modules/join_org_consent.lua") +dofile (localdir .. "/modules/remove_org_consent.lua") --dofile (localdir .. "/modules/child_org.lua") diff --git a/modpol/modpol.lua b/modpol/modpol.lua index e1f62cb..9e779d3 100644 --- a/modpol/modpol.lua +++ b/modpol/modpol.lua @@ -97,7 +97,6 @@ end -- create instance if not present modpol.instance = modpol.orgs.array[1] or modpol.orgs.init_instance() - modpol.ocutil.log ("modpol loaded") -- =================================================================== diff --git a/modpol/modules/consent.lua b/modpol/modules/consent.lua index 27b1cd8..e7d22b3 100644 --- a/modpol/modules/consent.lua +++ b/modpol/modules/consent.lua @@ -39,4 +39,4 @@ function Consent:callback(member) end -modpol.modules.consent = Consent \ No newline at end of file +modpol.modules.consent = Consent diff --git a/modpol/modules/join_org.lua b/modpol/modules/join_org.lua index 3353dae..3806685 100644 --- a/modpol/modules/join_org.lua +++ b/modpol/modules/join_org.lua @@ -1,6 +1,12 @@ join_org = {} +join_org.setup = { + name = "Join Org", + slug = "join_org", + desc = "If consent process is passed, initiator joins this org." +} + function join_org.initiate(initiator, org, result) modpol.interactions.binary_poll_user( initiator, diff --git a/modpol/modules/join_org_class.lua b/modpol/modules/join_org_class.lua deleted file mode 100644 index 9160425..0000000 --- a/modpol/modules/join_org_class.lua +++ /dev/null @@ -1,58 +0,0 @@ --- JOIN ORG --- Module that enables a user to join an org - -JoinOrg = {} - -JoinOrg.setup = { - name = "Join an org", - desc = "Initiator chooses an org to become a member of. Nothing happens if they are already in an org.", - votes_yes = 0 -} - -function JoinOrg:initiate(result) - modpol.interactions.binary_poll_user( - self.initiator, - "Would you like to join", - function (resp) - if resp == "Yes" then - for id, member in pairs(self.org.members) do - self.org:add_pending_action(self.id, member, "callback") - - end - end - end - ) - - if result then result() end - -end - -function JoinOrg:callback(member) - modpol.interactions.binary_poll_user( - member, - "Do you want " .. self.initiator .. " to join?", - function (resp) - if resp == "Yes" then - self.votes_yes = self.votes_yes + 1 - end - - self:evaluate_vote() - - end - ) -end - - - -function JoinOrg:evaluate_vote() - if self.votes_yes >= 1 then - print('added user') - self.org:add_member(self.initiator) - self.org:wipe_pending_actions(self.id) - end -end - --- =================================== --- When calling a module internally - -modpol.modules.join_org_class = JoinOrg \ No newline at end of file diff --git a/modpol/modules/join_org_consent.lua b/modpol/modules/join_org_consent.lua index cc02d4e..d126fd5 100644 --- a/modpol/modules/join_org_consent.lua +++ b/modpol/modules/join_org_consent.lua @@ -1,20 +1,22 @@ +--- Join org (consent) +-- A simple module that calls a consent process on an org to add a member. +-- Depends on the Consent module. +join_org_consent = {} -JoinOrg = {} - -JoinOrg.setup = { - name = "Join an org", +join_org_consent.setup = { + name = "Join this org", slug = "join_org_consent", - desc = "Consent based join org module" + desc = "Adds member with consent of all members." } -function JoinOrg:initiate() +function join_org_consent:initiate() self.org:call_module( "consent", self.initiator, { prompt = "Allow " .. self.initiator .. " to join?", - votes_required = 1 + votes_required = #self.org.members }, function () self:complete() @@ -22,9 +24,9 @@ function JoinOrg:initiate() ) end -function JoinOrg:complete() +function join_org_consent:complete() self.org:add_member(self.initiator) - print("Added " .. self.initiator .. " to the org!") + print("Added " .. self.initiator .. " to the org.") end -modpol.modules.join_org_consent = JoinOrg \ No newline at end of file +modpol.modules.join_org_consent = join_org_consent diff --git a/modpol/modules/remove_org.lua b/modpol/modules/remove_org.lua index e69de29..ae9bbdc 100644 --- a/modpol/modules/remove_org.lua +++ b/modpol/modules/remove_org.lua @@ -0,0 +1,22 @@ +--- Remove Org +-- A simple module that calls a consent process on an org to remove it. +-- Depends on the Consent module. +remove_org = {} + +--- (Required): setup table containing name and description of the module +remove_org.setup = { + name = "Remove this org", + slug = "remove_org", + desc = "Removes an org if all members consent." +} + +--- Initiate function +--
self.org
(the org the module was called in),self.initiator
(the user that callced the module),self.id
(the process id of the module instance)self.org
(the org the module was called in),self.initiator
(the user that callced the module),self.id
(the process id of the module instance)