Problem with my $variable
I am not quite sure how to get this working. Basically, I want my NPC to change what a variable is equal to on a timer, and then use that variably to decide when to do or not to do something. The variable I am using is $cast and for some reason, it always casts the illusion, even though everything else in the quest is working properly. The variable is supposed to switch to equal 0, and when it is 0, she isn't supposed to cast the illusions.
Code:
#Illusionist Quest |
I'm still a little fuzzy on how exactly my functions, but I think it you declare my $cast at the beginning of the script, before sub EVENT_SPAWN, it will allow only that script to use it, and it will carry through all of the subs.
Then again, this: Code:
if ($cast=1) { Code:
if ($cast==1) { Hope this at least points you in the right direction. |
Another thing to look at: Is a 'my' variable script level or sub level?
|
In PERL, "my" variables are private in scope. They're not the same as "local" variables, but they function as you'd expect a local variable would in this context. Not using "my" makes a variable global.
|
I think AndMetals suggestion cleared it up for me, though I didn't have time to fully test it yet. I was defining my variable in the subs instead of defining it 1 time before the subs to they all use the same one. That should allow each section to see any changes made to it.
|
All times are GMT -4. The time now is 11:34 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.