I don't know if this is primarily Perl-related or MUSH related, but here's the scenario:
I have all my aliases in a plugin script (i.e. pattern matching on OnPluginSend parameters). However, when I press enter two times in quick succession, I get a 'Type Mismatch' Error, and the OnPluginSend function does not work anymore. Any help would be greatly appreciated.
Perhaps you could post your aliases here, as well as the contents of your OnPluginSend function?
I don't have any in-client aliases. They're all in the script. (sorry for the misleading statement). Anyway here's part of the script:
sub OnPluginSend {
my $command=@_[0];
$command=aliases_general($command);
if ($command) {
$world->Send($command);
}
}
sub aliases_general {
my $command=@_[0];
if ($command=~/^clanlist$/i) {
$clanlist="Your clans are: ";
for my $ctr (@clanlist) {
$clanlist=$clanlist."\t".$ctr."\n\t\t";
}
$clanlist=$clanlist."\n";
$world->note($clanlist);
$command=0;
#=============================================
# A. Fishing Aliases
#=============================================
} elsif ($command=~s/^tl$/tease line/i) {
} elsif ($command=~s/^jl$/jerk line/i) {
} elsif ($command=~s/^rl$/reel line/i) {
} elsif ($command=~s/^rcl$/reel line\ncast line $castdir/i) {
} elsif ($command=~s/^castdir (\D+)$//i) {
$castdir=$1;
$command=0;
} elsif ($command=~s/^recast$/bait hook with bait/i) {
@to_do=("rcl");
}
return $command;
}
When I press two CR's in quick succession, I get an error message box ('Type Mismatch') and suddenly the OnPluginSend sub does not get any parameters anymore.
It doesn't work anymore because the script engine (for the plugin) isn't working anymore (just like normal script errors, scripts turn off until you recompile).
It's any script error, what you posted looks fine, does anything else happen when you send things?
Not that this should cause the problem, but you're better off using $_[0] instead of @_[0] to get arguments for subroutines.
Why are you using a plugin callback instead of aliases? Since youre doing a lot of work that mushclient would be happy to do for you.
I'm trying to reduplicate the event, albeit unsuccessfully :D I added somethings recently, but I doubt they should have solved that problem since they were but superficial.
However here's how I recall what happens:
1. All my triggers are in a plugin callback too. And they still work after that error comes up (i.e. OnPluginPacketReceived still works)
2. Reinstalling the plugin does not help. The least drastic thing that helps is closing the World and opening a new one.
3. OnPluginSend does not even run (I put there a $world->note for debugging purposes, and it does not go through)
And I put all my triggers and aliases into the plugin callback because I'm wierd. :D I'd rather have one huge text file to work with than having to switch between multiple dialog boxes.
Why dont you put your triggers/aliases in triggers and aliases (and whatever else) INSIDE of the plugin? Then it's still just one big file (or if you want to, edit your world file with a text editor, although then you'd lose curret stuff each time you reloaded).
I couldn't duplicate errors either. Could it have perhaps been some other plugin (receiving text or whatnot) at the same time as you hitting return twice (response from the server from your blank line?)
I really opt not to put my triggers inside the plugin (not part of the script) since that would defeat the whole point of my project (which actually alters the entire look of the MUD, packet per packet).
I just duplicated the event though... this is only one plugin running, no others, and yes, from all my tests I've narrowed it down to the fact that a fatal error with the OnPluginSend function occurs when there's an error with the parameter. Everything else works perfectly fine except for that one single callback. This is a rather huge project so its driving me nuts. Maybe I'll have to trap errors or something... Something I've never done before. I'll figure out something somehow.
I'm not a Perl expert, but I would think you can check the type of the argument before using it in such a way that it causes type mismatch.
Flannel is correct that once a script has a runtime error MUSHclient marks the script as "in error" until such time as the error is corrected and does not call it again. Otherwise you might get spammed with thousands of error messages, which might prevent you fixing the error.