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


Joined: 19 Dec 2010
Posts: 10

PostPosted: Mon Jul 15, 2013 11:03 am   

Triggering on the value of multiple variables.
 
Im capturing mobs into different variables that look like this; @target1, @target2, @target3..and so on until @target20.
For example when I walk into a room with a guard and servant. The guard will add a value of 1 to @target1 and the servant to @target2.

#tr {A guard is here.} {target1 = @target1 + 1}
#tr {A servant is here.} {target2 = @target2 + 1}

Instead of firing my kill trigg every time I move into another room I would like to have it fire only when the value of any of the 20 target variables is greater then 0.

I tried this:
#IF (@target[1-20] > 0) {autowhack}
Im definitly not using this range expression correctly because its not working, and as Im writing this a thought occured. How would I make a variable that contains the value of the target variables?

@targetgroup = @target1 + @target2 + @target3....and so on?

Then I could use: #IF (@targetgroup > 0) {autowhack}

Any ideas and hints will be greatly appreciated. Even if it seems to be taking me in another direction.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Mon Jul 15, 2013 5:58 pm   
 
#tr {A guard is here.} {target1 = (@target1 + 1)}

you need the parenthesis to perform math on the variables i believe
_________________
Discord: Shalimarwildcat
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Jul 15, 2013 9:29 pm   
 
Range expressions are only for trigger patterns, and you cannot put zscript commands like #if into a pattern (you can put functions in there, but none of the trigger pattern wildcards are allowed to go inside the function).

If you only want the first occurrence to fire, you could use a #loop with a datarecord variable:

Code:
#loop 1,20 {
  #if (@target.%i > 0) {
    autowhack @target.%i
    #break
  }
}
_________________
EDIT: I didn't like my old signature
Reply with quote
savus
Beginner


Joined: 19 Dec 2010
Posts: 10

PostPosted: Mon Jul 15, 2013 10:16 pm   
 
Thanks for the quick responses guys. Im not having any trouble adding the value to an @target or firing on one target at a time. My question is after I walk into a room and all mobs are assigned to their variable is it possible to set up a trigger that will fire only if there is value greater than zero to any of the 20 @target variables?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Tue Jul 16, 2013 6:53 am   
 
Add it to the incrementing trigger


target1 = (@target1 + 1)
#IF (@target1>0) {smack target1}
_________________
Discord: Shalimarwildcat
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