HOWTO: Inter-plugin communication
#27
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:
-- 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.
Reply
Thanks given by:


Messages In This Thread
HOWTO: Inter-plugin communication - by FakeTruth - 10-11-2012, 08:07 AM
RE: HOWTO: Inter-plugin communication - by ThuGie - 10-11-2012, 08:11 AM
RE: HOWTO: Inter-plugin communication - by xoft - 10-11-2012, 09:08 PM
RE: HOWTO: Inter-plugin communication - by xoft - 10-11-2012, 11:05 PM
RE: HOWTO: Inter-plugin communication - by ThuGie - 10-12-2012, 12:36 AM
RE: HOWTO: Inter-plugin communication - by xoft - 10-12-2012, 04:57 AM
RE: HOWTO: Inter-plugin communication - by xoft - 10-23-2013, 05:43 AM
RE: HOWTO: Inter-plugin communication - by xoft - 10-23-2013, 06:33 AM
RE: HOWTO: Inter-plugin communication - by xoft - 11-25-2013, 01:33 AM
RE: HOWTO: Inter-plugin communication - by xoft - 12-07-2013, 06:51 AM



Users browsing this thread: 1 Guest(s)