re. your questions of variable scope: the normal perl scoping policies are in tact. That means that variables will be scoped as globals in the current package unless declared with the my or local modifiers (although there may be other ways to modify scope, like enclosing in brackets). Your confusion is probably related to the way that the interpreter sets it up so that each npc's quest script is loaded into its own package - i.e... creating a global variable inside a function inside a script for npc 1234 results in a fully-qualified scope name of something like "$qst1234::somevar". While inside the qst1234 package, it can be accessed as $somevar. To access that same variable from another npc's script or a plugin or whatever, you would want to make sure to refer to it as "$qst1234::somevar" or include/use the qst1234 package. The same is true for functions (which explains how the interpreter knows to call the appropriate sub event_ or whatever function). I would have to do some review work to be able to say for certain how the plugin namespaces work, but OTTOMH, I would say that plugins are executed in the plugin:: package by default. This means that having a plugin to manage a global hash is probably wasted effort. It would make more sense to pick a reasonable namespace and just create a variable there.
If that sounded patronistic, I apologize. If it was, OTOH, instructive, then I suggest that you go back and review my initial comments on plugins and see why I was so excited about them. You can use the same namespace trickery to redefine variables and even redefine subroutines outside of your own namespace. You can alter one npc's behavior via another or via plugin or via #peval on the command-line.
As far as the flag stuff goes, I have been reticent to comment. My personal opinion is that the code I saw for it was kludgy and fundamentally broken. Moreover, I am not the maintainer of the code and have no control over what goes in and what does not. Since your question was kind of leading w/ the stipulations of being "in the know" and whatnot, I wasn't sure I should comment.
|