[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]  Need some help!

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Need some help!
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by KorvinKray   (3 posts)  [Biography] bio
Date Fri 18 Dec 2009 10:12 PM (UTC)  quote  ]

Amended on Fri 18 Dec 2009 10:14 PM (UTC) by KorvinKray

Message
Oh well, seems more complicated than I thought, I will just have to forget about it for now and keep using XpertMud till I can figure it out.

Thanks for the replies.
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Thu 17 Dec 2009 07:17 PM (UTC)  quote  ]

Amended on Thu 17 Dec 2009 07:25 PM (UTC) by Nick Gammon

Message
Template:function=AddAlias AddAlias

The documentation for the AddAlias script function is available online. It is also in the MUSHclient help file.


Template:function=DeleteAlias DeleteAlias

The documentation for the DeleteAlias script function is available online. It is also in the MUSHclient help file.



KorvinKray said:


addTrigger("DAMAGE_WEAPON_AXE",qr/You try to axe/, sub {
	$lastWeapon="Axe";	
	delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
	addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
	return shift;
});



This isn't exactly how MUSHclient handles scripts. You can't put a Perl script in as the argument to AddTrigger. You have two options - put in the name of a script in your script file (the function name) or you use "send to script" and put the commands to be done (outside a function) in the "send" field.

See http://www.mushclient.com/scripting for a lengthy discussion about this.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by KorvinKray   (3 posts)  [Biography] bio
Date Thu 17 Dec 2009 05:30 PM (UTC)  quote  ]
Message
I guess what I am looking for is how do I create and delete aliases from within a script?
[Go to top] top

Posted by Ron   China  (15 posts)  [Biography] bio
Date Wed 16 Dec 2009 11:50 AM (UTC)  quote  ]
Message
The problem is Mush didn't have this function "delAlias".

Is that yourself defined function?

If so . please "require" the file that include sub delAlias first.

Ron
[Go to top] top

Posted by KorvinKray   (3 posts)  [Biography] bio
Date Wed 16 Dec 2009 11:14 AM (UTC)  quote  ]

Amended on Wed 16 Dec 2009 11:15 AM (UTC) by KorvinKray

Message
I have been trying to figure out how to get the working, if possible, in MUSHclient. It works fine in a couple other clients but cannot figure it out here. I keep getting this:

Error number: -2147467259
Event: Execution of line 1 column 0
Description: (in cleanup) Undefined subroutine &main::delAlias called




Called by: Immediate execution



use strict;
use warnings;
no warnings 'redefine';

my %inflictedDamage;
my %takenDamage;
my $lastWeapon="unknown";
my %inflictedWeapons;

sub damageText {
	my $txt='Damage Log:%r%cb%cuDamage inflicted:%cn%r%r';
	my $shots=0;
	my $damage=0;
	foreach my $loc (keys %inflictedDamage) {
		$txt .= sprintf('%20s: %4d damage in %4d shots.%%r',
				$loc,
				$inflictedDamage{$loc}->[1],
				$inflictedDamage{$loc}->[0]);
		$shots+=$inflictedDamage{$loc}->[0];
		$damage+=$inflictedDamage{$loc}->[1];
	}
 	$txt.=sprintf('%%ch%20s: %4d damage in %4d shots.%%cn%%r',
		"Total",$damage,$shots);
		
 	$txt.='%r%cb%cuWeapons hit:%cn%r%r';
	foreach my $loc (keys %inflictedWeapons) {
		$txt .= sprintf('%20s: %4d damage in %4d shots.%%r',
				$loc,
				$inflictedWeapons{$loc}->[1],
				$inflictedWeapons{$loc}->[0]);
	}
	
	$shots=0;
	$damage=0;	
	$txt.='%r%cb%cuDamage taken:%cn%r%r';
	foreach my $loc (keys %takenDamage) {
		$txt .= sprintf('%20s: %4d damage in %4d shots.%%r',
				$loc,
				$takenDamage{$loc}->[1],
				$takenDamage{$loc}->[0]);
		$shots+=$takenDamage{$loc}->[0];
		$damage+=$takenDamage{$loc}->[1];
	
	}
 	$txt.=sprintf('%%ch%20s: %4d damage in %4d shots.%%r%%cn',
		"Total",$damage,$shots);

	$txt=~s/ (?= )/ \%/g;
	return $txt;
}

delAlias(qr/^DAMAGE_/);
addAlias("DAMAGE_RESET",qr/^damagereset\s*$/,sub {
	%inflictedDamage=();
	%inflictedWeapons=();
	%takenDamage=();
	statusWindow->print(ansi('%cbDamage log reset%cn%r'));
	return undef;
	},1);
	
addAlias("DAMAGE_PRINT",qr/^dpr\s*$/,sub {
	statusWindow->print(ansi(damageText));
	return undef;
	},1);

delTrigger(qr/^DAMAGE_/);
addTrigger("DAMAGE_DEAL",qr/You hit for (\d+) points of damage in the ([\w (]+[\w)])/, sub { 
        my $w=$2;
        chomp $w;
	$inflictedDamage{$w}->[0]++;
	$inflictedDamage{$w}->[1]+=$1;
	$inflictedWeapons{$lastWeapon}->[0]++;
	$inflictedWeapons{$lastWeapon}->[1]+=$1;
	return shift;
	});

addTrigger("DAMAGE_TAKE",qr/You have been hit for (\d+) points of damage in the ([\w (]+[\w)])/, sub {
	my $p=$1;
	my $w=$2;
        chomp $w;
	unless ($w=~/transfer/) {
		$takenDamage{$w}->[0]++;
		$takenDamage{$w}->[1]+=$p;
	}
	return shift;
	});

addTrigger("DAMAGE_WEAPON",qr/You fire ([\w\-\/]+) at/, sub {
	$lastWeapon=$1;
	delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
	addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
	return shift;
});

addTrigger("DAMAGE_WEAPON_KICK",qr/You try to kick/, sub {
	$lastWeapon="Kick";	
	delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
	addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
	return shift;
});

addTrigger("DAMAGE_WEAPON_PUNCH",qr/You try to punch/, sub {
	$lastWeapon="Punch";	
	delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
	addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
	return shift;
});

addTrigger("DAMAGE_WEAPON_CLUB",qr/You try to club/, sub {
	$lastWeapon="Club";	
	delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
	addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
	return shift;
});


addTrigger("DAMAGE_WEAPON_AXE",qr/You try to axe/, sub {
	$lastWeapon="Axe";	
	delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
	addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
	return shift;
});


addTrigger("DAMAGE_WEAPON_DFA",qr/You land on your target/, sub {
	$lastWeapon="Death From Above";	
	delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
	addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
	return shift;
});


addAlias("DAMAGE_INSERT",qr/\@DAMAGE\@/,sub {
	my $t=damageText;
	my $l=shift;
	$l=~ s/\@DAMAGE\@/$t/;
	return $l;
});


As I said, this works in a couple other clients, here is the link to a screenshot I took of what it is supposed to look like.

http://i221.photobucket.com/albums/dd134/mark_perryman/BTMux%20Stuff/test.jpg

Thank you, any help is greatly appreciated.
[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.


1,821 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]