SetPluginVariable? SetWorldVariable?

Posted by Wanghom8228 on Sun 05 Sep 2010 11:32 PM — 4 posts, 21,986 views.

#0
Hi Nick:
I noticed you updated the CallPlugin funcation recently.
Do you have a plan to add a new funcation like "SetPluginVariable" or "SetWorldVariable"??

I need this feature, but didn't find a workaround.

Thanks
Hong
Amended on Sun 05 Sep 2010 11:33 PM by Wanghom8228
USA #1
I think Nick's going to hate me for this:

CallPlugin("PLUGIN ID HERE", "SetVariable", "foo", "1")


If you want to make this a little cleaner:

function SetPluginVariable(id, key, val)
  return check(CallPlugin(id, "SetVariable", key, val))
end

SetPluginVariable("PLUGIN ID HERE", "foo", "1")


EDIT: There's no way to emulate a SetWorldVariable(), though. CallPlugin won't use a blank id "" to refer to the world, like some other plugins do.
Amended on Sun 05 Sep 2010 11:48 PM by Twisol
USA #2
What I normally recommend is that you create your own function in one plugin that sets a specific variable, and call it with CallPlugin in another. So you'd do something like this:

-- First plugin
function set_target(target)
  SetVariable("target", target)
end

-- Second plugin
CallPlugin("PLUGIN ID HERE", "set_target", "gnoll")


As I showed, you can cut out the middleman by calling SetVariable in the other plugin directly. That feels like a hack though. It's hilarious and awesome, but it's still a hack. ;)
USA #3
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3925&page=1

Will let you work around the issue