• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Reflection] A function to print all the functions of a given table.

Jack Parsons

Member
Joined
Mar 8, 2016
Messages
32
Reaction score
12
Location
São Paulo State, Brazil
I grew somewhat tired of reading compat.lua to learn the available functions (Since they're mostly "shortcuts"), so I came up with this solution. Just introduce this function to your global.lua:
Code:
function listFunctions(t)
    for i, v in pairs(t) do
        if type(v) == "function" then
            print(i, v, debug.getinfo(v))
        end
    end
end
Then, you have to pass the table that you wish to introspect / inspect (Like "Player", "Item", "Town", "Creature", "Tile", etc (Still inside global.lua)).
Code:
listFunctions(Item)
This way, you can discover all the functions and read them each time the server starts. You could also use the I/O Library in order to export them to a text file.

Example:

3eb49a2.png
 
Last edited:
Back
Top