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
Delphi03
Novice


Joined: 20 Aug 2004
Posts: 37
Location: Illinois

PostPosted: Tue Sep 07, 2004 1:16 am   

Timed, Triggered Loops And More
 
Hello all. I have a couple of questions, mainly a loop question and then some (hopefully) simple ones, so I don' think I need to make more than one topic for it all.

1.) In the MUD I'm playing, after you do something (attack, cast a spell, change stance, forge equipment) you have to spend some time offbalanced. The MUD sends the data to me in the format:

Code:
^%s%d.%d%s(%d)


So, whenever I do something, the last number is set to my offbalance time. This is what I'm trying to do:

Code:
#VA offbalancemax %1
#VA offbalance %1 -------------------> I've also done #VA offbalance @offbalancemax

#WHILE (@offbalance >= 0) {#ALARM +1 {#MATH offbalance {@offbalance-1}}}
#GAG 0
*****OR*****
#WHILE (@offbalance >= 0) (#ALARM +1 {#ADD offbalance -1}}
#GAG 0


Now, when this trigger is tripped, it starts out fine by setting offbalance to %1 (eg: 5) and it starts counting down, only it's going 300mph and doesn't stop at zero. It goes to -800 something, then starts again from 5 down, then it'll just start going towards negative infinity. I don't know if it's my loop statement, or if it's something with the variables, or the #ALARM +1 (I want it to subtract 1 from offbalance for every second that goes by). Anyone have any ideas?

2.) Using %replace to fix my color issue still, but I'm running into problems with the MUD sends a double-quote (") to me, seems to mess up the parsing, and shows some pretty ugly stuff on my screen. Is there anyway I can fix that, or use #CW inside of %replace instead of %ansi ?

And for the final, newbiesh question

3.) How can I make zMUD allow me to send < and > to my MUD? every time I type it in the command line, it just disappears and never makes it to the MUD?

Thanks all in advance!
Reply with quote
Delphi03
Novice


Joined: 20 Aug 2004
Posts: 37
Location: Illinois

PostPosted: Tue Sep 07, 2004 1:50 pm   
 
Okay, I have spent a little work on this thing, and I'm still not getting it to work correctly. My new trigger code is as follows:

Code:
#VA offbalancemax %1
#VA offbalance %1
#GAG 0
#MATH offbalancemax {@offbalancemax-1}
#MATH offbalance {@offbalance-1}
#WHILE (@offbalance > 0) {#ALARM "offB" *1 {#MATH offbalance {@offbalance-1}}}
#SUSPEND offB
#VA offbalance 0


Now, this sorta works, as in removes 1 from @offbalance every second, but it never stops, ever. I can not find a way to jump out of the loop, or terminate this countdown in anyway. Perhaps someone can help me with this #ALARM/#RESUME/#SUSPEND stuff? I've also tried...

Code:
#VA offbalancemax %1
#VA offbalance %1
#GAG 0
#MATH offbalancemax {@offbalancemax-1}
#MATH offbalance {@offbalance-1}
#WHILE (@offbalance > 0) {
 #RESUME offB
 #ALARM "offB" *1 {#MATH offbalance {@offbalance-1}}
 #SUSPEND offB
 }
#SUSPEND offB
#VA offbalance 0


This causes the same results as the first, countdown by 1 ad infinitum.

If I remove the #RESUME/#SUSPEND parts from this trigger...

It will count down by 1 until it reaches zero, then it will count down by 2 starting with -2 (ie: 5 4 3 2 1 0 -2 -4 -6 -8 -10)

Any and All help is appreciated, thanks!
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Tue Sep 07, 2004 6:16 pm   
 
1. Why would you try to mix two different timing methods? If you're going to use an ALARM then there's no need for a WHILE.
Code:
 
#MATH offbalancemax (%1 - 1)
#MATH offbalance (%1 - 1)
#ALARM "offB" *1 {#IF (@offbalance > 0) {#ADD offbalance -1} {#VAR offbalance 0;#T- offB}}


2. Yes, unmatched double-quotes will mess you up. No, you can't use #CW inside %replace. No, I can't think of any way around it.

3. Use ~ before special characters when you want zMUD to treat them like normal characters.
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Delphi03
Novice


Joined: 20 Aug 2004
Posts: 37
Location: Illinois

PostPosted: Tue Sep 07, 2004 7:28 pm   
 
[EDIT]The reasoning behind the while loop was that I didn't know that an alarm was a loop (aside from repeating every second), but when I think of it, it makes more and more sense for it to be a loop.

Also, no whenever there is any input to the MUD, the gauge that these variables control will go to -1 for 1 second, and then back to zero...but works perfectly when it should be working...is this just a glitch/limitation in the scripting, or is it possible something is wrong?[/EDIT]
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