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


Joined: 28 Aug 2003
Posts: 25
Location: USA

PostPosted: Fri Jan 30, 2004 6:58 am   

Cannot get #IF command to work....
 
It's my first time trying to use #IF commands.

I just got this from another topic:

#if @HP<@lowhp {get @food;eat @food} "Prompt"

I already had a prompt trigger, so it wasn't that hard to make... or so I thought.

Just for referance I also put in:
#if {@HP<@lowhp} {get @food;eat @food}

and

#if {@HP < @lowhp} {get @food;eat @food}

still none of them worked.

What happened at first is, it would actually just skip the #if part, and put in the execution (get food, eat food)

Then I took out the "Prompt" thing, and it wouldn't fire the "get food, eat food" thing, but I would not be able to find the trigger anywhere, and it would not work.

#CLASS {Prompt}
#VAR HP { 20}
#VAR SP { 90}
#VAR maxhp {114}
#VAR maxsp {90}
#VAR lowhp {45}
#VAR food {fillet}
#TRIGGER {^HP: &HP SP: &SP$} {}
#CLASS 0

My prompt trigger -does- work. Actually, it's technically not a prompt trigger, because it triggers off of a special prompt that only comes up when you fight (like when you get hit at least). So every time I get hit (when I actually need this thing to work) it changes my @HP Var etc. I added in the @lowhp so I could try using someone else's #if command, since I couldn't figure out how to do a percentage of my Maxhp... samd end-product.

The main problem is, I just can't even get this #if command started. Even if I could get Zmud 6.62 to actually save the #if command, whether it worked to some place in the folders I can look at it, that'd be start.

Do I need to reinstall Zmud? I cannot find this problem in anyone else's (recent) topic.
Reply with quote
Kendrick
Beginner


Joined: 28 Aug 2003
Posts: 25
Location: USA

PostPosted: Fri Jan 30, 2004 7:13 am   
 
Ok I put it into my prompt trigger, and I think it's fixed. Only now, it does work, but it works early... like as soon as I get hit, even if it's not below 45...but I can fix that probably.
Reply with quote
Yvves
Newbie


Joined: 29 Nov 2003
Posts: 9
Location: USA

PostPosted: Fri Jan 30, 2004 7:17 am   
 
Okay, lets say your prompt is
HP: XX SP: XX

You'd need to create the following trigger

#TRIGGER {^HP: @HP} {#IF {@HP < 45} {get @food;eat @food}}

However, you will have the problem of spamming eating food, since you won't do it the second the command is entered. I'd suggest this ->

#CLASS {autofood}
#TRIGGER {^HP: @HP} {#IF {@HP < 45} {#T- autofood;get @food;eat @food;#T+ autofood}}
#CLASS 0

Which will check to see if your hp is below 45, if it is, it will turn off the class (so the trigger doesnt fire anymore), get @food, eat @food, then turn the class back on, so it can check again.

I'm also assuming you have @food already specified, but with this, it would be just as easy to say 'get meat pack;eat meat' or what have you, since you wont be typing it anymore.

~Yvves
Reply with quote
Kendrick
Beginner


Joined: 28 Aug 2003
Posts: 25
Location: USA

PostPosted: Fri Jan 30, 2004 7:45 am   
 
Still can't get it to work... I've tried many things. My friend is helping me too, and either the trigger always fires, or doesn't work at all.

I tried your suggestions and it won't work at all. I even fixed a syntax error that came with it, and still no luck.

#CLASS {Prompt}
#VAR HP { 64}
#VAR SP { 90}
#VAR maxhp {114}
#VAR maxsp {90}
#VAR lowhp {45}
#VAR food {fillet}
#TRIGGER {^HP: @HP} {#IF (@HP < 45) {get @food;eat @food}}
#CLASS 0
Reply with quote
Yvves
Newbie


Joined: 29 Nov 2003
Posts: 9
Location: USA

PostPosted: Fri Jan 30, 2004 7:50 am   
 
#CLASS {prompt}
#TRIGGER {HP: (@HP)} {#IF (@HP < 45) {get @food;eat @food}}
#CLASS 0

Forgot the parenthesis.
Reply with quote
Kendrick
Beginner


Joined: 28 Aug 2003
Posts: 25
Location: USA

PostPosted: Fri Jan 30, 2004 8:04 am   
 
Ok still doesn't work... I think it was because you triggered @Hp instead of &Hp.. that's why it would cease to even fire...

But I fixed that, still no deal. Back to the "heal everytime I get hit no matter what" trigger... *sigh*... Is it a spacing problem? HP:*100 and HP:**50 for example (*=space)
Reply with quote
Yvves
Newbie


Joined: 29 Nov 2003
Posts: 9
Location: USA

PostPosted: Fri Jan 30, 2004 8:27 am   
 
yes, I am a moron who needs either caffiene or sleep. So many damn typos.

If A) the spaces between hp and the number changes,
but B) you only need to heal when there's two spaces,
then c)

#TRIGGER {HP:**(&HP)} {#IF (@HP < 45) {get @food;eat @food}}

** = double space
I should sleep. ;)
Reply with quote
Kendrick
Beginner


