Procházet zdrojové kódy

failsafe for empty orgs.array

Luke Miller před 3 roky
rodič
revize
e22b143a6a
1 změnil soubory, kde provedl 11 přidání a 3 odebrání
  1. 11 3
      modpol/modpol.lua

+ 11 - 3
modpol/modpol.lua

@@ -71,9 +71,17 @@ dofile (topdir .. "/api.lua")
 
 -- ===================================================================
 -- Final checks
-for id, org in ipairs(modpol.orgs.array) do
-    if type(org) == 'table' then 
-        setmetatable(org, modpol.orgs)
+
+-- sets org metatable on load
+if (modpol.orgs.array) then
+    for id, org in ipairs(modpol.orgs.array) do
+        if type(org) == 'table' then 
+            setmetatable(org, modpol.orgs)
+        end
+        -- sets process metatable on load
+        for id, process in ipairs(org.processes) do
+            setmetatable(process, org.modules[process.type])
+        end
     end
 end