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
atheaker
Newbie


Joined: 10 Dec 2011
Posts: 9

PostPosted: Thu Feb 07, 2013 3:34 am   

Auto Recast Defense Spells. (Solved)
 
Trying to figure how to use the %pos function to read a variable I record each round from my defenses and when a spell drops to auto recast..
Currently I'm just using 3 triggers per defense to control them, 1 when they fade, 1 to recast, and 1 to confirm they've taken effect, I was hoping to try learning a different method.

<trigger priority="14920" id="1492">
<pattern>Protections: (*) T:</pattern>
<value>#va defs %1
#IF (%pos("A ","A MS SS B MG MB ST")=0) {cast armor}</value>
</trigger>




that's what I currently have, the display line coming out each round for my defenses looks like this:
*****! Protections: *I15* A MS SS B MG MB ST T: Mon(Bla):83%

the *****! is random to if it's there or not, and it's not always the same amount of *'s and !'s... *I15* is random if it's there or not as well... it's a duration spell... and ST is random it is only active when ****! is active.... T: is my target that I'm currently killing.

A MS SS B MG MB are the static defense spells that should always be up.
my thought process was going to be two triggers... Protections: (*) T: and Protections: ~*I15~* (*) T:


I'm guessing some type of Regex would make things easier, but my scripting isn't that good.


Any suggestions? Please and Thanks.


Last edited by atheaker on Thu Feb 07, 2013 3:23 pm; edited 1 time in total
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Feb 07, 2013 2:09 pm   
 
The explanation of what you want is not very clear, so I will describe what I think you want so you can confirm it.

You get lines from the mud that look like: <optional stuff> Protections: <more stuff> T: <other stuff>
<more stuff> can contain A, MS, SS, B, MG, and MB
If those strings are not in <more stuff> you want to recast a spell

As far as I can tell, you only need one trigger, and the one you've got should be fine. You don't need to worry about the optional *I15*. Just change your trigger to the following (note that I am using a local variable $def instead of a global variable @def):
Code:

<trigger priority="14920" id="1492">
<pattern>Protections:(*)T:</pattern>
<value>$defs = %1
#IF (%pos(" A ", $defs)=0) {cast armor}
#IF (%pos(" MS ", $defs)=0) {cast whatever}
#IF (%pos(" SS ", $defs)=0) {cast whatever}
#IF (%pos(" B ", $defs)=0) {cast whatever}
#IF (%pos(" MG ", $defs)=0) {cast whatever}
#IF (%pos(" MB ", $defs)=0) {cast whatever}
</value>
</trigger>

What is not clear to me in your explanation is whether you care about ST or the I15. Based on what you say, I'm assuming that you don't care about them. If you do need to keep track of them, you will have to explain what you want to happen.
Reply with quote
atheaker
Newbie


Joined: 10 Dec 2011
Posts: 9

PostPosted: Thu Feb 07, 2013 2:28 pm   
 
Yes you are correct, *I15* and ST are not important... sorry if I wasn't fully clear.

The method I'm using atm, doesn't seem to work, and if I switch the #if statement to use @def variable it fires every round, and when using one the the #if lines you've suggested I get an error message for using $def.

#IF (%pos(" A ", @defs)=0) {cast armor}
This fires every round.


#IF (%pos(" A ", $defs)=0) {cast armor}
This creates an error.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Feb 07, 2013 2:33 pm   
 
Did you also switch the $def=%1, as I had in my example?

Yes, this trigger will fire every round--you did say that you get this message every round, right? If you don't want it firing every round, what _do_ you want?
Reply with quote
atheaker
Newbie


Joined: 10 Dec 2011
Posts: 9

PostPosted: Thu Feb 07, 2013 3:23 pm   
 
Ahh ok, I see where I messed up.... Works perfect, Fires off my defense spells only when they are not displayed....

Thanks a bunch...
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