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


Joined: 29 Oct 2001
Posts: 250

PostPosted: Fri Apr 05, 2002 2:28 am   

%read help
 
Ok, I got this script to read a text file and search for speedwalks to areas in my mud, but list is so darn long, I tend forget the keywords to certain areas. I have an alias set up to list all the speedwalks, with their keywords, but as I said, its a long list. What I need help with is trying to make markers to sperate it alphabetically, so that when I use the 'swlist' alias I could do 'swlist r' and have it return just the 'r' section of the list. Any suggestions?Also take note of the format I use when displaying the list, which is #ECHO @{swtitle}: @swname which will return it in this format:
Lost City of Atlantis: atlantis
Town of Solace: solace

Now for the script:
#CLASS {SWStuff}
#ALIAS swfile {swfname=%1}
#ALIAS swtell {
getsw %1
#IF (@swexist) {tell %2 @swtitle= @swinfo}
}
#ALIAS swlist {
swname=""
swnum=1
#FILE 1 @swfname
#WHILE (@swname != "end") {
swname=%read( 1, @swnum)
#IF (@swname != "end") {
#ADD swnum 1
swtitle=%read( 1, @swnum)
#ADD swnum 2
#ECHO @{swtitle}: @swname
}
}
#CLOSE 1
}
#ALIAS runto {
enter
getsw %1
#if (@swexist) {
#ECHO Running to @swtitle
#LOOP 1,%numwords( @swinfo, ";") {%word( @swinfo, %i, ";")}
}
}
#ALIAS getsw {
swname=""
swnum=-2
#FILE 1 @swfname
#WHILE (@swname != %1 & @swname != "end") {
#ADD swnum 3
swname=%read( 1, @swnum)
}
#IF (@swname != "end") {
#ADD swnum 1
swtitle=%read( 1, @swnum)
#ADD swnum 1
swinfo=%read( 1, @swnum)
swexist=1
} {
#ECHO Speedwalk %1 doesn't exist in @swfname
swexist=0
}
#CLOSE 1
}
#CLASS 0
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Apr 05, 2002 12:01 pm   
 
I would suggest getting all the names, into a list (ADDITEM). Then use FORALL %sort(@nameslist) {#IF (%begins(%i,"%1") {do display stuff}}

Then you can have em displayed alphabetically, and can use more then one letter for your key.
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Fri Apr 05, 2002 4:28 pm   
 
Hmmm, that would be difficult, because my current list only stores the info for a fraction of a second, and is prompted by the file itself where it needs to end. In order to store it all into a variable, it would have to be record var, storing both a sw.swtitle and sw.swname, and then gettinf it to return properly, I just dont know how to do that
Reply with quote
Drevarr
Beginner


Joined: 19 Dec 2001
Posts: 17
Location: USA

PostPosted: Fri Apr 05, 2002 8:59 pm   
 
#alias findkey {
#file 1 My_Paths.txt
#gag
#var check %grep(1, "^%1")
#if %null(@check) {#show No Match Found!}{
#show Items Matching Search
#FORALL @check {#show %i
}
#close 1
#gag
}

Assumes each line in your file starts with the keyword. The grep pattern uses the start
of line marker, so "findkey lo" should return all lines in the file starting with lo and
display them.

Could also use this to get the path if you keyword are unique enough.

This is all typed offline at work, but I utilize the same sort of thing to dole out
equipment stats in a similiar fashion
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Sat Apr 06, 2002 5:37 am   
 
ok, let me explain what the text file looks like, it doesnt have all the fields i need in one line, it has them in a progressive order like this:

atlantis ///keyword = @swname
Lost City of Atlantis ///area name = @swtitle
run 2s3e;op east; blahblah /// command sent = @swinfo
solace
Town of Solace
run 2s3wblahblah
end ///tells the loop to stop when using swlist
end
end

and the script just returns all this info and formats it depending on the command like this:

swtell solace bob
tell bob Town of Solace= run 2s3wblahblah

or

runto solace
Running to Town of Solace
run 2s3wblahblah

or
swlist
Lost City of Atlantis: atlantis
Town of Solace: solace

So you see, the above scripts could be usefull, but I need to figure out how to put the lines into a record variable, and then echo the variable in a simular fashion as my swlist alias, providing me with BOTH the swtitle and swname.

Hop thats a bit more descriptive...
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Fri Apr 12, 2002 6:18 pm   
 
Anyone else care to take a crack at this?
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