template.lua 1.5 KB

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