Aggravated - HELP (please :) )
Hello,
I have a bit of a problem that I'm trying to find the solution for - I'm trying to create a buff bot that tells non-casting classes (warriors, monks, rogues, berserkers) that they cannot cast spells therefore do not need the buff bot's services. Here is a sample of the code I was trying this with: sub EVENT_SAY { if($text=~/hail/i && $class == 'Warrior') { quest::say("You are a warrior. You cannot cast spells."); } } According to other code examples, and logic, this should work. If a warrior hails this NPC, the npc will reply as above - however, even a Shaman, or Necro, or whatever (I tried a few) classes will also see that message. So it seems that the NPC isn't seeing what class the user really is. Is my syntax off, or is this broken? I'm pulling my hair out... Regards, Sonic |
Been awhile since I even looked at this stuff :)
Not sure, but seems that should work, but like I said been a long time since I even looked at this. And the perl quests weren't my favorite anyways :) Hope it works/helps. (I have no way to test it) sub EVENT_SAY{ if($text=~/hail/i) && ($class == 'Warrior' || $class == 'Monk' || $class == 'Rogue' || $class == 'Berserker') { quest::say("You are a $class . You cannot cast spells."); } } |
This should work (if it does, notice the double brackets added) ;
Code:
sub EVENT_SAY{ This does work Code:
sub EVENT_SAY{ Quote:
|
the error is in the operator.
"==" is for numeric comparison, "eq" is for string comparison. your if should read: Code:
if($text=~/hail/i && $class eq 'Warrior' ) |
Duh, why didn't I think of that? Using a numerical based operator instead of a string based operator ... Thanks for helping out with this all :)
Regards, Sonic |
Hmm ..seems that using string operators makes no difference either.
Example: Quote:
Regards, Sonic |
I added parenthisis ...does nothing. :(
|
Quote:
Code:
if($text=~/hail/i && ( $class eq 'Rogue' || $class eq 'Warrior') ) if the text contains "hail" and class eq 'Rogue' OR class eq 'Warrior' whereas you want: if the text contains 'hail' AND the class is either Rogue or Warrior == sfisque |
Alright ..that makes sense. I'll give it a whirl. Thanks for your response. :D
Sonic |
Quote:
Quote:
Sonic |
Angelox, I'm trying to read this like a computer would read this:
Quote:
Quote:
Sonic |
Don't give up! I have taken weeks to understand simple things too. Just put it to aside, and come back to it again, later.
you only need $class for what you want - make one like this: Code:
sub EVENT_SAY{ You first PL might have worked, but you had typos in it. Quote:
|
While im certian no noob user of perl (i do guess work... i guess this will work) lol
but being a c++/c# dev has given me an advantage. All languages follow the sample principlals when it comes down to it. This site, is well worth a read :) http://stein.cshl.org/genome_informa...tro/index.html In perticular, check out the "Operators" and also have a quick browse. Perl hjas the great advantage of being very english based :) The above link, is not EQEmu information, but rather just perl. - froglok |
I got it to work, finally! This is what I did:
Quote:
Thanks all for your help and support, I appreciate it a ton. Sonic |
Quote:
if $text contains "hail" and the $class is either ( not warrior ) or (not rogue) which is true if you're a rogue ( rogue != warrior ). converse statements (ones containing "negations" ) are usually tricky and require some care. you're easiest bet would be to construct it like follows: if( contains "hail" ) { if( class1 ) { do something } elsif (class2 ) { do something else } elsif( class3 ) { do something else } ... else { do the other thing } } hope this helps. == sfisque |
All times are GMT -4. The time now is 10:46 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.