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


Joined: 18 Nov 2007
Posts: 28

PostPosted: Thu Nov 29, 2007 1:38 pm   

%numrooms() questions!
 
i need to traversing all the rooms in a zone to find a NPC and do something, i had read the zmud's help files, it tell me the %numrooms() function can retune the number of the rooms in the zone. infact it return the number of the rooms all the map,
how can i do?

thank you very much!
Reply with quote
Tech
GURU


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

PostPosted: Thu Nov 29, 2007 1:53 pm   
 
I think you misunderstood the documentation mines says
Quote:
numrooms

Syntax: %numrooms()

Return the number of rooms in the current map filter.


Now you can establish a %mapfilter i.e. a SQL query string to the mapper to DB to only reference a particular zone. But you have to set it up.
_________________
Asati di tempari!
Reply with quote
killunix
Beginner


Joined: 18 Nov 2007
Posts: 28

PostPosted: Thu Nov 29, 2007 2:43 pm   
 
thank you very much!
very good!
but another question:
i use the #loop command to search NPC, when i found it, how can i end the loop and do other commands?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Nov 29, 2007 3:17 pm   
 
The #abort command is used to break loops.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
killunix
Beginner


Joined: 18 Nov 2007
Posts: 28

PostPosted: Thu Nov 29, 2007 3:29 pm   
 
i used the code:

#var test 1
#CALL %mapfilter(%concat("ZoneID = ",%zonenum(testzone)))
#LOOP %numrooms {
#show %roomnum( %mapvnum( %i))
#math test (@test+1)
#if (@test>5) {#abort}
}
#CALL %mapfilter("")

i need echo 5 rooms int the zone,but it can't work, what's the problem? thanks
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Nov 29, 2007 3:56 pm   
 
Because the #abort is only aborting the current block, the #if command. You need to use #abort 1 to abort the entire script (which will stop any command after the #loop being run as well - you'll need to find a way around that, like adding the commands to a one-time alarm that's created before the loop is run).

But why be hard on yourself?

#loop 5 {#show %roomnum( %mapvnum( %i))}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
killunix
Beginner


Joined: 18 Nov 2007
Posts: 28

PostPosted: Thu Nov 29, 2007 4:33 pm   
 
dir fang,
are you chinese? the #show command just for test, i will use the #walk command go to the target room
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Nov 30, 2007 3:34 am   
 
Nope, just light-fingered when it comes to foreign phrases :)

One option could be to use the #additem command to add the room numbers that the loop returns to a string list. Then you can walk to each of them at your leisure by returning an item from the list with %item or %pop.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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