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
Aarlot
Adept


Joined: 30 Dec 2003
Posts: 226

PostPosted: Sun May 30, 2004 8:44 am   

Trigger State help
 
I've been setting up a trigger with multiple states, and I've run into a problem. This whole thing is a script to calculate rent costs, how much money i have on me, and how much in the bank, then withdraw, or deposit, the right amount. Here's my trigger so far:

Code:

#ONINPUT "Calcrent" {calcrent} {
  take all.coin @contain
  count copper
  count crowns
  put all.coin @contain
  }
#COND {There {is|are} exactly (%d) {copper|coppers|pennys|penny}.} {copperwith = %1}
#COND {There {is|are} exactly (%d) {crown|crowns}.} {
  #MATH goldwith (20*%1)
  #MATH moneywith (@copperwith+@goldwith)
  bal
  }
#COND {A banker whispers to you} {
  #IF (@moneywith = @rentcost) {#ECHO "Exactly enough!"} {
    #IF (@moneywith > @rentcost) {
      #ECHO "More than enough."
      #MATH depmoney (@moneywith - @rentcost)
      deposit @depmoney copper
      } {
      #IF (@rentcost > (@moneywith + @bankmoney)) {#ECHO "You do not have enough!"} {
        #ECHO Getting money from bank...
        #MATH extramoney (@rentcost-@moneywith)
        withdraw @extramoney
        }
      }
    }
  #VAR copperwith "0"
  #VAR goldwith "0"
  }


The problem comes in when I don't have any copper with me, or crowns with me. In either case, the mud sends "You don't seem to have that." instead of "There are exactly 12 coppers." or "There are exactly 12 crowns."

In those cases, i'd like the trigger to set @copperwith or @goldwith to zero, and then move the trigger to the next state. Is there any way to do this?

Ideally, you could have two trigger states active at the same time, with the trigger moving on if either was triggered... but i don't know any way to do that. Anyone help please?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun May 30, 2004 3:22 pm   
 
A trigger can only have one state active at a time.
You could add the phrase, with appropriate commands, to your
conditions.
You could use Loopline, with a parameter of 1, to force the trigger to
advance states.

You could use an alias with independent triggers.
#AL {calcrent} {
#VAR copperwith 0
#VAR goldwith 0
take all.coin @contain
count copper
count crowns
put all.coin @contain
#TEMP {A banker whispers to you} {
#IF ((@copperwith + @goldwith) = @rentcost) {#ECHO "Exactly enough!"} {
#IF ((@copperwith + @goldwith) > @rentcost) {
#ECHO "More than enough."
#MATH depmoney (@copperwith + @goldwith - @rentcost)
deposit @depmoney copper
} {
#ECHO "You do not have enough!"
#ECHO Getting money from bank...
#MATH extramoney (@rentcost - @copperwith - @goldwith)
withdraw @extramoney
}
}
}
bal
}
#TR {There {is|are} exactly (%d) {copper|coppers|pennys|penny}.} {#VAR copperwith %1}
#TR {There {is|are} exactly (%d) {crown|crowns}.} {#MATH goldwith (20 * %1)}
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