🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Call a local function in Lua

Started by
0 comments, last by Fragmo 19 years, 10 months ago
Hi! Does anyone have an idea on how to call a local Lua function from C++? E.g. I have the following script: <code> local function OnLoaded() print("The script has been loaded.\n") end local function OnUnloaded() print("The script has been unloaded.\n") end </code> My system works fine if the two functions aren't defined as local, but the reason I need them to be local is because when I load more than one script that has a OnLoaded or OnUnloaded function, only the last-loaded script's functions get called (his functions overwritte the previous script's ones).
Advertisement
I'm not completely sure but since they are local you probably have to qualify the function name with the name of the parent table, i.e. lib.OnLoaded(). I had a similar problem that I solved by simply appending to the function name a value that is unique to each object. e.g. OnLoaded_ObjectName() or OnLoaded_1()

dave

This topic is closed to new replies.

Advertisement