Joined: 28 Aug 2003
Posts: 25
Location: USA

PostPosted: Fri Jan 30, 2004 8:41 am   
 
I should sleep too.. I'll check the trigger tommorow, and thanks for your help. No worries on the typos
Reply with quote
Valint
Wanderer


Joined: 12 Nov 2003
Posts: 70
Location: USA

PostPosted: Fri Jan 30, 2004 3:16 pm   
 
Try:

#TRIGGER {HP:%s&%dHP} {#IF (@HP<45) {get @food;eat @food}} "" {nocr|prompt}

The last set of options defines this as a prompt trigger, not waiting for a newline character.

Depending on how prompts work on your mud, however, you may find the #SETPROMPT command useful. Also, depending on how prompts work on your mud, you may find it necessary to name the trigger and have it disabling while eating and turned back on when finished, to avoid it firing multiple times if your get/eat command cause multiple prompts to be displayed.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Jan 30, 2004 5:46 pm   
 
Your problem is probably related to the use of the &HP pattern. Because it matches everything, this will include any extra spaces and extra spaces will change the variable from a number to a string. When the variable is a string, the comparison done by #IF will be a string comparison, which usually will produce unexpected results.

Valint's trigger pattern fixes this by specifying the %d wildcard, so that @HP will be limited to numerical digits and will always be a number.
Reply with quote
Kendrick
Beginner


Joined: 28 Aug 2003
Posts: 25
Location: USA

PostPosted: Fri Jan 30, 2004 11:57 pm   
 
Suprise suprise...still doesn't work... that trigger won't actually pick up my prompt numbers.

I tried to make the prompt pick up on SP too... still didn't work. Here's my non-working Prompt stuff... and btw, the prompt I'm triggering off of only shows up when I get hit, so the spam-thing doesn't matter.

#CLASS {Prompt}
#VAR HP { 95 SP: 90}
#VAR SP { 90}
#VAR maxhp {114}
#VAR maxsp {90}
#VAR lowhp {45}
#VAR food {fillet}
#TRIGGER {^HP:%s&%dHP SP:%s&%dSP} {#IF (@HP<45) {get @food;eat @food}} "" {nocr|prompt}
#CLASS 0

Yes I made changes, but I tried it without changing it first.
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Sat Jan 31, 2004 12:13 am   
 
Please write down a copy of the mud prompt so that it can be tested against the trigger. Thanks.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Jan 31, 2004 12:19 am   
 
First step is check to see if the trigger is firing. This is most readily done by making another trigger with the same pattern and using the #ECHO command.
#TRIGGER {^HP:%s&%dHP SP:%s&%dSP} {#ECHO Fired prompt trigger} "" {nocr|prompt}

If this doesn't fire then the problem is in the pattern. At which point it would be best if you posted a sample of your muds output within a code tag. This tag is for the forum and turns off its automatic formatting.
Code:

This is  a  code  tagged  thing.  Select
Reply with Quote from the top of my post
to    see    how     it     is     done.
Reply with quote
Kendrick
Beginner


Joined: 28 Aug 2003
Posts: 25
Location: USA

PostPosted: Sat Jan 31, 2004 12:47 am   
 
HP: 100 SP: 90
HP: 88 SP: 160
HP: 103 SP: 90

And no, the trigger he last made was not firing. I could tell because it would show up in my HP Var. My original prompt-trigger DID work and pick up on my HP and SP values. (first post)
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Sat Jan 31, 2004 12:54 am   
 
Code:

HP: 100  SP:  90
HP:  88  SP: 160
HP: 103  SP:  90

#TRIGGER {HP:%s&%dhp%sSP:%s&%dsp} {#if (@hp < 10) {say matched}}

Make it trigger on newline and prompts. As you see the issue was that there's two spaces between the HP and the SP Smile so %s is needed between them.
Reply with quote
Kendrick
Beginner


Joined: 28 Aug 2003
Posts: 25
Location: USA

PostPosted: Sat Jan 31, 2004 2:41 am   
 
Thanks... I put the spacing in like you did, but it didn't put into my post. How do you set it to post correctly?
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Sat Jan 31, 2004 10:51 am   
 
quote:
Originally posted by Kendrick

Thanks... I put the spacing in like you did, but it didn't put into my post. How do you set it to post correctly?




Like Viljante said you use the code tag. Like this:
[code]
Here goes the pattern
[/code]
Reply with quote
Kendrick
Beginner


Joined: 28 Aug 2003
Posts: 25
Location: USA

PostPosted: Sun Feb 01, 2004 12:40 am   
 
Ok the trigger works. It takes a couple prompts to fire though. But I've always run into this before. Like when I made a HP-MANA bar in Achaea, it always took a couple prompts to update the bar. Instead of one. Is this an option I can change? Or is it always like that?

That aside, I'm satisfied with it. If it's going to take two-prompts, I can just up the damage-time from 45, to 65.

And thank you for all the endless amounts of help. It took long enough, but we made it. THanks. It's useful coding like this that I can apply to just about any mud, so it really does help.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Feb 01, 2004 3:03 am   
 
Are Newline and Prompt selected in the prompt trigger options?
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