Files
modpol/modpol/modules/template.lua
T
2021-12-16 14:07:58 -07:00

40 lines
1.3 KiB
Lua

--- Template for modules
-- function initiate and table setup are required as a base.
-- @module Template
Template = {}
--- (Required): setup table containing name and description of the module
-- @field name "Module Human-Readable Name"
-- @field slug "Template" same as module name
-- @field desc "Description of the module"
Template.setup = {
name = "Module Human-Readable Name",
slug = "Template",
desc = "Description of the module"
}
--- (Optional): config for module
-- Defines the input parameters to the module initiate function.
-- When calling a module from within another module,
-- variables not defined in config will be ignored.
-- Default values set in config can be overridden
-- @field field_1 ex: votes_required, default = 5
-- @field field_2 ex: voting_type, default = "majority"
Template.config = {
field_1 = 5
field_2 = "majority"
}
--- (Required): initiate function
-- Modules have access to the following instance variables:
-- <li><code>self.org</code> (the org the module was called in),</li>
-- <li><code>self.initiator</code> (the user that callced the module),</li>
-- <li><code>self.id</code> (the process id of the module instance)</li>
-- @function initiate
function Template:initiate(config, result)
-- call interaction functions here!
-- call result function
if result then result() end
end