Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
Darker
GURU


Joined: 24 Sep 2000
Posts: 1237
Location: USA

PostPosted: Sun Jun 15, 2003 7:25 pm   

Darker's Directions (Realms Of Despair)
 
Finally got this working.
Description: This creates a "getdirs" alias that queries Nelkum's web page and shows you all the matching destination information for the text you enter. The results include the area name, level, and directions. Easy.

Requires: Internet Explorer, zMUD 6.62+
Usage: getdirs [some text]

Example:
getdirs art

Output:
- Directions -----------------------------------------
1: bARTok grove 5-20 6w, 2sw, 5w, s

2: darkhaven ART gallery 10-50 4s, w, n

3: sewer 5-30 6s, open manhole, d
from dh[] to the older pART of the
sewer (probably not connected to the newer pART by any walking path): (float
or fly required) 6s, ne, 2s, se, 2e, s, 2sw, s, 4sw, 4s, 5se, 2s, d, s,
se, s, 3sw, u, 2w, n, nw, 2n, sw, s, sw, se, e, ne, open wall, n


------------------------------------------------------


Version 1
Make sure you get the code by replying & copying, to make sure html display doesn't munch it.


#alias getdirs {
#var searchtext "%1"
#script {strHTML = ~"~"}
#script {strTEXT = ~"~"}
#script {strTEST = ~"~"}
#script {strfind = ~"%lower(@searchtext)~"}
#script {strLIST = ~"~"}
#script {sub getit:set objHTTP = CreateObject~(~"MSXML2.XMLHTTP~"):objHTTP.Open ~"GET~", ~"http:~/~/home.austin.rr.com~/nelkum~/~", ~"FALSE~":objHTTP.Send:intX = instr~(lcase~(objHTTP.ResponseText), ~"find things in the~"):intY = instr~(objHTTP.ResponseText, ~"******~"):intZ = intY - intX:strHTML = mid~(objHTTP.ResponseText, intX, intZ):Set objHTTP = Nothing:End Sub}
#script {sub stripit:Set objRegExp = New Regexp:objRegExp.IgnoreCase = True:objRegExp.Global = True:strOutput = Replace~(strHTML, ~"~<~/tr>~", ~"!eol!~"):strOutput = Replace~(strOutput, ~"~<tr>~", ~"!bol!~"):objRegExp.Pattern = ~"~<~(.|n)+?>~":strOutput = objRegExp.Replace~(strOutput, ~"~"):strOutput = Replace~(strOutput, chr~(34~), ~"'~"):strTEXT = lcase~(strOutput):Set objRegExp = Nothing:End Sub}
#script {sub findit:intStart = 1:intCount = 1:do while instr~(intStart, strTEXT, strfind) > 0:intX = instrRev~(strTEXT, ~"!bol!~", instr~(intStart, strTEXT, strfind)) + 7:intY = instr~(intX, strTEXT, ~"!eol!~") - 1:intZ = intY - intX:strLIST = strLIST & intCount & ~": ~":strTEST = ~"intX=~" & intX & vbCrLf & ~"intY=~" & intY & vbCrLf: strTEST2 = ~"mid~(strTEXT, ~" & intX & ~", ~" & intZ & ~")~":strLIST = strLIST & replace~(replace~(mid~(strTEXT, intX, intZ), strfind, ucase~(strfind)), vbCrLf & vbCrLf, ~" ~"):strLIST = strLIST & vbCrLf & vbCrLf:intStart = intY:intCount = intCount + 1:loop:End Sub}
#mss {getit}
#mss {stripit}
#mss {findit}
#show - Directions -----------------------------------------
#show %mss( strLIST)
#show ------------------------------------------------------
}



zMUD 6 Online Help: All the power you'll ever need.
Reply with quote
Morten
Apprentice


Joined: 17 Feb 2001
Posts: 119
Location: Denmark

PostPosted: Mon Jun 16, 2003 2:13 pm   
 
nice script Darker....

any posiblities in getting it to work with other dirs sites?.

