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


Joined: 25 Apr 2008
Posts: 6

PostPosted: Fri Apr 25, 2008 2:08 pm   

Problem with #IF Statment
 
I am trying to write a script that will check my current tnl and if it is within a certain range then it should equip my status affecting gear. It works except that it repeats endlessly. How do I write this to makes sure that it will only execute once?

Looks like this:

//Declaring variable xpTnl
#var xptnl 0;
//Trigger to check
#trigger xpCheck {(*)<(%d)/(%d)hp (%d)/(%d)mp (%d)/(%d)mv (%d)xp>} {xpTnl = %8;#if (xpTnl < 200) {levelGear}{} }

Ok, so essentially this works. BUT because it is a trigger it executes endlessly so long as that evaluates as true. I need to know how to get this to evaluate and execute one time. I have thought about adding an "emote wears his levelgear." and then drafting a conditional trigger to fire if that happens but after that I am stuck. So do you have any suggestions?
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri Apr 25, 2008 2:14 pm   
 
This is a relatively common problem with a fairly simple solution.

#if ((xpTnl < 200) and (@levelGearOnce==0)) {levelGear;levelGearOnce=1}
#if ((xpTnl > 200) and (@levelGearOnce==1)) {levelGearOnce=0}
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
elucid8
Newbie


Joined: 25 Apr 2008
Posts: 6

PostPosted: Fri Apr 25, 2008 2:25 pm   
 
Thanks Arminas. I didn't even think about making a second variable doing a if and. Thanks!
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