Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Lpwn Wolf
Newbie


Joined: 10 Mar 2010
Posts: 8

PostPosted: Wed Mar 10, 2010 2:37 pm   

A Simple Problem (Probably)
 
Hello all. I've a rather simple problem that I can't really figure out with my meager zmud knowledge.

Basically, in a mud I play when I scan, I see mobs, it looks like this:

South : an astral warhorse


I've been trying to use a trigger to capture "astral warhorse" as a variable (say target), but ignore the words a, an, and the in making the variable itself as they confuse things ('kill an' has unfortunate consequences per se).

However, the trigger must also be able to handle this sort of readout:

South : Bob the Grocer

Setting 'Bob the Grocer' as target.

Is there someway to do this, and have the trigger ignore the words 'a', 'an', and 'the' altogether for reading the string and setting the variable?

Thanks for any help in advance!
Reply with quote
Martaigne
Wanderer


Joined: 05 Jan 2002
Posts: 88
Location: Atlanta, GA

PostPosted: Wed Mar 10, 2010 4:29 pm   
 
There's probably an easier way to do this from the more experienced coders but...

Try a %replace(@target," ","|"), which will turn your variable into a stringlist. Then, use an #IF statement to determine if the first item in the @target stringlist is "a", "an", or "the" with %item(@target, 1). If it exists, %delitem(@target, 1), %replace (@target, "|", " ") and send your 'kill @target' to the mud.
_________________
Unwritten Legends
Reply with quote
Lpwn Wolf
Newbie


Joined: 10 Mar 2010
Posts: 8

PostPosted: Wed Mar 10, 2010 9:18 pm   
 
How exactly would one code that, please? I've never used #if or stringlists before so pardon my newbieness. Also, is it possible to exclude certain words? Like Sue, who is a group member.
Reply with quote
Martaigne
Wanderer


Joined: 05 Jan 2002
Posts: 88
Location: Atlanta, GA

PostPosted: Wed Mar 10, 2010 9:58 pm   
 
I'm more used to CMUD, so I may get the syntax a little off... but I can try...

First, create your trigger for your scan. You probably already have this. The code for the trigger should be something like:


target = %replace(%-1, " ", "|")
#IF (%ismember(%item(@target, 1), "a|an|the")) {
target = %delnitem(@target, 1)
}
target = %replace(@target, "|", " ")


Then you can do whatever you wish with the @target. If you need an exclusion list, you'll build a stringlist of friends and compare in the same manner.
_________________
Unwritten Legends
Reply with quote
Lpwn Wolf
Newbie


Joined: 10 Mar 2010
Posts: 8

PostPosted: Wed Mar 10, 2010 11:55 pm   
 
Do I paste that into the trigger itself that finds @target?

If so, it didn't appear to work, so unsure what to do to fix it.
Reply with quote
Martaigne
Wanderer


Joined: 05 Jan 2002
Posts: 88
Location: Atlanta, GA

PostPosted: Thu Mar 11, 2010 2:03 am   
 
Show me your trigger?
_________________
Unwritten Legends
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Mar 11, 2010 11:20 am   
 
It truly is much more simpler than what Martaigne is trying to do (and Martaigne, your trigger will not work effectively anyway...)

#TRIGGER {Whatever your scan output is (make sure you're capturing something)} {target=%subregex(%1,"^(?:a |an |the )")}

That /should/ work. I just woke up, so the syntax may be wrong, but give it a try. I won't be able to do anything about it for another 9 hours if it's wrong, though, sadly. :\

Charneus
Reply with quote
Martaigne
Wanderer


Joined: 05 Jan 2002
Posts: 88
Location: Atlanta, GA

PostPosted: Thu Mar 11, 2010 3:00 pm   
 
Yeah, I figured there was an easier way. I'm not terribly experienced with regex yet.
_________________
Unwritten Legends
Reply with quote
Lpwn Wolf
Newbie


Joined: 10 Mar 2010
Posts: 8

PostPosted: Sun Mar 14, 2010 3:07 am   
 
This appears to work flawlessly, thank you both very much for the help!


I've never done a stringlist before, and the helpfile in zmud doesn't seem to have it mentioned. How might I find help in making a list of friendlies that this ignores so they don't get targeted?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Mar 14, 2010 3:39 am   
 
1)make your stringlist variable:

#variable stringlistname {item1|item2|itemN}

2)in the trigger (the pattern needs only to match the space WHERE the name would appear), use an conditional command (#IF, #SWITCH, etc) where the condition is %ismember(%1,@stringlistname):

Code:

#if (%ismember(%1,@stringlistname) = 0) {
  //stuff to do when %1 is not a friend
} {
  //stuff to do when %1 is a friend (if nothing, you can remove this set of curly braces)
}
_________________
EDIT: I didn't like my old signature
Reply with quote
Lpwn Wolf
Newbie


Joined: 10 Mar 2010
Posts: 8

PostPosted: Mon Mar 15, 2010 3:31 am   
 
Wow, thanks to all. This works fantastically! Much thanks for your time and effort.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net