Posted 13 March 2013 - 10:08 PM
To understand why you'll have to understand how loadAPI() works.
To load an api it uses loadfile to load the code. Then it sets the function enviroment for your api wich will ensure that it doesn't use the global enviroment (That would be bad, you could for example only have one xy() function because they would overwrite each other).
As the last step it will loop through every index in the function enviroment and copy it into it's own table in the global enviroment
_G["yourAPIName"] = {"functions"}
That is the table you refer to if you say yourAPIName.functions.
But unfortiounatly if you manipulate the global index it won't change the function enviroment.
You can refer to it by typing getfenv() and setfenv(), but I think you can't do that from outside your api.
Edit: You don't have access to the lua function of your api, so you can't set it outside of your api.
if you say setfenv(1, yourNewTable) it will change the function enviroment of the current function, that is your api.