CLI interactions updated for modules-as-actions
This commit is contained in:
parent
fa7a0f82f6
commit
28e2710efc
@ -19,12 +19,12 @@ In the game, open the Modular Politics interface with the command `/modpol`.
|
|||||||
|
|
||||||
Modular Politics can also be used independently of Minetest as a command-line tool. Currently command-line use of modpol requires a Unix-style system, but it is intended to become more fully platform independent.
|
Modular Politics can also be used independently of Minetest as a command-line tool. Currently command-line use of modpol requires a Unix-style system, but it is intended to become more fully platform independent.
|
||||||
|
|
||||||
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 command in this directory:
|
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/
|
$ cd modpol/interacctions/
|
||||||
$ lua [or luajit]
|
$ lua [or luajit]
|
||||||
> dofile("modpol.lua")
|
> dofile("login.lua")
|
||||||
```
|
```
|
||||||
|
|
||||||
For a list of global functions and tables, use `modpol.menu()`.
|
For a list of global functions and tables, use `modpol.menu()`.
|
||||||
@ -45,6 +45,7 @@ Other contributors include:
|
|||||||
* [Luke Miller](https://gitlab.com/lukvmil) (main control flow, object orientation, module spec)
|
* [Luke Miller](https://gitlab.com/lukvmil) (main control flow, object orientation, module spec)
|
||||||
* [MisterE](https://gitlab.com/gbrrudmin) (project refactoring, core feature development)
|
* [MisterE](https://gitlab.com/gbrrudmin) (project refactoring, core feature development)
|
||||||
* Robert Kiraly [[OldCoder](https://github.com/oldcoder/)] (ocutils.lua, storage-local.lua, project refactoring)
|
* Robert Kiraly [[OldCoder](https://github.com/oldcoder/)] (ocutils.lua, storage-local.lua, project refactoring)
|
||||||
|
* Skylar Hew (documentation)
|
||||||
|
|
||||||
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).
|
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).
|
||||||
|
|
||||||
|
@ -38,10 +38,12 @@ function modpol.interactions.dashboard(user)
|
|||||||
|
|
||||||
local sel = io.read()
|
local sel = io.read()
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
if modpol.orgs.array[tonumber(sel)] then
|
||||||
local sel_org = modpol.orgs.array[tonumber(sel)].name
|
local sel_org = modpol.orgs.array[tonumber(sel)].name
|
||||||
|
else
|
||||||
if not sel_org then return end
|
return
|
||||||
|
end
|
||||||
modpol.interactions.org_dashboard(user, sel_org)
|
modpol.interactions.org_dashboard(user, sel_org)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -53,6 +55,7 @@ function modpol.interactions.org_dashboard(user, org_name)
|
|||||||
local org = modpol.orgs.get_org(org_name)
|
local org = modpol.orgs.get_org(org_name)
|
||||||
if not org then return nil end
|
if not org then return nil end
|
||||||
|
|
||||||
|
-- identify parent
|
||||||
local parent = ""
|
local parent = ""
|
||||||
if org.id == 1 then
|
if org.id == 1 then
|
||||||
parent = "none"
|
parent = "none"
|
||||||
@ -60,67 +63,66 @@ function modpol.interactions.org_dashboard(user, org_name)
|
|||||||
parent = modpol.orgs.get_org(org.parent).name
|
parent = modpol.orgs.get_org(org.parent).name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- identify children
|
||||||
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
|
||||||
|
|
||||||
local process_msg = #org.processes .. " total"
|
-- list available modules
|
||||||
|
local org_modules = {}
|
||||||
|
for k,v in ipairs(org.modules) do
|
||||||
|
table.insert(org_modules, org.modules[k].slug)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- list pending actions
|
||||||
|
local process_msg = #org.processes .. " total actions"
|
||||||
if org.pending[user] then
|
if org.pending[user] then
|
||||||
process_msg = process_msg .. " (" .. #org.pending[user] .. " pending)"
|
process_msg = process_msg .. " (" .. #org.pending[user] .. " pending)"
|
||||||
else
|
else
|
||||||
process_msg = process_msg .. " (0 pending)"
|
process_msg = process_msg .. " (0 pending)"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- set up output
|
-- set up output
|
||||||
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("Children: " .. table.concat(children, ", "))
|
||||||
print("Processes: " .. process_msg)
|
print("Modules: " .. table.concat(org_modules, ", "))
|
||||||
|
print("Actions: " .. process_msg)
|
||||||
print()
|
print()
|
||||||
print("Commands: (L)eave, (J)oin, (P)rocesses, (A)dd child, (D)elete org")
|
print("Commands: (M)odules, (A)ctions")
|
||||||
|
|
||||||
local sel = io.read()
|
local sel = io.read()
|
||||||
print()
|
print()
|
||||||
|
|
||||||
if sel == 'l' or sel == 'L' then
|
if sel == 'm' or sel == 'M' then
|
||||||
org:remove_member(user)
|
print("Type module name: ")
|
||||||
|
local module_sel = io.read()
|
||||||
elseif sel == 'j' or sel == 'J' then
|
print()
|
||||||
org:make_request({user=user, type="add_member", params={user}})
|
local module_result = false
|
||||||
|
for k,v in ipairs(org_modules) do
|
||||||
|
if v == module_sel then
|
||||||
|
module_result = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if module_result then
|
||||||
|
org:call_module(module_sel, user)
|
||||||
|
else
|
||||||
|
print("Error: Module not found.")
|
||||||
|
end
|
||||||
|
|
||||||
elseif sel == 'a' or sel == 'A' then
|
elseif sel == 'a' or sel == 'A' then
|
||||||
print("What should the new org be named?")
|
|
||||||
local new_org_name = io.read()
|
|
||||||
org:make_request({user=user, type="add_org", params={new_org_name}})
|
|
||||||
|
|
||||||
elseif sel == 'd' or sel == 'D' then
|
|
||||||
org:make_request({user=user, type="delete", params={}})
|
|
||||||
|
|
||||||
elseif sel == 'p' or sel == 'P' then
|
|
||||||
local processes = {}
|
local processes = {}
|
||||||
print("All processes: (* indicates pending action)")
|
print("All processes: (* indicates pending action)")
|
||||||
for k,v in ipairs(org.processes) do
|
for k,v in ipairs(org.processes) do
|
||||||
local this_request = org.requests[v.request_id]
|
|
||||||
if type(this_request) == "table" then
|
|
||||||
local active = ''
|
local active = ''
|
||||||
if org.pending[user] then
|
if org.pending[user] then
|
||||||
if org.pending[user][v.id] then
|
if org.pending[user][v.id] then
|
||||||
active = '*'
|
active = '*'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local req_str = "[" .. v.id .. "] " ..
|
|
||||||
active .. this_request.type
|
|
||||||
if this_request.params[1] then
|
|
||||||
req_str = req_str .. ": " ..
|
|
||||||
table.concat(this_request.params, ", ")
|
|
||||||
end
|
|
||||||
print(req_str)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
print()
|
print()
|
||||||
print("Interact with which one?")
|
print("Interact with which one?")
|
||||||
@ -129,14 +131,12 @@ function modpol.interactions.org_dashboard(user, org_name)
|
|||||||
if not process then return end
|
if not process then return end
|
||||||
if org:has_pending_actions(user) then
|
if org:has_pending_actions(user) then
|
||||||
if org.pending[user][process.id] then
|
if org.pending[user][process.id] then
|
||||||
process:interact(user)
|
org:interact(process.id, user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
print("Command not found")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Function: modpol.interactions.policy_dashboard
|
-- Function: modpol.interactions.policy_dashboard
|
||||||
|
@ -11,14 +11,8 @@ function temp_org()
|
|||||||
return {
|
return {
|
||||||
id = nil,
|
id = nil,
|
||||||
name = nil,
|
name = nil,
|
||||||
policies = {
|
modules = modpol.modules,
|
||||||
add_org={process_type='consent', must_be_member=false},
|
|
||||||
delete={process_type='consent', must_be_member=false},
|
|
||||||
add_member={process_type='consent', must_be_member=false},
|
|
||||||
remove_member={process_type='consent', must_be_member=false}
|
|
||||||
},
|
|
||||||
processes = {},
|
processes = {},
|
||||||
-- requests = {},
|
|
||||||
pending = {},
|
pending = {},
|
||||||
members = {},
|
members = {},
|
||||||
parent = nil,
|
parent = nil,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user