2
0

interactions.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. -- ===================================================================
  2. -- /orgs.lua
  3. -- User interaction functions for Modular Politics
  4. -- Called by modpol.lua
  5. -- ===================================================================
  6. -- Function: modpol.dashboard(user)
  7. -- Params: user (string)
  8. -- Q: Should this return a menu of commands relevant to the specific user?
  9. -- Output: Displays a menu of commands to the user
  10. -- TKTK currently just prints all of modpol---needs major improvement
  11. modpol.dashboard = function(user)
  12. local output = ""
  13. -- Org status
  14. output = output .. "Orgs:\n" .. modpol.orgs.list_all()
  15. -- Process status (ongoing processes)
  16. output = output .. "Processes:\n" .. table.concat(modpol.processes)
  17. -- Command list (should be redone to be org-specific)
  18. output = output .. "Command list:\n"
  19. for key,value in pairs(modpol) do
  20. output = output .. "modpol." .. key .. " "
  21. end
  22. print(output)
  23. end
  24. -- ===================================================================
  25. -- Function: modpol.binary_poll_user(user, question)
  26. -- Params: user (string), question (string)
  27. -- Output:
  28. -- presents a yes/no/abstain poll to a user, returns answer
  29. modpol.binary_poll_user = function(user, question)
  30. local query = "Poll for " .. user .. " (y/n/a): ".. question
  31. local answer
  32. repeat
  33. print(query)
  34. answer = io.read()
  35. until answer == "y" or answer == "n" or answer == "a"
  36. if answer == "y" then
  37. return "Yes"
  38. elseif answer == "n" then
  39. return "No"
  40. else
  41. return "Abstain"
  42. end
  43. end