[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Perlscript
. . -> [Subject]  get exits from room

get exits from room

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by finnish   Russia  (18 posts)  [Biography] bio
Date Thu 18 Sep 2003 04:53 AM (UTC)
Message
hello.
i just need help
here's the string with exits from room i get from mud:
[Exits: none]
or
[Exits: west south]
or even
[Exits: north south west east up down]
here's my problem:
i wann tell my script which exits does current room have.
that's for kinda autowalking.
maybe form an array of avaiable exits or empty if none.
i can't figure out how to do it.. will ya help?

(using perlscript and regexp's, of course)

she never loved me why should anyone
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 18 Sep 2003 07:10 AM (UTC)
Message
Probably the trick would be to match on:

[Exits: *]


Then use Perl to break up the wildcard into as many words as it can, at the space character, and process those.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #2 on Thu 18 Sep 2003 12:31 PM (UTC)
Message
A walker plugin i made, just change the "Exits: " trigger:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, September 08, 2003, 7:44 PM -->
<!-- MuClient version 3.42 -->

<!-- Plugin "Walker" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Walker"
   author="Poromenos"
   id="7dea598620724627aca3629a"
   language="VBscript"
   purpose="Randomly walks around."
   save_state="y"
   date_written="2003-09-08 19:44:07"
   requires="3.42"
   version="1.0"
   >

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   enabled="n"
   group="grpWalk"
   keep_evaluating="y"
   match="Exits: *"
   match_text_colour="y"
   script="subWalk"
   sequence="100"
   text_colour="15"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>
  <trigger
   enabled="n"
   group="grpWalk"
   keep_evaluating="y"
   match="(It\'s locked\.|Alas\, you cannot go that way\.)$"
   match_text_colour="y"
   regexp="y"
   sequence="100"
   text_colour="15"
   other_text_colour="black"
   other_back_colour="black"
  >
  <send>glance</send>
  </trigger>
  <trigger
   enabled="n"
   group="grpWalk"
   keep_evaluating="y"
   match="You can\'t do that sitting down\.$"
   match_text_colour="y"
   regexp="y"
   sequence="100"
   text_colour="15"
   other_text_colour="black"
   other_back_colour="black"
  >
  <send>stand
glance</send>
  </trigger>
</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   script="subSetInterval"
   match="^Walker\:SetInterval[ ]+(\d+)$"
   enabled="y"
   regexp="y"
   ignore_case="y"
   sequence="100"
  >
  </alias>
  <alias
   script="subToggle"
   match="^Walker\:Enable[ ]+(0|1)$"
   enabled="y"
   regexp="y"
   ignore_case="y"
   sequence="100"
  >
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[
Sub subToggle(strName, strLine, strWildcards)
    EnableTriggerGroup "grpWalk", Int(strWildcards(1))
    If Int(strWildcards(1)) = 1 Then
        Note "Walker: Enabled plugin."
    Else
        Note "Walker: Disabled plugin."
    End If
End Sub

Sub subWalk(strName, strLine, strWildcards)
    Dim intDirection
    Dim strDirection

    Randomize
    varDirs = Split(strWildcards(1), " ", -1, 1)
    strDirection = varDirs(Int(UBound(varDirs) * Rnd))
    If Left(strDirection, 1) = "[" Then
        strDirection = Right(Left(strDirection, Len(strDirection) - 1), Len(strDirection) - 2)
        Send "pick " & strDirection
        Send "open " & strDirection
    End If
    If Int(GetVariable("Interval")) < 1 Then
        Send strDirection
    Else
        DoAfter Int(GetVariable("Interval")), strDirection
    End If
End Sub

Sub subSetInterval(strName, strLine, strWildcards)
    SetVariable "Interval", strWildcards(1)
    Note "Walker: Interval set to " & strWildcards(1) & "."
End Sub
]]>
</script>


</muclient>

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by finnish   Russia  (18 posts)  [Biography] bio
Date Reply #3 on Thu 18 Sep 2003 08:37 PM (UTC)
Message
okay, thanks, i'll see what i can do.

she never loved me why should anyone
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,523 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]