Skip to content

Commit

Permalink
重构Module兼容部分代码
Browse files Browse the repository at this point in the history
  • Loading branch information
Muscipular committed Oct 8, 2021
1 parent eb93ff7 commit 7369314
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ModuleConfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ loadModule('autoRegister')
loadModule('bag')
loadModule('autoBattle')
loadModule('manaPool')
--useModule('Welcome2')
--useModule('LvOnePet')
--useModule('Signin')
useModule('Welcome2')
useModule('LvOnePet')
useModule('Signin')
13 changes: 13 additions & 0 deletions libs/Module/LegacyModule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,22 @@ function LegacyModule:createContext()
setmetatable(self.context, {
__index = self.sharedContext,
__newindex = function(table, key, value)
if rawget(table, key) then
rawset(table, key, value)
return
end
self.sharedContext[key] = value;
end
})
self.context.dofile = function(path)
return loadfile(path, 'bt', self.context)();
end
self.context.load = function(path, name, mode, env)
return load(path, name, mode or 'bt', env or self.context);
end
self.context.loadfile = function(path, mode, env)
return loadfile(path, mode or 'bt', env or self.context);
end
self.context.currentModule = self;
self.context.print = function(msg, ...)
if msg == nil then
Expand Down

0 comments on commit 7369314

Please sign in to comment.