Hello. I am hoping there is a Lua expert out there who might know how to do the following.
In my day to day coding, I often localize a number of Corona and Lua functions to achieve a speedup.
-- Loclized Lua and Corona Functions local mAbs = math.abs local mRand = math.random local getInfo = system.getInfo local getTimer = system.getTimer local strMatch = string.match local strFormat = string.format local pairs = pairs
While, this is easy and straightforward to do, it is time consuming and wasteful of file space. i.e. Before my code begins, I have a bunch of localization statements.
I am hoping that Lua has some ‘magic’ means of localizing functions. For example, and bear with me, I’m looking to simply replace the above example with something like this:
local localizer = require "localizer" localizer.doit()
The ‘localizer’ module would be defined something like this:
local localizeSomeFunctions() --[[Some LUA magic to localize: math.abs math.random system.getInfo ... etc. --]] end local public = {} public.doit = localizeSomeFunctions return public
So, what I’m looking for is the ‘Lua Magic’ in the above code.
Thanks in advance to anyone who digs into this. I’m open to solutions and/or hints, links, etc. that can lead me to a solution.
I’m quite willing to do more research, but thus far I’ve had no luck with this.