Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ Perlscript
➜ Newbie Perlscript Issues
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Sb
(12 posts) Bio
|
Date
| Mon 04 Jul 2005 09:35 PM (UTC) Amended on Mon 04 Jul 2005 09:37 PM (UTC) by Sb
|
Message
| I'm not new to PERL, but I am new to the MUSH Client interface. I'm trying to write a script to learn languages faster (a nice beginner thing to get a good feel).
sub OnLanguageLearn {
my ($thename, $theoutput, $wildcards) = @_;
$Language = $world->trim ($world->GetAliasInfo ($thename, 101));
if ($Language eq "") {
$world->send("language");
return;
}
for($i = 0; $i < 10; ++$i) {
$world->send ("language learn $Language");
}
}
Quote:
<alias
script="OnLanguageLearn"
match="^languagelearn(.*)$"
enabled="y"
regexp="y"
ignore_case="y"
sequence="100"
>
Everytime I try, 'languagelearn common' it sends 'language' because @_ and subsequently $Langauge are always empty. What exactly am I doing wrong here? I think it's something on the alias side, but not sure. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #1 on Tue 05 Jul 2005 06:49 PM (UTC) |
Message
| Why are you using the getinfo, instead of just getting the wildcard?
You probably want the first line to be:
my ($name, $output, @wildcards) = @_;
since, wildcards will/can be an array.
your alias should account for your space, ^languagelearn (.*)$ since, that'll make the wildcard be "common" in your example instead of " common".
But, the biggest problem is, your alias doesnt HAVE a name. So, you're calling getaliasinfo("",101) which returns EMPTY.
However, you could just as easily (and a couple lines smaller...ly) code the script straight into the alias.
You set the sendto box to 'script' and then you can put a script right in the aliases/triggers 'send' box. The good part is (besides not having to have a bunch of subroutines that are only used with one trigger/alias/timer, which means you have to edit/recompile your script file each time you want to add/edit one) you can use wildcard expansion.
Your script would become:
$Language = $world->trim("%1");
if ($Language eq "")
{
$world->send("language");
}
else
{
foreach(1..10)
{
$world->send("language learn $Language");
}
}
and it will be contained within your alias, so you can delete the whole thing together, or send it to someone in one piece. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
12,172 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top