template.lua 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. -- @function initiate
  31. function Template:initiate(config, result)
  32. -- call interaction functions here!
  33. -- call result function
  34. if result then result() end
  35. end