Global Fixed :D

This commit is contained in:
Cooldude2606
2018-10-14 20:55:21 +01:00
parent 05f6fa4657
commit f02d0d5d37
3 changed files with 14 additions and 6 deletions

View File

@@ -196,7 +196,16 @@ Manager.global=setmetatable({__defaults={},__global={
end
return setmetatable(Global,{
__call=function(tbl,default) return Manager.global(default,tbl) end,
__index=function(tbl,key) return rawget(Manager.global(),key) or moduleIndex[key] and Manager.global(key) end,
__index=function(tbl,key) return rawget(Manager.global(nil,tbl),key) or moduleIndex[key] and Manager.global(key) end,
__newindex=function(tbl,key,value) rawset(Manager.global(nil,tbl),key,value) end,
__pairs=function(tbl)
local tbl = Manager.global(nil,tbl)
local function next_pair(tbl,k)
k, v = next(tbl, k)
if type(v) ~= nil then return k,v end
end
return next_pair, tbl, nil
end,
path=module_path,name=module_name
})
end,

View File

@@ -3,10 +3,10 @@ function _log(...) log(...) end -- do not remove this is used for smaller verbos
Manager = require("FactorioSoftmodManager")
Manager.setVerbose{
selfInit=true, -- called while the manager is being set up
moduleLoad=true, -- when a module is required by the manager
moduleInit=true, -- when and within the initation of a module
modulePost=true, -- when and within the post of a module
moduleEnv=true, -- during module runtime, this is a global option set within each module for fine control
moduleLoad=false, -- when a module is required by the manager
moduleInit=false, -- when and within the initation of a module
modulePost=false, -- when and within the post of a module
moduleEnv=false, -- during module runtime, this is a global option set within each module for fine control
eventRegistered=false, -- when a module registers its event handlers
errorCaught=true, -- when an error is caught during runtime
output=Manager._verbose -- can be: can be: print || log || other function

View File

@@ -326,7 +326,6 @@ end
function Role._prototype:get_players(online)
if not self_test(self,'role','get_players') then return end
if online and not type_error(online,'boolean','Invalid argument #1 to role:get_players, online is not a boolean.') then return end
log(serpent.line(global))
if not global.roles[self.name] then global.roles[self.name] = {} end
local rtn = {}
for _,player_index in pairs(global.roles[self.name]) do