2
0

interactions.lua 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. -- ===================================================================
  2. -- /orgs.lua
  3. -- User interaction functions for Modular Politics
  4. -- Called by modpol.lua
  5. -- ===================================================================
  6. -- Function: modpol.menu(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.menu = function(user)
  12. local output = "Command list:\n"
  13. for key,value in pairs(modpol) do
  14. output = output .. "- modpol." .. key .. "\n"
  15. end
  16. print(output)
  17. end
  18. -- ===================================================================
  19. -- Function: modpol.binary_poll_user(user, question)
  20. -- Params: user (string), question (string)
  21. -- Output:
  22. -- presents a yes/no/abstain poll to a user, returns answer
  23. modpol.binary_poll_user = function(user, question)
  24. local query = "Poll for " .. user .. " (y/n/a): ".. question
  25. local answer
  26. repeat
  27. print(query)
  28. answer = io.read()
  29. until answer == "y" or answer == "n" or answer == "a"
  30. if answer == "y" then
  31. return "Yes"
  32. elseif answer == "n" then
  33. return "No"
  34. else
  35. return "Abstain"
  36. end
  37. end