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


Joined: 30 May 2002
Posts: 25
Location: USA

PostPosted: Tue Jun 15, 2004 4:29 am   

Help with two different triggers...
 
I'm trying to figure out how to do a couple triggers, and both have me completely stumped.

The first isn't any particular trigger, but I'm trying to parse a number in a trigger patern and save it as a variable. Normally this wouldn't be hard--saving a variable is no problem--except this number is displayed from the game with commas and periods, such as: 1,234,567.90. This wouldn't be a problem, either, except that the number can vary from in the billions to single digits. Is there any way to parse a number without capturing commas, since commas turn it into a text string?

The next trigger might be extremely simple and I'm oblivious. Sometimes the game outputs duplicate lines, on purpose and in immediate succession. I'd like to #GAG one of the two lines each time. The duplicate lines vary in content, otherwise I would just make a trigger for each type of line. I've tried using the pattern ^(*)$^(*)$ and an #IF to test if the two lines are the same, but that doesn't work. Any ideas?

Edit: Okay, I lied. One more little trick. I occasionally have to wait a certain number of seconds to be able to do something, and the game tells me so by saying "You have to wait XX seconds before you can do that." So I set up a trigger with that phrase as its command and with XX replaced by (%d) to capture the number of seconds. I then have a command "#WAIT +(%1 * 1000);#BEEP" which beeps at me when the time is up, but I would also like to set up a gauge using %secs or %ctime. Any ideas?
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Tue Jun 15, 2004 5:26 am   
 
First don't use #WAIT in triggers (read the link in sig line) use and Alarm

#TR {You have to wait (%d) seconds before you can do that.} {#ALARM "wait" {+%1} {#BEEP}}
The gauge part of your question has been asked an answered recently do a search for it

For the Gagging dup lines this should work
#TR {^(*)$(*)} {#IF ("%1"="%2") {#GAG}}

for Numbers with Commas you can use (%n) //You will lose the numbers after the decimal though
Reply with quote
McGravin
Beginner


Joined: 30 May 2002
Posts: 25
Location: USA

PostPosted: Tue Jun 15, 2004 6:12 am   
 
quote:
Originally posted by nexela
#TR {You have to wait (%d) seconds before you can do that.} {#ALARM "wait" {+%1} {#BEEP}}
The gauge part of your question has been asked an answered recently do a search for it


I did search for related threads, and nothing helps me do what I'm trying to do. There are a couple posts dealing with gauges and time-based variables, but they don't provide me with any insight beyond what I already have.

quote:
Originally posted by nexela
For the Gagging dup lines this should work
#TR {^(*)$(*)} {#IF ("%1"="%2") {#GAG}}


This doesn't work, since it appears to be matching the strings "%1" and "%2", rather than the values stored in %1 and %2. If I take out the quotes, the duplicate lines continue while other, non-duplicate lines are gagged.
Reply with quote
Aarlot
Adept


Joined: 30 Dec 2003
Posts: 226

PostPosted: Tue Jun 15, 2004 6:31 am   
 
I made a timer script that creates a gauge for the countdown automatically... you could use that for the waiting thing:

Code:

#CLASS {Timers}
#ALIAS timeron {
  #MATH secsleft (@timermin*60 + @timersecs)
  #BUTTON 5 "@secsleft" {} {} {} {@secsleft} {} {} {Size} {160} {23} {} {} {} {32812} {} {Gauge||12|@timermin*60+@timersecs|5|0} {} "Timers|Timerbuttonclass" {Explore|Inset} {} {Countdown}
  #T+ update
  }
#ALIAS timeroff {
  #DELCLASS Timers|Timerbuttonclass
  #T- update
  }
#ALIAS stopt {#T- update}
#ALIAS startt {#T+ update}
#VAR timermin {0}
#VAR timersecs {0}
#VAR secsleft {0}
#ONINPUT {timer (%d)m (%d)s} {
  timermin = %1
  timersec = %2
  #IF (@timersec > 60) {
    #UNTIL (@timersec < 60) {
      #ADD timermin 1
      #ADD timersec -60
      }
    }
  #GAG
  #ECHO Timer now at @timermin minutes and @timersec seconds.
  }
#ALARM "update" {1} {
  #IF (@secsleft>0) {#ADD secsleft -1} {
    #BEEP
    timeroff
    }
  } "" {disable}
#ONINPUT {timer (%d)s} {
  timersec = %1
  timermin = 0
  #GAG
  #ECHO Timer now at @timermin minutes and @timersec seconds.
  }
#CLASS 0


Then you just make a trigger:

#TR {You have to wait (%d) seconds before you can do that} {timer %1~s;timeron}

Though if you have more than one of these running at the same time, you'd need to modify it.
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