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
foldar
Novice


Joined: 21 May 2020
Posts: 33
Location: The Netherlands

PostPosted: Mon Jun 28, 2021 3:48 am   

How do I create a trigger with the #TRIGGER command using a variable in it?
 
How do I create a trigger with the #TRIGGER command using a variable in it?

Like #TRIGGER MobAttack {@OpponentName %w (%w)} {tank=%1} does not work

It doesnt evaluate the @opponentName it puts it in as straight text.
There is no way to know @opponentName in advance, it is different every time.

So if you are fighting a mouse it should make the trigger a mouse %w (%w)
not @OpponentName %w (%w) like it does.

%1 (%w) would be worse. that matches almost every line. (may be slow)
Though I could see if %1 starts with @opponentname then.

a mouse hits Jane --> tank is Jane
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Mon Jun 28, 2021 6:59 pm   
 
is this just to track who is the active tank?

I don't think you can parse/eval the variable in the trigger itself. You can set a variable using '&{tank}' in place of the players name.

#TR {a &{monster} %w &{tank}} {} would write to the two variables @monster @tank their respective pattern matches, but you run the risk of a broad match without more definition to the pattern.

#REG {^a (\w) (?:hit|hits) (\w).} {monster = %1;tank = %2} (don't have client available to syntax check but something along those lines would work)
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Thu Jul 01, 2021 7:25 am   
 
You can test against a variable in a trigger if you enclose it in {}

#TRIGGER MobAttack {{@OpponentName} %w (%w)} {tank=%1}
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Fri Jul 02, 2021 10:56 am   
 
I stand corrected and TIL
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