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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
gankzer
Newbie


Joined: 18 Apr 2010
Posts: 5

PostPosted: Sun Apr 18, 2010 1:00 am   

Trigger help
 
Hi. I'm trying to get a "fumble" trigger to work. The text is:

You swing at your foe _really_ badly, sending your An Elven Longsword flying!

The underlined text is the weapon that was just fumbled so could vary depending on what I have equipped. Is there an easy way to parse that random string? Or do i have to assign a variable each time i change weapons?

Thanks for any advice.[/i]
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sun Apr 18, 2010 6:04 am   
 
Code:

Pattern: You swing at your foe _really_ badly, sending your (*) flying!

Script:
$_article="a|an|the|some"
$_weapon=%replace(%1, " ", "|")
#FORALL $_weapon {#IF (!%ismember(%i, $_article)) {
  #send {get %i}
  #send {wear %i}
}}


However, a better solution would be to make a command input trigger (it's the drop down box below the script box)
Code:

Pattern: wield (*)

Script:
_curr_weapon=%1


Make a variable named _curr_weapon

Next, you have:
Code:

Pattern: You swing at your foe _really_ badly, sending your * flying!

Script:
#send {get @_curr_weapon}
#send {wear @_curr_weapon}
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Sun Apr 18, 2010 11:27 am   
 
making a trigger for setting weapon is prolly a tad much for a simple thing...

#ALIAS wd {wield %1;current_weapon = %1}
#TRIGER {^You swing at your foe _really_ badly, sending your * flying!$} {get @current_weapon;wd @current_weapon}

gotta keep in mind after a while, triggers must watch every line and check for matches, aliases just sit there till used, thus why i'd reccoment a "wield" alias

p.s. wd for primary, dw for duel weapon if you use em.. easy to remember
Reply with quote
gankzer
Newbie


Joined: 18 Apr 2010
Posts: 5

PostPosted: Sun Apr 18, 2010 12:40 pm   
 
thanks for both replies. It's now working as needed but more importantly - I learned something new. Thanks!!
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Apr 18, 2010 5:22 pm   
 
Quote:

gotta keep in mind after a while, triggers must watch every line and check for matches, aliases just sit there till used, thus why i'd reccoment a "wield" alias


Actually, that's not true.

#trigger {you were disarmed!} {
wield dagger
}

The above will cause every alias to be checked against the word 'wield'. To avoid this check, use #SENDRAW if you are sending literal commands (ie, "wield dagger") or #SEND if you are sending variable data ("wield @current_weapon").
_________________
EDIT: I didn't like my old signature
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Tue Apr 20, 2010 7:56 am   
 
if i have an alias foobar... then only when i enter foobar as a command is it searched for, otherwise it just sits there

if i have a trigger for {foobar}, then every line on the screen is checked for the pattern
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Tue Apr 20, 2010 10:05 am   
 
Private wrote:
if i have an alias foobar... then only when i enter foobar as a command is it searched for, otherwise it just sits there

Everything you enter into the command line is parsed unless you turn the command parser off. So if you enter wield into the command line all of your aliases are checked to see if there is a matching alias called wield. The same is true within lines of scripts. Matt summed it up perfectly:
MattLofton wrote:
#trigger {you were disarmed!} {
wield dagger
}

The above will cause every alias to be checked against the word 'wield'. To avoid this check, use #SENDRAW if you are sending literal commands (ie, "wield dagger") or #SEND if you are sending variable data ("wield @current_weapon").
_________________
Taz :)
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Tue Apr 20, 2010 11:50 am   
 
whatever yall say, i still think aliases are better then triggers... i receive a LOT more text from the mud that has to be parsed with triggers then i send to the mud that has to be parsed by aliases...

simple math... 1000 triggers vs. 1000 aliases... the triggers will cause more load
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Tue Apr 20, 2010 12:32 pm   
 
There is no argument there that is absolutely true. If something you want to do can be achieved by an alias alone then definitely do so instead of using a trigger.

I just wanted to clarify how the command line and scripting works.
_________________
Taz :)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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