Nevermind. newproxy to the rescue!
sandboxstring=function(s)
local proxy=newproxy(true)
local meta=getmetatable(proxy)
meta.__len=function()return #s end
meta.__index=function(_,k)
return function(a,...)
local t={string[k](s,...)}
for i=1,#t do if type(t[i])=='string'then t[i]=sandboxstring(t[i])end end
return unpack(t)
end
end
return proxy
end
This is the first time I have ever needed to use newproxy. I feel accomplished.