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
kiti96
Newbie


Joined: 17 Mar 2005
Posts: 3

PostPosted: Thu Mar 17, 2005 1:06 pm   

Need help with exploring script
 
Ok, i am pretty new to ZMUD and i need help with an Explorer-Script.
I do not really know how to start with this project.

I play in a Mud where you have to explore each room very intensive. You need to look at each word that starts with a Upper-Case letter.

I want to write a script, that i can use on a button.
If i push the button the command 'look' will display the room-description.
Then the script should write every word that starts with a Upper-Case letter in a list and do a 'look word' on every item of the list.

Is this possible? Any Advice would be nice ...

Thanks, Kiti
Reply with quote
Spartacus
Wanderer


Joined: 23 Apr 2001
Posts: 53
Location: USA

PostPosted: Thu Mar 17, 2005 8:19 pm   
 
Assumptions:
    The current room has been added to your map, complete with description.
    You don't need to wait for any response between sending your look commands.


Code:
#ALIAS ckRoom {
#VAR rmDescWords {%subregex(%roomdesc(),"[[:space:][:punct:]]*[a-z]+[[:space:][:punct:]]*","|")}
#forall @rmDescWords {
  #if (%left(%i,1)=%upper(%left(%i,1))) {
    look %i
    }
  }
}
#KEY ALT-R {ckRoom}


Explanation:
My regex may be off, but I think that this should replace all lowercased words and their surrounding delimiters with |, creating a tidy list of all of the uppercased words in the room description. The #forall statement then loops through the items in the list and looks at each of them after the #if double-checks that they really are upper-cased.

Disclaimer: I think this will work - Good Luck! Wink
_________________
Spartacus
rm -rf .*
Reply with quote
Maelstrom
Apprentice


Joined: 10 Feb 2005
Posts: 158

PostPosted: Thu Mar 17, 2005 10:05 pm   
 
I would have a stab at this (sounds interesting), but would need examples (perhaps two) of the mud output when you send the look command.
Most muds have something like:

Room name
Desc
Desc
Exits
Prompt

But thats about what I would need. Unless of course you *do* have everything in the mapper. In which case Spartacus's example would work best.
Reply with quote
kiti96
Newbie


Joined: 17 Mar 2005
Posts: 3

PostPosted: Thu Mar 17, 2005 10:46 pm   
 
@Spartacus i managed to run the Alt-R Button in a room, but it seems that the list of the words is not in the variable rmDescWords.
If i run Alt-R the command line

look %subregex(%roomdesc(),"[:punct:]*[a-z]+[:punct:]*","|")

is sent to the mud.

@Maelstrom
My rooms do not have a Room-Name

They look like:

Desc
Desc
Desc
You see the exits: north, west, south.
>

thnx for your kind help :-)

Kiti
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Thu Mar 17, 2005 11:22 pm   
 
#CLASS {Explorer}
#ALIAS dolook {#T+ STARTEXPLORE;look}
#VAR WordList {}
#VAR TheList {}
#TRIGGER "INEXPLORE" (*) {#additem TheList {%subregex("%1","\W"," ")}} "" {disable}
#REGEX "STOPEXPLORE" {^<\d+hp \d+m \d+mv \d+w>} {#T- INEXPLORE
#T- STOPEXPLORE
#VAR TheList {%expandlist(@TheList,"")}
#Loop %numwords(@TheList) {#if (%proper(%word(@TheList,%i)) = %word(@TheList,%i)) {#additem WordList %word(@TheList,%i)}}
#FO @WordList {look %i}} "" {prompt|disable}

#REGEX "STARTEXPLORE" {[Exits:(?: \w+)+]} {#var WordList {}
#var TheList {}
#T+ STOPEXPLORE
#T+ INEXPLORE
#T- STARTEXPLORE
} "" {disable}

#CLASS 0

The STOPEXPLORE Trigger (bold) is used to stop the capture and find the proper words, the pattern will have to be changed to match your prompt.
The STARTEXPLORE Trigger (blue) is used to start the capture so you'll
have to change the pattern to match whatever line comes before your room description
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
Maelstrom
Apprentice


Joined: 10 Feb 2005
Posts: 158

PostPosted: Fri Mar 18, 2005 2:56 am   
 
Hmm, not too much to go on... oh well heres my shot.
Works fine when I tested it here on my side. Only thing I cant tell if your > is prompt of not. If so enable that option for second trigger and remove the $ from the pattern

#BUTTON 1 {look all} {#RESET lookall;#CLASS lookall {1};#SEND {look}} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} "" {} {} {}

#CLASS lookall
#VAR WordList {} {}
#TRIGGER {(*)} {#MATH WordList {@WordList+%subregex("%1","\W+","|")}}
#TRIGGER {^>$} {#FORALL {@WordList} {#IF (%proper(%i)=%i) {#ECHO {look %lower(%i)}}};#CLASS lookall {0}}
#CLASS 0


Oh yeah last thing, when you paste these in make sure the lookall class is defaulted to disabled when connecting... Idea
Reply with quote
Maelstrom
Apprentice


Joined: 10 Feb 2005
Posts: 158

PostPosted: Fri Mar 18, 2005 3:25 am   
 
Oops, forgot your last line isnt the prompt... all the better

#BUTTON 1 {look all} {#RESET lookall;#CLASS lookall {1};#SEND {look}} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} "" {} {} {}

#CLASS lookall
#VAR WordList {} {}
#TRIGGER {(*)} {#MATH WordList {@WordList+%subregex("%1","\W+","|")}}
#TRIGGER {^You see the exits:} {#FORALL {@WordList} {#IF (%proper(%i)=%i) {#ECHO {look %lower(%i)}}};#CLASS lookall {0}} {case}
#CLASS 0
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Fri Mar 18, 2005 10:15 pm   my mud
 
