|
ew1075 Newbie
Joined: 21 Sep 2007 Posts: 4
|
Posted: Fri Sep 21, 2007 6:25 am
Variables picking up too many words. |
I play on a mud where once a character gets above level 90, he gets a title put on the front of his name. So if your name is normally achilles, after level 90 your name may be Brother Achilles, or Warlock Achilles, depending on what class you are.
I am having trouble setting up triggers to work for both types of names at the same time. I set up the following trigger:
#TR {&name tells you 'sanctuary'} {cast 'sanctuary' @name}
This works for the lower level characters, however, if a char above level 90 sets off the trigger, the variable picks up both the title and the name and tries to cast like this: c 'sanctuary' brother achilles, which results in the spell not working but lag still being applied for the attempt.
I can set up a trigger with 2 variables, one for the title and one for the name, like this:
#TR {&title &secondName tells you 'sanctuary'} {cast 'sanctuary' @secondName}
This works with chars above lev 90, but does not work with chars below lev 90 because they only have a name and not a title. If I run both triggers at the same time, it works fine for chars below lev 90, but the higher lev chars set both triggers off at the same time, resulting in extra lag.
Is there any way around this? Thanks in advance! |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Fri Sep 21, 2007 10:35 am |
Try
#TR {(%w) tells you 'sanctuary'} {name = %1;cast 'sanctuary' @name}
The %w says to look for just one word |
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Sep 21, 2007 7:13 pm |
I think part of it is that he wants to also cast it on those with pretitles, but needs to find out how to do that. How about this?
Code: |
#TRIGGER {(*) tells you 'sanctuary'} {#IF (%numwords( %string( %1))=2) {name=%word(%1, 2)} {name=%1};cast 'sanctuary' @name} |
That'll check to see if the (*) has one word or two. If it has two, then it'll put the second word as the name variable. Otherwise, it'll just use the only word there.
Charneus |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Fri Sep 21, 2007 9:01 pm |
I covered that by not forcing the start of a line with ^
with '(%w) tells you'
then 'Bob tells you' returns %1 as Bob
and 'Sir Bob tells you' returns %1 as Bob too |
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Sep 21, 2007 9:21 pm |
Duh. Yeah, I just realized that. lol. I'm used to having things anchored. Oh well. But with my script, you -can- anchor it and not be a victim of potential bug abuse. :)
Charneus |
|
|
|
ew1075 Newbie
Joined: 21 Sep 2007 Posts: 4
|
Posted: Sat Sep 22, 2007 3:00 am |
Thanks guys, that works beautifully!
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Sep 22, 2007 3:12 am |
Actually, a pattern of ^(*) something is less specific than (%w) something. It's a toss-up as to which is safer, too, though I'd suspect the latter to win that one as well. The former matches too many potentially dangerous things.
|
|
|
|
|
|