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


Joined: 15 Mar 2006
Posts: 9

PostPosted: Wed Mar 15, 2006 5:09 pm   

Basic Trigger help.
 
Hi.

Freely confessed, I'm a coding idiot, and I could use some help with this.

What I'm trying to do is set up a series of triggers to heal an affliction IF I am currently able to eat the healing crystal.

I'm using the dialogue boxes rather than the command line to set these things up, so I'll use the term 'Pattern' to show what text is used to fire the trigger and the term 'Value' to designate the actions I'm asking it to do.

The trigger to toggle the affliction variable to on is:

Quote:


Pattern: * causes you to fume with his off color references to

Value: #var taunt 1


This works fine, but it just occurs to me now as I type this that it would probably be better if I can figure out a way for it to work for both 'his off color...' and 'her off color...', I'm thinking another * in place of 'his' will fix that? Will test, either way, I can just make another trigger. The real problem comes here:

Quote:


Pattern: @taunt=1

Value:
#until (!@taunt) {
#IF (!@curativebalance) {
eat maroon
#WA 500 }
}


There are triggers that similarly set curativebalance to 1 or 0, depending on whether or not I can eat another curative. The problem here is that the trigger simply does not fire. There's something wrong with how I've phrased the pattern, I'm sure, but I don't know how to get it to fire off an expression rather than text from the MUD (Having tested useing the #sh command, it DOES fire when I type #sh @taunt=1).

If I'm shown how to structure it so that it checks the expression rather than looking for it in recieved text.

Any help will be greatly appreciated.
_________________
Breathe on.
Reply with quote
Carabas
GURU


Joined: 28 Sep 2000
Posts: 434
Location: USA

PostPosted: Wed Mar 15, 2006 6:11 pm   
 
---
Pattern: * causes you to fume with {his|her} off color references to

Value: #var taunt 1
---
Pattern: @taunt

Value:
#IF (!@curativebalance) {
eat maroon
#WA 500 }
---
Expression triggers fire when the expression evaluates to true. Since 1 is true, and 0 is false, all you need is @taunt as the pattern. You should also reconsider the use of #WAIT.

Timers, Alarms, and the WAIT command.
_________________
Carabas
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Mar 15, 2006 6:23 pm   
 
The problem is you can not trigger on a variable condition, you trigger on MUD text received. You may consider adding it to your prompt trigger (another trigger that matches on the prompt but is only active while you're fighting.)

As for you other trigger,

Code:
Pattern: * causes you to fume with {his|her} off color references to


should work.
_________________
Asati di tempari!
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Mar 15, 2006 6:23 pm   
 
Carabas, you beat me to it... with color to boot.
_________________
Asati di tempari!
Reply with quote
Ranaven
Newbie


Joined: 15 Mar 2006
Posts: 9

PostPosted: Wed Mar 15, 2006 6:26 pm   
 
Thanks a lot Carabas, that did solve the problem...

Unfortunately, with:

Pattern: @taunt

The trigger loops infinitely, regardless of the value of taunt.
_________________
Breathe on.
Reply with quote
Carabas
GURU


Joined: 28 Sep 2000
Posts: 434
Location: USA

PostPosted: Wed Mar 15, 2006 7:45 pm   
 
Yeah, I can see why you may be experiencing a loop. You may need to add another check variable or perhaps change the value of @taunt to zero more quickly.

If you do not need @taunt for any other reason, then I don't see why this won't work just fine.

#IF (!@curativebalance) {
#VAR taunt 0
eat maroon}

The @taunt trigger should fire (if @taunt is set to 1) until @curativebalance is no longer true itself. At that point @taunt will immediately be set to 0 (false), eat maroon will be sent to the MUD, and the trigger will not fire again until @taunt is set to 1 (true) again.

If eat maroon could fail, you could add another trigger that would set @taunt back to 1.

#TRIGGER {eat maroon failed} {#VAR taunt 1}

Then the @taunt would fire again.
_________________
Carabas
Reply with quote
Ranaven
Newbie


Joined: 15 Mar 2006
Posts: 9

PostPosted: Thu Mar 16, 2006 5:34 pm   
 
Having tested the problem remains:

Variable name: Taunt
Value: 0

The trigger is still firing. Every half second.

So what I'm thinking is...

Using:

Pattern :@taunt

The trigger fires regardless of the value of taunt, and it fires for as long as the variable simply exists.

It doesn't seem to matter if @taunt is 1 or 0. I've tried turning off triggers and manually setting @taunt to 0 and it still fires when I turn on triggers again.

If it helps, I'm using version 7.21
_________________
Breathe on.
Reply with quote
Vorax
Apprentice


Joined: 29 Jun 2001
Posts: 198
Location: USA

PostPosted: Thu Mar 16, 2006 6:54 pm   
 
Code:
#TRIGGER {(@taunt)} {#IF (@taunt) {#IF (!@curativebalance) {#VARIABLE taunt 0;eat maroon}}}

Expression triggers fire whenever the value of the variable changes (it doesn't matter if it changes from 1 to 0 or vice versa), so you should check the value of the variable again to see if it is 1 or 0 inside the trigger.
Reply with quote
Carabas
GURU


Joined: 28 Sep 2000
Posts: 434
Location: USA

PostPosted: Thu Mar 16, 2006 6:56 pm   
 
Make certain that you do not have any other variables of the same name in any other classes. I've tested this on my end, and the trigger does not fire if the variable is set to zero.
_________________
Carabas
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Mar 16, 2006 7:07 pm   
 
First off... setting the pattern to @Taunt will trigger on what ever value @Taunt currently contains... i.e. if it's set to 1 it will fire whenever 1 occurs and likewise for 0.

Try this.
Code:
#TRIGGER {* causes you to fume with {his|her} off color references to} {#VAR Taunt 1; #T+ Taunt}
#TRIGGER  "Taunt" {**Your Prompt HERE**} { #until (!@Taunt) {
  #IF (!@curativebalance) {
    eat maroon
    #WA 500
    } {
    #echo hear
    #VAR Taunt 0
    #T- Taunt
    }
  }}