ok my mud is pretty much like kiki's, an example of a roomoutput is this:

desc
desc
desc
There are seven obvious exits: east, northeast, south, west, northwest,
southeast, southwest
>(which is my prompt)

im decent at understanding zmud stuff, dont know much about regex, but what i would like to do is make this script look at all the words in the room except things like a/an/the/but/it/you/to/ect, which i assume i can make a variable/notepad file containing the exclude words. anyway to do this? and the words i want to examine aren't all capital, so case doesn't matter. additionally, the room exits aren't always over one line long, just how long until it wraps.
Reply with quote
Maelstrom
Apprentice


Joined: 10 Feb 2005
Posts: 158

PostPosted: Fri Mar 18, 2005 10:52 pm   
 
Almost the same thing...

#BUTTON 1 {look all} {#RESET lookall;#CLASS lookall {1};#SEND {look}} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} "" {} {} {}

#CLASS lookall
#VAR WordList {} {}
#VAR Restrict {a|an|the|but|it|you|to|ect} {a|an|the|but|it|you|to|ect}
#TRIGGER {(*)} {#MATH WordList {@WordList+%subregex("%1","\W+","|")}}
#TRIGGER {^There are %w obvious exits:} {#FORALL {@WordList} {#IF (!%ismember(%lower(%i),@Restrict)) {#ECHO {look %lower(%i)}}};#CLASS lookall {0}} {case}
#CLASS 0


Did not test but should work...
Reply with quote
Spartacus
Wanderer


Joined: 23 Apr 2001
Posts: 53
Location: USA

PostPosted: Sun Mar 20, 2005 7:32 am   
 
Kiti,

Dharkael's approach was better, but I think there's still some merit to letting the mapper grab the desc and then looking at the extras:

Code:
#ALIAS ckRoom {
#loop %numwords(%roomdesc()) {
  #var ckWord {%word(%roomdesc(),%i)} _nodef
  #if (%left(@ckWord,1)=%upper(%left(@ckWord,1))) {
    look @ckWord
    }
  }
}
#KEY ALT-R {ckRoom}


The places you're likely to have problems are when this includes a punctuation mark in the word - sentence ends, commas, etc. Did you mention which version you're using? From your last post it sounds like it may be pre-regex, in which case none of what's been posted before now will work for you.
_________________
Spartacus
rm -rf .*
Reply with quote
kiti96
Newbie


Joined: 17 Mar 2005
Posts: 3

PostPosted: Mon Mar 21, 2005 2:56 pm   
 
Hi Spartacus,

i use Zmud 6.16 i think. Just on work and not at home.
I had great problems with my XP and trying to run the Zmud
in Version 7.
I could not start after installaion an error 'Class not registered'
occured.
So i decided to try an older version and this worked fine ...

And i have problems to run the scripts above - right now i am
thinking i am to stupid to understand :-). I will try your code
since a am at home.

Thnx a lot, Kiti

Very Happy Jeah - it works!!! Thnx, thnx thnx Very Happy


Last edited by kiti96 on Mon Mar 21, 2005 5:13 pm; edited 1 time in total
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Mon Mar 21, 2005 5:00 pm   
 
could someone alter that script to not search a list of restricted words and to do all words? it would be really appreciated
Reply with quote
Spartacus
Wanderer


Joined: 23 Apr 2001
Posts: 53
Location: USA

PostPosted: Mon Mar 21, 2005 5:12 pm   
 
Sure!

Try this - it also fixes the problem of (some) punctuations being included as part of a word. You could easily add other puctuation marks to be stripped - just add them in where I have ",.":

Code:
#ALIAS ckRoom {
#loop %numwords(%roomdesc()) {
  #var ckWord {%subchar(%word(%roomdesc(),%i),",.","")} _nodef
  look @ckWord
  }
}
#KEY ALT-R {ckRoom}
_________________
Spartacus
rm -rf .*
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Mon Mar 21, 2005 6:44 pm   
 
Code:

#VAR ckForbid {This|Is|a|list|of|forbidden|words}

#ALIAS ckRoom {#var ckWords {%subregex(%roomdesc(),<(\b(@ckForbid)\b)|'|\s+>," ")}
#var ckWords {%subregex(@ckWords,"\W+","|")}
#delitem ckWords {}
#fo (@ckWords) {look %i}
}

#KEY ALT-R {ckRoom}


Just fill the ckForbid list with all the words you dont want to look at.
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Mon Mar 21, 2005 7:27 pm   
 
Sorry the previous code had a bug if ckForbid was empty then it locked up
zmud, because it repeatedly matched a zero width string.
I just added an if statement so it wont do that anymore.

Code:
#ALIAS ckRoom {#if (%numitems(@ckForbid)) {
#var ckWords {%subregex(%roomdesc(),<(\b(@ckForbid)\b)|'|\s+>," ")} } {
#var ckWords {%subregex(%roomdesc(),"'|\s+"," ")}
}
#var ckWords {%subregex(@ckWords,"\W+","|")}
#delitem ckWords {}
#fo (@ckWords) {look %i}
}
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Tue Mar 22, 2005 7:57 am   
 
thanks a lot for your willingness to help me out with this, now i only have one more problem and an additonal question. it doesn't seem to exclude the ckForbid words, and in the alias box I get a syntax error that refers to the <(\b(@ckForbid)\b)|'|\s+>," "), about the initial <. Also, is there a way to not see the huge look at every object command spam? i want to see the descriptions, but not the 100 or so commands entered
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