[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Perlscript
. . -> [Subject]  Newbie Perlscript Issues

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Newbie Perlscript Issues

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Sb   (12 posts)  [Biography] bio
Date Mon 04 Jul 2005 09:35 PM (UTC)  quote  ]

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.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #1 on Tue 05 Jul 2005 06:49 PM (UTC)  quote  ]
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.
[Go to top] 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.


2,392 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]