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
selch
Beginner


Joined: 19 Dec 2003
Posts: 15
Location: USA

PostPosted: Tue Mar 02, 2004 11:55 am   

Simple Trigger help please
 
I've read the pattern matching help but I can't seem to get my head around triggers. At least some of them. Here's my problem:

In a fight I may get disarmed:

A long thin dagger flies from your grasp.

I want to write a trigger that will get the dagger, or whatever weapon i was holding, and then wield it again.

My trigger:

A (*) flies from your grasp

#COLOR Orange <- so I can see the line fly by
#SEND Get %1 <- to grap the weapon
#SEND Hold %1 <- to hold it again

Well lets just say I color the line correctly, otherwise, nada. And of course the item being held will vary.
Reply with quote
Pega
Magician


Joined: 08 Jan 2001
Posts: 341
Location: Singapore

PostPosted: Tue Mar 02, 2004 12:16 pm   
 
Use {}'s.

#SEND {Get %1}
#SEND {Hold %1}

It appears that if you do a '#SEND Get %1', #SEND would assume that Get is a file you would like to open and have its contents sent to the mud prefixed with %1.
Reply with quote
selch
Beginner


Joined: 19 Dec 2003
Posts: 15
Location: USA

PostPosted: Tue Mar 02, 2004 2:16 pm   
 
Nope. Didn't work. When testing the trigger the * captures the text I want so it seems that I'm having problems with how to format and send the commands back to the mud. Should I be using the #SEND command or another one? Currently, my non-working command is:

#SEND {Get %1}
#SEND {Hold %1}
Reply with quote
selch
Beginner


Joined: 19 Dec 2003
Posts: 15
Location: USA

PostPosted: Tue Mar 02, 2004 5:09 pm   
 
Well I've sort of figured it out. If I simply use:
get %1
hold %1
It will just send those commands to the mud. *bonk my head*

However, I've discovered a new problem with this. Say I'm holding 'a small training dagger'.
When I send 'get %1' it tries to get 'a small training dagger' like it should. However, the mud won't except that command. Meaning, its looking for the item in particular. So sending just 'get dagger' would allow me to pick it up.

I'm thinking that my trigger will need to be much more complex as I'll have many different items. Some as simple as 'a knife' and others such as 'a training dagger' or 'the Rod of Gnath'. So I'm going to have to figure out how to parse out just the item's name or maybe just rid the variable of the first word: a, the, etc.

Did some testing manually and yes, it seems if I don't send 'a' or 'the' it will let me do the command 'get small' for 'a small training dagger'.

So any tips on how to parse out such an instance?
Reply with quote
selch
Beginner


Joined: 19 Dec 2003
Posts: 15
Location: USA

PostPosted: Tue Mar 02, 2004 5:28 pm   
 
Bah! Did some more manual testing and it seems the MUD is a bit finicky(sp) about how you specify an item to get.

A small training dagger. I can send 'get small' and 'get dagger' to get it, but not 'get training'.

A small hand axe. I can send 'get small' and 'get axe' but not 'get hand'.

The Rod of Gnath. I don't have one to test on but I'm thinking it'll only take 'rod'.

Ideas?
Reply with quote
selch
Beginner


Joined: 19 Dec 2003
Posts: 15
Location: USA

PostPosted: Tue Mar 02, 2004 6:35 pm   
 
I think I've figured it out now. Since the last word of the item seems to be the key. i.e. a small training dagger. Dagger being the word to use. So I've made my script:

Pattern to match (> is the end of the prompt):
~> (*) flies from your grasp

Script:
#COLOR Orange <- To color the line 'A small training dagger flies from your grasp.' So I can see it.
#VAR num %numwords( %1) <- The pattern matched is 'A small training dagger' so count the number of words and set that to variable 'num'
get %word( %1, @num) <- get the last word as its the one I want and send the get command to the MUD with that word. ie 'get dagger'
hold %word( %1, @num) <- ditto except it'll be 'hold dagger'

Anyway I could clean this up or wouldn't that really matter as they'll parse the same? Or is there a better way to go about this?

Thanks all. I've obviously figured this out myself but would love some input from you scripting gurus.

selch
Reply with quote
Rennus
Beginner


Joined: 30 Dec 2003
Posts: 22
Location: USA

PostPosted: Tue Mar 02, 2004 11:40 pm   
 
The way I solved this problem is as follows:

Since the item you are wielding is normall the last word of its description (a short SWORD, a training DAGGER, etc) I set a trigger for when I wield a weapon as follows:

#trig {You wield * (*).} {#var weapon {%1}}

When I get disarmed a seperate trigger fires:

#trig {disarms you and sends} {wield @weapon}


Hope this helps.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Wed Mar 03, 2004 4:00 am   
 
quote:
Originally posted by selch


Pattern to match (> is the end of the prompt):
~> (*) flies from your grasp

Script:
#COLOR Orange <- To color the line 'A small training dagger flies from your grasp.' So I can see it.
#VAR num %numwords( %1) <- The pattern matched is 'A small training dagger' so count the number of words and set that to variable 'num'
get %word( %1, @num) <- get the last word as its the one I want and send the get command to the MUD with that word. ie 'get dagger'
hold %word( %1, @num) <- ditto except it'll be 'hold dagger'



How bout without a variable functions can be nested

SCRIPT
get %word(%1, %numwords(%1))
wield %word(%1, %numwords(%1))
Reply with quote
Vorax
Apprentice


Joined: 29 Jun 2001
Posts: 198
Location: USA

PostPosted: Wed Mar 03, 2004 4:23 am   
 
Just capture the last word of the weapon name.

#TRIG {* (%w) flies from your grasp.} {
get %1
hold %1
}
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