Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 12-01-2015, 10:13 PM
provocating's Avatar
provocating
Demi-God
 
Join Date: Nov 2007
Posts: 2,175
Default Globals in Globals

So this would work in a normal zone folder....

Code:
my $var = 1;

sub EVENT_SAY {
     quest::say("Var value: " . $var);
}
If I throw this same script in the global folder the script runs fine but the variable value is gone unless of course put it in the same routine. I am sure this has something to do with it actually being a global variable. But in many instances I need that global variable. Ideas?
Reply With Quote
  #2  
Old 12-02-2015, 12:30 AM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

The use of "my" denotes it's not a "global" variable, thus a lexical/local variable.

I'm not sure what you're trying to do exactly bud, but, that said, guessing here, you -may- benefit from plugin::SEV and plugin::REV.

aka $entity->SetEntityVariable("variable_name", "value") and $entity->GetEntityVariable("variable_name")
Reply With Quote
  #3  
Old 12-02-2015, 12:48 AM
provocating's Avatar
provocating
Demi-God
 
Join Date: Nov 2007
Posts: 2,175
Default

I will try the entity variable, thanks.
Reply With Quote
  #4  
Old 12-02-2015, 08:13 AM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,589
Default

You could also just use quest globals using the 7 setting for NPC/PC/Zone, so quest::setglobal("Test", 1, 7, "F") would be a quest global for all NPCs, PCs, and zones and could be accessed simply by using $qglobals{"Test"} in any script.
Reply With Quote
  #5  
Old 12-02-2015, 08:35 AM
provocating's Avatar
provocating
Demi-God
 
Join Date: Nov 2007
Posts: 2,175
Default

Overall I am just wondering why the variables quit working when you take an NPC script and throw it in global, that is when it changes.
Reply With Quote
  #6  
Old 12-02-2015, 09:12 AM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,589
Default

I mean, as Ghanja mentioned 'my' is the Perl equivalent of Lua's 'local', meaning it's localized to a singular method or file, which could be the issue. It should work correctly being you're initializing it outside of the subroutines as a lexical variable. Due to that, it should also be able to be modified and viewed from inside any subroutine within a given script. Have you attempted removing the 'my' keyword and making it a non-lexical variable and testing it to see if you get any different results?
Reply With Quote
  #7  
Old 12-02-2015, 09:14 AM
provocating's Avatar
provocating
Demi-God
 
Join Date: Nov 2007
Posts: 2,175
Default

That was the first thing I did.
Reply With Quote
  #8  
Old 12-02-2015, 01:08 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

This seems to work for me.. what NPC / zone / file is this quest in.

I tried a single NPC and it works fine.. global npc it works fine as well.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:27 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3