55 lines
1.8 KiB
Lua
55 lines
1.8 KiB
Lua
--- change_modules
|
|
-- @module change_modules
|
|
|
|
--- (Required): data table containing name and description of the module
|
|
-- @field name "Human-readable name"
|
|
-- @field slug "Same as module class name"
|
|
-- @field desc "Description of the module"
|
|
-- @field hide "Whether this is a hidden utility module"
|
|
local change_modules = {
|
|
name = "Module Human-Readable Name",
|
|
slug = "template",
|
|
desc = "Description of the module",
|
|
hide = false;
|
|
}
|
|
|
|
--- (Required) Data for module
|
|
-- Variables that module uses during the course of a process
|
|
-- Can be blank
|
|
change_modules.data = {
|
|
}
|
|
|
|
--- (Required): config for module
|
|
-- Defines the input parameters to the module initiate function.
|
|
-- Can be blank
|
|
-- 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"
|
|
change_modules.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>
|
|
-- @param result (optional) Callback if this module is embedded in other modules
|
|
-- @function initiate
|
|
function change_modules:initiate(result)
|
|
-- call interaction functions here!
|
|
|
|
-- concluding functions:
|
|
-- call these wherever process might end;
|
|
-- may need to put result in self.data.result
|
|
-- if process ends in another function
|
|
if result then result() end
|
|
self.org:delete_process(self.id)
|
|
end
|
|
|
|
--- (Required) Add to module table
|
|
modpol.modules.change_modules = change_modules
|