-- sandbox runner for the loader carrier local realprint = print local function log(...) local parts = {} for i=1,select('#',...) do parts[i]=tostring(select(i,...)) end realprint('[sandbox] '..table.concat(parts,' ')) end local function mkproxy(name, depth) depth = depth or 0 local p = {} setmetatable(p, { __index = function(t,k) log('INDEX', name, tostring(k)) local child = mkproxy(name..'.'..tostring(k), depth+1) rawset(t,k,child) return child end, __call = function(t, ...) local args = {} for i=1,select('#',...) do args[i]=tostring(select(i,...)) end log('CALL', name, table.concat(args, ',')) return mkproxy(name..'()', depth+1) end, __tostring = function() return '' end, __newindex = function(t,k,v) log('SET', name, tostring(k), tostring(v)); rawset(t,k,v) end, }) return p end local missing = {} setmetatable(_G, { __index = function(t,k) if missing[k] == nil then missing[k] = true log('GLOBAL MISSING', tostring(k)) end local v = mkproxy(tostring(k), 0) rawset(t,k,v) return v end }) local ok, err = pcall(function() return dofile('load_peel_03_inner.lua') end) log('RESULT', tostring(ok), tostring(err))