template.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 config (optional) If user wants to override fields in the config table
  35. -- @param result (optional) Callback if this module is embedded in other modules
  36. -- @function initiate
  37. function module_template:initiate(config, result)
  38. -- call interaction functions here!
  39. -- call result function
  40. if result then result() end
  41. end
  42. --- (Required) Add to module table
  43. modpol.modules.module_template = module_template