(http://battletech.homepage.dk)

Yugo

Yugo Sangori
Reply with quote
Darker
GURU


Joined: 24 Sep 2000
Posts: 1237
Location: USA

PostPosted: Sun Jun 29, 2003 11:50 pm   
 
Update. Put this in the alias body and it'll even convert Nelkum's non-zMUD friendly dirs to something you can copy & paste in zMUD to get where you're going.

Code:

#var searchtext "%1"
#script {strHTML = ~"~"}
#script {strTEXT = ~"~"}
#script {strTEST = ~"~"}
#script {strfind = ~"%lower( @searchtext)~"}
#script {strLIST = ~"~"}
#script {sub getit:set objHTTP = CreateObject~(~"MSXML2.XMLHTTP~"):objHTTP.Open ~"GET~", ~"http:~/~/home.austin.rr.com~/nelkum~/~", ~"FALSE~":objHTTP.Send:intX = instr~(lcase~(objHTTP.ResponseText), ~"find things in the~"):intY = instr~(objHTTP.ResponseText, ~"******~"):intZ = intY - intX:strHTML = mid~(objHTTP.ResponseText, intX, intZ):Set objHTTP = Nothing:End Sub}
#script {sub stripit:Set objRegExp = New Regexp:objRegExp.IgnoreCase = True:objRegExp.Global = True:strOutput = Replace~(strHTML, ~"~<~/tr>~", ~"!eol!~"):strOutput = Replace~(strOutput, ~"~<tr>~", ~"!bol!~"):objRegExp.Pattern = ~"~<~(.|n)+?>~":strOutput = objRegExp.Replace~(strOutput, ~"~"):strOutput = Replace~(strOutput, chr~(34~), ~"'~"):strTEXT = lcase~(strOutput):Set objRegExp = Nothing:End Sub}
#script {sub findit:intStart = 1:intCount = 1:do while instr~(intStart, strTEXT, strfind) > 0:intX = instrRev~(strTEXT, ~"!bol!~", instr~(intStart, strTEXT, strfind)) + 7:intY = instr~(intX, strTEXT, ~"!eol!~") - 1:intZ = intY - intX:strLIST = strLIST & intCount & ~": ~":strTEST = ~"intX=~" & intX & vbCrLf & ~"intY=~" & intY & vbCrLf: strTEST2 = ~"mid~(strTEXT, ~" & intX & ~", ~" & intZ & ~")~":strLIST = strLIST & replace~(replace~(mid~(strTEXT, intX, intZ), strfind, ucase~(strfind)), vbCrLf & vbCrLf, ~" ~"):strLIST = strLIST & vbCrLf & vbCrLf:intStart = intY:intCount = intCount + 1:loop:End Sub}
#mss {getit}
#mss {stripit}
#mss {findit}
#var LastDirs %mss( strLIST)
#var LastDirsP ""
#var skipthis 0
#var insertspace 0
#loop %len( @LastDirs) {
  #var Thischar %copy( @LastDirs, %i, 1)
  #if (@skipthis = 0) {
    #if (%isnumber( @Thischar)) {
 #if (%i < %len( @LastDirs)) {
        #var Nextchar %copy( @LastDirs, %i+1, 1)
        #if (%isnumber( @Nextchar)) {
          #var skipthis 1
          #var Nextchar %copy( @LastDirs, %i+2, 1)
          }
        #if (%ismember( @NextChar, n|e|s|w|u|d)) {
          #var LastDirsP %concat( @LastDirsP, "#")
          #var insertspace 1
          }
        }
      }
    #if (@Thischar = ",") {#var LastDirsP %concat( @LastDirsP, ";")} {
      #var LastDirsP %concat( @LastDirsP, @Thischar)
      #if (@insertspace=1 and @skipthis=0) {
        #var LastDirsP %concat( @LastDirsP, ' ')
        #var insertspace 0
        }
      }
    } {
    #var skipthis 0
    #var LastDirsP %concat( @LastDirsP, @Thischar)
    #if (@insertspace=1) {
      #var LastDirsP %concat( @LastDirsP, ' ')
      #var insertspace 0
      }
    }
  }
#show - Directions -----------------------------------------
#show @LastDirsP
#show ------------------------------------------------------
Reply with quote
Aleir
Newbie


Joined: 31 Aug 2003
Posts: 2

PostPosted: Sat Sep 20, 2003 5:56 pm   
 
Wonderful concept. However, I receive an error when I attempt to execute.

I receive this:
Error executing: getit
Invalid procedure call or argument: 'mid' (error 5) on line 1, column 262.

I am using zmud 6.62, IE 6.0.2800.1106.xpsp2 and playing Realms of Despair.

Not sure if I have done anything wrong. I was initially getting an error when I imported the script, but now I am not. Still can not execute it though. Any thoughts?
Reply with quote
Darker
GURU


Joined: 24 Sep 2000
Posts: 1237
Location: USA

PostPosted: Sat Sep 20, 2003 8:17 pm   
 
If it doesn't recongize 'mid', then VBScript is likely not an available scripting language on your computer.

To solve this, visit http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp
to install the Scripting runtimes on your computer.
Reply with quote
PrestoPimp
Apprentice


Joined: 18 Sep 2001
Posts: 175
Location: USA

PostPosted: Sun Sep 21, 2003 11:39 pm   
 
Yo Darker, I went there and got the script updates and i get the same error.. how is this fixable cuz this sounds like a really cool script.
Reply with quote
Darker
GURU


Joined: 24 Sep 2000
Posts: 1237
Location: USA

PostPosted: Mon Sep 22, 2003 5:38 pm   
 
Hmm. Not sure why it would barf on 'mid'... That's been in vbscript for years. I could re-write this to use 'left' and 'right' instead of 'mid', but then it'd probably gag on those.

I'm going to ponder this for a bit.
Reply with quote
Darker
GURU


Joined: 24 Sep 2000
Posts: 1237
Location: USA

PostPosted: Sat Sep 27, 2003 10:26 pm   
 
That shifty Nelkum. He changed text on his page and it broke my script! Little bugger. Very Happy

Here's the fix. Find the text "find things in the" in the script (it's in the getit line) and change it to "to find"

Voila. Things work again, until he messes with the text again.
Reply with quote
PrestoPimp
Apprentice


Joined: 18 Sep 2001
Posts: 175
Location: USA

PostPosted: Sun Sep 28, 2003 4:09 am   
 
lol works great thx darker
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts 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