That might work but is pretty much useless. Such a function won't have the upvalues, so it won't see neither the first plugin's globals nor the locals. Consider this example:
I'm not sure now whether Plugin2 will fail on the actual execution, or if the loadstring() will already complain about the undefined function. But the end result is the same - the callback just cannot access Plugin1's data in any way.
-- Plugin 1: function CallMe() ... end g_UseMe = 1; local SomeVar = 2; local Callback = [[ g_UseMe = 2; SomeVar = 3; CallMe(); ]] Plugin2:Call("Executor", Callback); -- The call has failed inside Plugin2, but that doesn't propagate here -- However, g_UseMe is still 1, SomeVar is still 2 and CallMe() hasn't been called. -- Plugin 2: function Executor(Callback) local Function = loadstring(Callback); Function(); -- will set Plugin2's globals g_UseMe to 2 and SomeVar to 3 and then fail with message "CallMe not defined" end;
I'm not sure now whether Plugin2 will fail on the actual execution, or if the loadstring() will already complain about the undefined function. But the end result is the same - the callback just cannot access Plugin1's data in any way.