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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
DrkLazarus
Newbie


Joined: 25 Jan 2003
Posts: 1

PostPosted: Sat Jan 25, 2003 5:59 am   

Desperately Need Trigger Check
 
As you can see by the title, I need my triggers checked. None of the other MUDders can help me, so I'd like you guys to tell me if they'll work. There are 3 of them, and they are supposed to heal when hp falls below a certain value (25% of Max). Here they are:

1: This one places current hp value into memory #TRIGGER {Hp: &HpVar}

2: This one places max hp value into memory #Trigger {MHp: &MHpVar}

3: And this one checks those values with an if statement and heals if conditions are right. #If (&HpVar < 25% &MHPVar) {starsign}

Note: The third trigger should input the command starsign to the mud when hp falls below 25% of max hp. Are these triggers correct? I don't want to risk it without knowing for sure.

Thanks! ~DrkLazarus
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Sat Jan 25, 2003 6:39 am   
 
Careful how you implement it. See Lightbulb's comment about looping things
due to prompts here. Else you'll spam starsign to the mud.


The check for your hitpoints should be:


#IF ((@HpVar*100/@MHPVar) <= 25) {
#NOOP More needed here than starsign see reference above
}



Ton Diening
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Jan 25, 2003 11:51 pm   
 
Since &VarName is the equivalent of an * wildcard, you'll get a string variable instead of a number variable if there's anything else at the end of the line (possibly even trailing spaces). I've used the &VarName syntax occasionally, but strongly prefer using standard wildcards in the pattern with #VAR commands in the value because it's easier to see what I'm doing that way. If you are getting these values from a prompt, you'll also need to change the Trigger On options from Newline to Prompt.

In other words:
#TRIGGER {Hp: &HpVar}
#Trigger {MHp: &MHpVar}

Line from MUD:
Hp: 107 MHp: 217

Variables:
HpVar = "107 MHp: 217"
MHpVar = 217

LightBulb
Senior Member
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Jan 26, 2003 12:49 am   
 
The &varname syntax can also be restricted to any other wildcard besides *. Example:
#TRIGGER {Hp: &%d{HpVar}} {...}

Now:
Hp: 107 MHp: 217

makes @HPVar equal to 107 and not "107 MHp: 217".

However, like LightBulb mentioned, this is a more advanced syntax and it is not as easy to see what is happening as matching with a normal wildcard and then storing it in a variable.

Kjata
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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