Quote:
Originally Posted by c0ncrete
you can't have two subroutines with the same name in the same namespace in perl. only the last one ends up being used. if you want to check your scripts for compilation errors while writing them, add these lines at the top and run then from a command line, instead of using them from within the emulator:
Code:
use strict;
use warnings;
when you run your script from within the emulator, you'll most likely need to either remove the additional lines listed above or add the following to get them to run:
if you were to add those lines to your script, you'd see a message similar to this one, indicating something likely isn't working as you expected it to:
example_script.pl
Code:
use strict;
no strict 'vars';
use warnings;
use constant {
TRUE => 1,
FALSE => 0
};
sub conditionMet_1 {
my $bool = defined($_[0]) ? shift : FALSE;
print "DEBUG: checking conditionMet_1($bool)\n";
return $bool;
}
sub conditionMet_2 {
my $bool = defined($_[0]) ? shift : FALSE;
print "DEBUG: in checking conditionMet_2($bool)\n";
return $bool;
}
sub EVENT_ARBITRARY {
# checking for TRUE(1) returned in both conditions
# second condition is not checked if first fails
if ( conditionMet_1(shift) && conditionMet_2(shift) ) {
print "DEBUG: both conditions passed\n";
}
else {
print "DEBUG: both conditions did not pass\n";
}
}
sub EVENT_ARBITRARY {
# same as before, but checking for FALSE on either condition
# since this subroutine has the same name and is last in the list, it is used
print "DEBUG: in second defintion of EVENT_ARBITRARY\n";
if ( !conditionMet_1(shift) || !conditionMet_2(shift) ) {
print "DEBUG: both conditions did not pass\n";
}
else {
print "DEBUG: both conditions passed\n";
}
}
EVENT_ARBITRARY(FALSE, TRUE);
output:
Code:
C:\EQEmu\sandbox>perl test_conditionals.pl
Subroutine EVENT_ARBITRARY redefined at test_conditionals.pl line 34.
DEBUG: in second defintion of EVENT_ARBITRARY
DEBUG: checking conditionMet_1(0)
DEBUG: both conditions did not pass
command-line debugging will also let you know when you have things like missing brackets, semicolons, or any other major syntax issues.
|
Ok!,
had another shot, this is how it looks now

But, got a problem with the else statement?, anyone got thoughts, thanks for the help thus far!
sub EVENT_SAY {
if($text=~/Hail/i) {
quest::say("I am for hire, $name, and I'm currently charging 5pp per hour, Want me to fight for you $class?, just pass me 5pp");
}
sub EVENT_TIMER {
if($timer eq "payme") {
quest::say("Time for my payment, $name");
quest::stoptimer("payme");
}
}
else {
quest::say("No pay, no fighting, see you around, $name");
quest::depop;
}
sub EVENT_ITEM {
if(($platinum == 5)) {
quest::depop;
$client->MakePet(null, Trillion, "Trillion");
}
}
quest::settimer("payme", 60);
}