-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
31 lines (26 loc) · 752 Bytes
/
main.lua
File metadata and controls
31 lines (26 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
--Limport Debug Testing
--[[
Attach automatic pathing for required modules
We can do this by adjusting the loader's environment and changing package.path locally
For language interoperability, we can use metatables
]]
package.path = '.\\?\\init.lua;'..package.path;
local mirror = {};
for i, v in next, getfenv() do
mirror[i] = v;
end;
setmetatable(mirror, {
__index = function(self, index)
if (index == 'TEST') then return 5; end; return getfenv()[index];
end;
__newindex = function(self, index, value)
getfenv()[index] = value;
end;
})
print('test mirror', mirror.TEST);
local f = function()
print('F', TEST);
end;
setfenv(f, mirror)();
print(require'jsone');
print(package.loaded.jsone);