Pārlūkot izejas kodu

Merge branch 'master' of https://gitlab.com/medlabboulder/modpol

Luke Miller 3 gadi atpakaļ
vecāks
revīzija
4c912f0e1b

+ 12 - 13
README.md

@@ -1,4 +1,4 @@
-# modpol: Modular Politics Prototype for Minetest
+# Modular Politics Prototype for Minetest
 
 This is a mod for [Minetest](https://minetest.net) that enables diverse governance mechanisms. It seeks to implement the [Modular Politics](https://metagov.org/modpol) proposal. Ideally, in the future, it
 will be possible to use this framework to simulate governance in a
@@ -20,20 +20,15 @@ $ lua
 > dofile("modpol.lua")
 ```
 
+For a list of global functions and tables, use `modpol.menu()`.
+
 ## Minetest
 
 To use this in Minetest, simply install it as a Minetest mod. Minetest
 will load init.lua. See the source code for information about chat
 commands which can then be used.
 
-Most of these commands will later be buried under other commands that
-do more privilege checking. These are mainly for testing purposes.
-
-* `/addorg [orgname]` - Create a new org
-* `/listorgs` - Lists the orgs (and their members) currently in existence
-* `/listplayers` - Lists all the players currently in the game
-* `/joinorg [orgname]` - Adds the user to the specified org
-* `/pollself [question]` - Asks the player a yes/no/abstain question
+Use the `/menu` command to see a list of registered chat commands.
 
 
 ## Storage
@@ -42,7 +37,8 @@ By default, a  data  directory  named  "data" will  be created in  this director
 
 Another storage method may be chosen in modpol.lua. A StorageRef-based method for Minetest 5.* is included: storage-mod_storage.lua.
 
-## Stand-alone Modular Politics
+
+## Standalone Modular Politics
 
 To separate the Modular Politics core from the Minetest mod, simply remove these files:
 
@@ -58,13 +54,16 @@ depends.txt
 Eventually the stand-alone modpol package will be published as a separate repo.
 
 
-## Authorship
+## Credits
 
 Initiated by [Nathan Schneider](https://nathanschneider.info) of the [Media Enterprise Design Lab](https://colorado.edu/lab/medlab) at the University of Colorado Boulder, as part of the [Metagovernance Project](https://metagov.org). Based on the paper "[Modular Politics: Toward a Governance Layer for Online Communities](https://metagov.org/modpol)."
 
-We'd love to have more contributors, particularly from the Minetest community! Please join the conversation in the [Issues](https://gitlab.com/medlabboulder/modpol/-/issues) or the [Minetest.net forum](https://forum.minetest.net/viewtopic.php?f=47&t=26037).
+Thanks to contributors: 
+
+* [MisterE](https://gitlab.com/gbrrudmin) (project refactoring, core feature development)
+* Robert Kiraly [[OldCoder](https://github.com/oldcoder/)] (ocutils.lua, storage-local.lua, project refactoring)
 
-Thanks to contributors: Robert Kiraly [[OldCoder](https://github.com/oldcoder/)] (ocutils.lua, storage-local.lua, project refactoring), [MisterE](https://gitlab.com/gbrrudmin) (project refactoring, core feature development)
+We'd love to welcome more contributors, particularly from the Minetest community! Please join the conversation in the [Issues](https://gitlab.com/medlabboulder/modpol/-/issues) or the [Minetest.net forum](https://forum.minetest.net/viewtopic.php?f=47&t=26037).
 
 ## Licenses
 

+ 0 - 1
init.lua

@@ -1,6 +1,5 @@
 modpol = {}
 
-
 -- ===================================================================
 --preoverrides: certain things must be predefined in the global table for them to have effect (or cmd line version defualts are used)
 -- ===================================================================

+ 14 - 0
modpol/interactions/interactions.lua

@@ -3,6 +3,20 @@
 -- User interaction functions for Modular Politics
 -- Called by modpol.lua
 
+-- ===================================================================
+-- Function: modpol.menu(user)
+-- Params: user (string)
+-- Q: Should this return a menu of commands relevant to the specific user?
+-- Output: Displays a menu of commands to the user
+-- TKTK currently just prints all of modpol---needs major improvement
+modpol.menu = function(user)
+   local output = "Command list:\n"
+   for key,value in pairs(modpol) do
+      output = output .. "- modpol." .. key .. "\n"
+   end
+   print(output)
+end
+
 -- ===================================================================
 -- Function: modpol.binary_poll_user(user, question)
 -- Params: user (string), question (string)

+ 0 - 1
modpol/modpol.lua

@@ -70,7 +70,6 @@ modpol.load_storage()
 -- ===================================================================
 -- ModPol core features
 
-
 dofile (topdir .. "/api.lua")
 
 

+ 37 - 3
modpol_minetest/chatcommands/chatcommands.lua

@@ -2,11 +2,45 @@
 -- Minetest commands
 -- ===================================================================
 
+command_list = {}               -- user-facing table of commands
+
 local chat_table                -- MT chat command definitions table
 local regchat                   -- Chat-command registration function
 
 regchat = minetest.register_chatcommand
 
+regchat = function(name, command_table)
+   minetest.register_chatcommand(name, command_table)
+   table.insert(command_list, name)
+end
+
+-- ===================================================================
+-- /menu
+-- Presents a menu of options to users
+regchat(
+   "menu", {
+      privs = {},
+      func = function(user)
+         local result = modpol.menu(user)
+         return true, result
+      end,
+})
+
+-- ===================================================================
+-- /reset
+-- For testing only
+-- Clears the system and recreates instance with all players
+regchat(
+   "reset", {
+      privs = {},
+      func = function(user)
+         modpol.reset_orgs();
+         return true, "Reset orgs"
+      end,
+})
+
+
+
 -- ===================================================================
 -- /addorg  /add_org
 -- This code defines a chat command which creates a new
@@ -44,7 +78,7 @@ regchat ("list_orgs" , chat_table)
 
 -- ===================================================================
 -- /listplayers
-minetest.register_chatcommand(
+regchat(
    "listplayers", {
       privs = {},
       func = function(user)
@@ -55,7 +89,7 @@ minetest.register_chatcommand(
 
 -- ===================================================================
 -- /joinorg
-minetest.register_chatcommand(
+regchat(
    "joinorg", {
       privs = {},
       func = function(user, param)
@@ -69,7 +103,7 @@ minetest.register_chatcommand(
 -- ===================================================================
 -- /pollself [question]
 -- asks the user a question specified in param
-minetest.register_chatcommand(
+regchat(
    "pollself", {
       privs = {},
       func = function(user, param)

+ 2 - 2
modpol_minetest/orgs/instance.lua

@@ -2,5 +2,5 @@
 
 minetest.register_on_joinplayer(function(player)
     local p_name = player:get_player_name()
-    modpol.add_member("instance", p_name)
-end)
+    modpol.add_member(1, p_name)
+end)

+ 14 - 1
modpol_minetest/overrides/interactions/interactions.lua

@@ -1,4 +1,17 @@
 
+-- ===================================================================
+-- Function: modpol.menu(user)
+-- Params: user (string)
+-- Q: Should this return a menu of commands relevant to the specific user?
+-- Output: Displays a menu of commands to the user
+-- TKTK currently a manually curated list---needs major improvement
+modpol.menu = function(user)
+   local output = "Command list:"
+   for key,value in pairs(command_list) do
+      output = output .. "/" .. value .. " "
+   end
+   return output
+end
 
 -- ===================================================================
 -- Function: modpol.binary_poll_user(user, question)
@@ -41,4 +54,4 @@ modpol.binary_poll_user = function(user, question)
     else -- if the form is not a recognized name
        return
     end
-end)
+end)