|
@@ -1,4 +1,4 @@
|
|
|
-function modpol.orgs:call_module(module_name, initiator)
|
|
|
+function modpol.orgs:call_module(module_name, initiator, config, result)
|
|
|
if not modpol.modules[module_name] then
|
|
|
modpol.ocutil.log('Error in ' .. self.name .. ':call_module -> module "' .. name .. '" not found')
|
|
|
return
|
|
@@ -23,13 +23,15 @@ function modpol.orgs:call_module(module_name, initiator)
|
|
|
|
|
|
local module = modpol.modules[module_name]
|
|
|
|
|
|
+ -- setting default params
|
|
|
local new_process = {
|
|
|
metatable = {__index = module},
|
|
|
initiator = initiator,
|
|
|
org = self,
|
|
|
id = index
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ -- copying default fields from setup
|
|
|
for k, v in pairs(module.setup) do
|
|
|
new_process[k] = v
|
|
|
end
|
|
@@ -38,7 +40,14 @@ function modpol.orgs:call_module(module_name, initiator)
|
|
|
|
|
|
self.processes[index] = new_process
|
|
|
|
|
|
- self.processes[index]:initiate()
|
|
|
+ -- sets default values for undeclared config variables
|
|
|
+ for k, v in pairs(module.config) do
|
|
|
+ if config[k] == nil then
|
|
|
+ config[k] = v
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ self.processes[index]:initiate(config, result))
|
|
|
|
|
|
return index
|
|
|
end
|