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


Joined: 19 Dec 2002
Posts: 14
Location: USA

PostPosted: Sat Dec 21, 2002 4:12 pm   

Trouble with #LOOP in 6.40
 
I'm in the process of creating a compass out of 10 buttons. I am trying to write script to highlight the available exits. I have no problem doing this for rooms with one exit. Thats because I don't need to loop through the list of directions to test for their existance. I use a huge nested #if. Probably not the most efficient way of doing things, this is my first BIG script for zMud. However, my problem is in programming a #loop to loop through the list of available exits and highlight each of those buttons. I messed around with the #LOOP statement to try and figure it out, but I just cannot do so. In testing the #loop statement, I did the following:

#loop 1,10 {#noop %btncol(%item{nw|n|ne|w|e|sw|s|se|u|d,%i},0,10)}

the string list above represents the name of each of my buttons that I declared in the ID box on the advanced tab of the button dialog.

Looking at the code, it would seem as though %i would expand to each of the 10 directions as it went through the loop. However, %i only holds the value of the very last button, and on it gets highlighted.

I was stumped for 2 hours last night, and finally went to bed at 5:15. I had to get up for work at 7:30. That being said, I am sorry if the above code isn't 100% perfect. I may have messed up the ()'s and the {}'s. zMud isn't in front of me, either, I'm going from memory. Any ideas guys?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Dec 21, 2002 7:10 pm   
 
The %btncol function uses button numbers rather than button names. And yes, you have indeed messed up the ()'s and {}'s. But if your compass buttons are in sequence, you shouldn't need to use a list since all you need is the button number. If they are buttons 1-10:
#LOOP 1,10 {#NOOP %btncol(%i, 0, 10)}
If they are buttons 7-16:
#LOOP 7,16 {#NOOP %btncol(%i, 0, 10)}

LightBulb
Senior Member
Reply with quote
sk0tto
Beginner


Joined: 19 Dec 2002
Posts: 14
Location: USA

PostPosted: Sat Dec 21, 2002 7:30 pm   
 
If the ID field uses numbers rather than names, then why did the button highlight on a room with one exit? It seems that I tried assigning them numbers, but then I had buttons highlighted that had nothing to do with the compass. I was probably over tired last night. I'll try again tonight and see what I come up with. Thank you!
Reply with quote
Iccor
Newbie


Joined: 21 Dec 2002
Posts: 9
Location: USA

PostPosted: Sat Dec 21, 2002 9:26 pm   
 
i have seen a complete script on this in the finished script forum

Iccor
Reply with quote
sk0tto
Beginner


Joined: 19 Dec 2002
Posts: 14
Location: USA

PostPosted: Sun Dec 22, 2002 12:55 am   
 
I figured it out. Apparently, zmud automatically assigns ID numbers to buttons according to the order that they were created. That's why when I was doing a loop from 1 to 10, all the wrong buttons were highlighted no matter what ID I gave them.
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