_________________
Asati di tempari!
Reply with quote
Carabas
GURU


Joined: 28 Sep 2000
Posts: 434
Location: USA

PostPosted: Thu Mar 16, 2006 8:00 pm   
 
Tech wrote:
First off... setting the pattern to @Taunt will trigger on what ever value @Taunt currently contains... i.e. if it's set to 1 it will fire whenever 1 occurs and likewise for 0.


Tech, I'm sorry, but that is simply not true for an expression trigger. It will only fire if the expression (pattern) evaluates to true.

However, if the trigger type is set to anything other than Expression, then you are correct.

zMUD Help File wrote:
Expression triggers evaluate the expression stored in the Pattern field whenever a is changed and execute the commands if the pattern expression is true.


As I have said previously, it works on my end. All expression triggers seem to execute whenever any variable changes. So, yes, the @taunt trigger will continue to fire until @taunt no longer evalutes to true (set to 0). If you chose to use an expression trigger in this way, then you need to set the value of that variable back to 0 (false) as soon as possible, or it will continue to fire every time any variable is changed.
_________________
Carabas
Reply with quote
Carabas
GURU


Joined: 28 Sep 2000
Posts: 434
Location: USA

PostPosted: Thu Mar 16, 2006 8:04 pm   
 
Ranaven, also make sure the the trigger type for the @taunt trigger is set to Expression. If it is set to Pattern, then it will fire when ever a 1 or 0 is output from the MUD (or echoed to the screen), just as Tech suggested it would.
_________________
Carabas
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Mar 16, 2006 8:29 pm   
 
Thanks for the correction Carabas... i didn't have my trigger type set to expression. I see I am still a sophomore when it comes to zMUD. But I'll start using it now. Very Happy
_________________
Asati di tempari!
Reply with quote
Carabas
GURU


Joined: 28 Sep 2000
Posts: 434
Location: USA

PostPosted: Thu Mar 16, 2006 8:50 pm   
 
Not a problem at all. I think Expression triggers are one of those seldomly used features that tend to confuse people. I sometimes think of them as if-then statements without the else. Wink
_________________
Carabas
Reply with quote
Ranaven
Newbie


Joined: 15 Mar 2006
Posts: 9

PostPosted: Fri Mar 17, 2006 12:34 pm   
 
Carabas, thou art a saviour.

That was the problem right there, it wasn't set to expression type.

Thanks a lot, and you too Tech.

Problem solved.
_________________
Breathe on.
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