Posted 25 January 2014 - 11:21 PM
I wrote my first API, and in attempting to follow good practices, I made all of the functions with the exception of the user-callable functions local. However, I found that doing so caused me some grief, and I ended up having to make one of the internal API functions global.
Here is the scenario:
When I call the API.userFunction() with the local version of problemLocalFunction, I get the error:
When I remove the local keyword from the declaration of problemLocalFunction, everything runs fine.
It seems that I cannot call a local function from within another local function of the API. Can anyone explain this to me?
Here is the scenario:
local function localFuntion()
problemLocalFunction() <-- this is where the code errors
end
local function problemLocalFunction()
do
--stuff
end
end
function userFunction()
localFuntion()
end
When I call the API.userFunction() with the local version of problemLocalFunction, I get the error:
myCoolAPI:<line number of call to problemLocalFunction>: attempt to call nil
When I remove the local keyword from the declaration of problemLocalFunction, everything runs fine.
It seems that I cannot call a local function from within another local function of the API. Can anyone explain this to me?
Edited on 30 January 2014 - 12:53 AM