join_org_class.lua 946 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. -- JOIN ORG
  2. -- Module that enables a user to join an org
  3. JoinOrg = {}
  4. JoinOrg_mt = { __index = JoinOrg }
  5. function JoinOrg.create(initiator, org)
  6. local inst = {
  7. name = "Join an org",
  8. desc = "Initiator chooses an org to become a member of. Nothing happens if they are already in an org.",
  9. initiator = initiator,
  10. org = org
  11. }
  12. setmetatable(inst, JoinOrg_mt)
  13. return inst
  14. end
  15. function JoinOrg:initiate(result)
  16. modpol.interactions.binary_poll_user(
  17. self.initiator,
  18. "Would you like to join",
  19. function (resp)
  20. if resp == "Yes" then
  21. self:implement()
  22. end
  23. end
  24. )
  25. if result then result() end
  26. end
  27. function JoinOrg:request()
  28. end
  29. function JoinOrg:implement()
  30. self.org:add_member(self.initiator)
  31. end
  32. -- ===================================
  33. -- When calling a module internally
  34. modpol.modules.join_org_class = JoinOrg