2013/4/8 Victor Bombi <sonoro@telefonica.net>:
It does not work, environment is missing the definitions in the required
files.
I think that it was too complicated in lua51 version. I wonder if there
is a
better way in lua 52
function add_functions_in(source,target,tag)
---
-- adds the functions in table "source" to table "target" with given tag
-- returns a list of all tables in "source"
local t={}
for k,v in pairs(source) do
if type(v)=='function' then target[tag..'.'..k]=v
elseif type(v)=='table' then t[k]=v
end
end
return t
end
local done = {}
function catalog(source,target,tag)
-- recursively adds the functions in table "source" and all functions
-- accessible via "source" to table "target"
local new=add_functions_in(source,target,tag)
done[source]=true
for k,v in pairs(new) do if not done[v] then
done[v]=true
catalog(v,target,tag.."."..k)
end end
return target
end
cat=catalog(_G,{},"_G")
for k,v in pairs(cat) do print(k) end
------------ prints out this: ------------
--[[
_G.string.byte
_G.os.getenv
_G.io.popen
_G.string.reverse
_G.package.searchers.1
_G.package.seeall
_G.debug.getlocal
_G.table.insert
_G.string.gsub
_G.math.min
_G.os.difftime
_G.io.close
_G.tostring
_G.module
_G.math.tanh
_G.rawset
_G.debug.setupvalue
_G.math.cos
_G.table.remove
_G.string.char
_G.math.randomseed
_G.math.floor
_G.table.sort
_G.string.match
_G.rawlen
_G.dofile
_G.load
_G.debug.setmetatable
_G.catalog
_G.loadstring
_G.string.len
_G.math.atan
_G.tonumber
_G.package.searchpath
_G.collectgarbage
_G.package.loaded.bit32.band
_G.math.modf
_G.package.loaded.bit32.arshift
_G.debug.getmetatable
_G.package.loaded.coroutine.running
_G.package.loaded.coroutine.status
_G.math.pow
_G.debug.getregistry
_G.pairs
_G.xpcall
_G.debug.upvalueid
_G.ipairs
_G.io.tmpfile
_G.math.asin
_G.table.pack
_G.math.sqrt
_G.math.ceil
_G.io.read
_G.loadfile
_G.math.ldexp
_G.type
_G.os.tmpname
_G.next
_G.rawget
_G.os.time
_G.io.output
_G.math.log
_G.math.atan2
_G.string.format
_G.io.open
_G.math.log10
_G.table.maxn
_G.os.rename
_G.math.abs
_G.print
_G.package.searchers.2
_G.package.loaded.bit32.rshift
_G.package.loaded.bit32.bxor
_G.debug.sethook
_G.os.date
_G.package.loaded.bit32.replace
_G.math.rad
_G.os.remove
_G.os.exit
_G.debug.getuservalue
_G.error
_G.io.flush
_G.debug.upvaluejoin
_G.debug.gethook
_G.math.tan
_G.unpack
_G.string.lower
_G.math.sinh
_G.os.clock
_G.io.lines
_G.table.concat
_G.debug.setuservalue
_G.package.loaded.bit32.extract
_G.package.searchers.4
_G.package.loaded.coroutine.wrap
_G.package.loaded.coroutine.yield
_G.package.searchers.3
_G.package.loaded.coroutine.resume
_G.package.loaded.coroutine.create
_G.package.loaded.bit32.bor
_G.io.write
_G.math.deg
_G.table.unpack
_G.package.loaded.bit32.btest
_G.debug.debug
_G.debug.getupvalue
_G.string.rep
_G.io.input
_G.package.loaded.bit32.lshift
_G.string.gmatch
_G.math.acos
_G.string.find
_G.math.frexp
_G.math.max
_G.package.loaded.bit32.lrotate
_G.math.exp
_G.math.random
_G.package.loaded.bit32.rrotate
_G.debug.setlocal
_G.string.upper
_G.os.setlocale
_G.add_functions_in
_G.select
_G.package.loadlib
_G.os.execute
_G.debug.traceback
_G.string.dump
_G.math.cosh
_G.pcall
_G.assert
_G.debug.getinfo
_G.rawequal
_G.math.sin
_G.setmetatable
_G.string.sub
_G.package.loaded.bit32.bnot
_G.getmetatable
_G.math.fmod
_G.require
_G.io.type
]]