1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- -- ===================================================================
- -- /orgs.lua
- -- User interaction functions for Modular Politics
- -- Called by modpol.lua
- modpol.interactions = {}
- -- ===================================================================
- -- Function: modpol.dashboard(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
- function modpol.dashboard(user)
- local output = ""
- -- Org status
- output = output .. "Orgs:\n" ..
- table.concat(modpol.orgs.list_all(),"\n")
- -- Process status (ongoing processes)
- output = output .. "\nProcesses:\n" .. table.concat(modpol.processes)
- -- Command list (should be redone to be org-specific)
- output = output .. "\nCommand list:\n"
- for key,value in pairs(modpol) do
- output = output .. "modpol." .. key .. " "
- end
- print(output)
- end
- -- ===================================================================
- -- Function: modpol.interactions.message
- -- input: user (string), message (string)
- -- output: prints message to CLI
- function modpol.interactions.message(user, message)
- print(user .. ": " .. message)
- end
- -- ===================================================================
- -- Function: modpol.interactions.text_query
- -- input: Query (string)
- -- output: User response (string)
- function modpol.interactions.text_query(query)
- -- TODO
- end
- -- ===================================================================
- -- Function: modpol.binary_poll_user(user, question)
- -- Params: user (string), question (string)
- -- Output:
- -- presents a yes/no/abstain poll to a user, returns answer
- function modpol.interactions.binary_poll_user(user, question)
- local query = "Poll for " .. user .. " (y/n): ".. question
- local answer
- repeat
- print(query)
- answer = io.read()
- until answer == "y" or answer == "n" or answer == "a"
- if answer == "y" then
- return "Yes"
- elseif answer == "n" then
- return "No"
- else
- return "Abstain"
- end
- end
|