Just a quick update…I didn’t get to upload to TestFlight yesterday because it seems CoronaCards is using the mic and camera…and Apple wants me to somehow clear that up. Giving it another attempt right now.
As for that require
hack I spoke about above, here’s the source if anyone wants it.
local oldRequire = require
local function newSafeTbl()
local tbl = {}
local meta = {}
local function returnSelf()
return tbl
end
meta.__index = returnSelf
meta.__newindex = returnSelf
meta.__add = returnSelf
meta.__sub = returnSelf
meta.__mul = returnSelf
meta.__div = returnSelf
meta.__idiv = returnSelf
meta.__lt = returnSelf
meta.__mod = returnSelf
meta.__pow = returnSelf
meta.__concat = returnSelf
meta.__unm = returnSelf
meta.__call = returnSelf
setmetatable(tbl, meta)
return tbl
end
function require(path)
local status, res = pcall(oldRequire, path)
if status then
return res
else
return newSafeTbl()
end
end
When you try to require
a library that exists, it works normally. But if the library doesn’t exist now, it will return this “safe table”. The safe table makes it near impossible to get a runtime error. Here’s a test I run it against. I try importing a non-existent library called “composer2”.
local composer2 = require "composer2"
composer2.a.c = 3
local x = composer2.a.c + composer2.a.c
local xy = composer2.a.c - composer2.a.c
local xy = composer2.a.c == composer2.a.c
local xy = composer2.a.c <= composer2.a.c
local xy = composer2.a.c < composer2.a.c
local xy = composer2.a.c > composer2.a.c
local xy = composer2.a.c >= composer2.a.c
local x = composer2.a.c * composer2.a.c
local xy = composer2.a.c / tostring(composer2.a.c)
local xy = -composer2.a.c % composer2.a.c
local xy = composer2.a.c ^ tostring(composer2.a.c())
local xy = composer2.a.c .. composer2.a.c
print(composer2.a.c[4])
Each one of the math operators, assignments, value access, etc I run on it, it will just ultimately return itself. Hopefully this will be enough for those depending on certain libraries to at least run their games without those libraries in App Maker