template.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --- module_template
  2. -- @module module_template
  3. --- (Required): data table containing name and description of the module
  4. -- @field name "Human-readable name"
  5. -- @field slug "Same as module class name"
  6. -- @field desc "Description of the module"
  7. local module_template = {
  8. name = "Module Human-Readable Name",
  9. slug = "template",
  10. desc = "Description of the module"
  11. }
  12. --- (Required) Data for module
  13. -- Variables that module uses during the course of a process
  14. -- Can be blank
  15. module_template.data = {
  16. }
  17. --- (Required): config for module
  18. -- Defines the input parameters to the module initiate function.
  19. -- Can be blank
  20. -- When calling a module from within another module,
  21. -- variables not defined in config will be ignored.
  22. -- Default values set in config can be overridden
  23. -- @field field_1 ex: votes_required, default = 5
  24. -- @field field_2 ex: voting_type, default = "majority"
  25. module_template.config = {
  26. field_1 = 5
  27. field_2 = "majority"
  28. }
  29. --- (Required): initiate function
  30. -- Modules have access to the following instance variables:
  31. -- <li><code>self.org</code> (the org the module was called in),</li>
  32. -- <li><code>self.initiator</code> (the user that callced the module),</li>
  33. -- <li><code>self.id</code> (the process id of the module instance)</li>
  34. -- @param result (optional) Callback if this module is embedded in other modules
  35. -- @function initiate
  36. function module_template:initiate(result)
  37. -- call interaction functions here!
  38. -- call result function
  39. if result then result() end
  40. end
  41. --- (Required) Add to module table
  42. modpol.modules.module_template = module_template