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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Perlscript
. . -> [Subject]  Help Matching
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Help Matching

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


Posted by Sb   (12 posts)  [Biography] bio
Date Thu 07 Jul 2005 09:52 AM (UTC)

Amended on Thu 07 Jul 2005 09:55 AM (UTC) by Sb

Message

      # = X  
      + ~===@
     =#=#  # 
      = #  # 
     .. =*== 
      +  :+: 
         :+: 
          "  
Shell Causeway
  Crushed shells mixed with sand and water make up the beautiful Shell
Causeway which is the road that leads through the city of Karana. 
Tall archways and towers climb high into the sun on either side of the road.
A warm salty breeze blows through the city from the near by ocean giving the
whole city a fresh smell.  
[Exits: east west]


How would I match this? I wish to set up a trigger to get my location everytime I move then store it to a variable called 'MyLocation'. So if you have any suggestions on how to approach that (should be pretty easy... just the matching) feel free to chip in.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #1 on Thu 07 Jul 2005 10:04 AM (UTC)
Message
You mean you want to match on "Shell Causeway"? Or what?

What does the map (I assume thats a map?) change around?

It would be easy enough to match on the first line of words after a couple of lines of characters (one of which could include the symbol for 'you' or whatever, youll have to give us more information on the map itself).

Or are you trying to match something else?

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Sb   (12 posts)  [Biography] bio
Date Reply #2 on Thu 07 Jul 2005 04:53 PM (UTC)
Message
I want to match "Shell Causeway" so I was looking at
Quote:
\s{5}.*{8}.\s{5}.*{8}.\s{5}.*{8}.\s{5}.*{8}.\s{5}.*{8}.\s{5}.*{8}.\s{5}.*{8}.\s{5}.*{8}.(.*)\r\n

or maybe I should match...
Quote:
\s{5}.*{8}\r\n\s{5}.*{8}\r\n\s{5}.*{8}\r\n\s{5}.*{8}\r\n\s{5}.*{8}\r\n\s{5}.*{8}\r\n\s{5}.*{8}\r\n\s{5}.*{8}\r\n(.*)\r\n
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #3 on Thu 07 Jul 2005 07:36 PM (UTC)
Message
What Should those characters be (in the map)? I imagine you could narrow that regexp down, since I imagine as it is currently, you'll find other random matches occassionally. So if you could determine a list of possible characters (a legend?) it would allow you to bullet proof your regexp.

And, you're using JUST \n for newlines, as we're using MC for the regexp match, not perl. And you'll also probably want to put a \Z at the end of the whole thing (which is the multiline equivalent of $).

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Sb   (12 posts)  [Biography] bio
Date Reply #4 on Fri 08 Jul 2005 03:06 AM (UTC)
Message
Here's what it looks like (haven't had a chance to try it yet).

Quote:

<trigger
enabled="y"
match="\s{5}(.*){8}\r\s{5}(.*){8}\r\s{5}(.*){8}\r\s{5}(.*){8}\r\s{5}(.*){8}\r\s{5}(.*){8}\r\s{5}(.*){8}\r\s{5}(.*){8}\r(.*)\r\Z"
regexp="y"
send_to="12"
sequence="100"
>
<send>$world-&gt;SetVariable("MyLocation", %9);
$world-&gt;note("Location: %9");</send>
</trigger>
[Go to top] top

Posted by Sb   (12 posts)  [Biography] bio
Date Reply #5 on Fri 08 Jul 2005 07:02 AM (UTC)
Message
Well that one didn't work, I'm gonna try to found out a better way, in the mean time if you find a good way that matches to it, please let me know.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #6 on Fri 08 Jul 2005 07:31 AM (UTC)
Message
\n not \r and you don't need the newline after the \Z.

And you should try and narrow down the .*s for each map line.

What are the possible entries in the map?

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Sb   (12 posts)  [Biography] bio
Date Reply #7 on Fri 08 Jul 2005 06:13 PM (UTC)
Message
Quote:
\s{5,}.{0,8}\n\s{5,}.{0,8}\n\s{5,}.{0,8}\n\s{5,}.{0,8}\n\s{5,}.{0,8}\n\s{5,}.{0,8}\n\s{5,}.{0,8}\n\s{5,}.{0,8}\n(.*)\Z

did the trick! Thanks for the help.
[Go to top] top

Posted by Sb   (12 posts)  [Biography] bio
Date Reply #8 on Fri 08 Jul 2005 06:50 PM (UTC)
Message
I probably need to hone it a bit though since it doesn't match everything.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #9 on Fri 08 Jul 2005 07:21 PM (UTC)

Amended on Fri 08 Jul 2005 08:48 PM (UTC) by Flannel

Message
What are the possible entries in the map? Is it just symbols (and WHICH symbols?)

And you should limit the spaces to 5 not {5,} because the other spaces aren't part of that tab. And you might as well use a space, instead of \s.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Sb   (12 posts)  [Biography] bio
Date Reply #10 on Fri 08 Jul 2005 07:32 PM (UTC)
Message
Quote:
What are the possible entries in the map? Is it just symbols (and WHICH symbols?)

And you should limit the spaces to 5 not {5,} because the other spaces aren't part of that tab. And you might as well use a space, instead of \s.

Are you actually reading my posts? Or should I just post gobbledy gook?

I'm using the .* until I can acrew a large collection symbols that are used on the map. Once I get a lot of them I will use that group. All right, I'll change it to {5} and whats wrong with using \s as opposed to a space?
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #11 on Fri 08 Jul 2005 08:48 PM (UTC)
Message
\s will match on other stuff, there isn't anything inheritly wrong with using it, but there are only spaces, and you should always try and be as specific as possible, to prevent false matches (although with multiline matches, false matches become more and more inprobably).

You said this currently doesn't match on some lines? Can you give some examples?

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Sb   (12 posts)  [Biography] bio
Date Reply #12 on Sat 09 Jul 2005 01:46 AM (UTC)
Message
When I run into one again I will. Also, does anybody know if you can write a winamp now playing plugin for this?
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #13 on Sat 09 Jul 2005 05:47 AM (UTC)
Message
Here is a plugin for the Winamp control. There are several versions of this now apparently, I think I found the right one, listed in the plugin's help text. I am not 100% sure it is the right one though. I am also not sure if the plugin itself will work 100% right, since I had to hack the bits for it out of the main script file (it was tied in with a mess of other things displayed on the info bar). If you have a plugin already using that, then this will need several changes.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, July 08, 2005, 10:02 PM -->
<!-- MuClient version 3.66 -->

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

<muclient>
<plugin
   name="Winamp_Plugin"
   author="kagehi"
   id="e63914767b5cd4d44254047c"
   language="VBscript"
   purpose="Example of using Winamp with Mushclient."
   save_state="y"
   date_written="2005-07-08 21:52:54"
   requires="2.00"
   version="1.0"
   >
<description trim="y">
<![CDATA[
This uses a winamp plugin to connect to Winamp and provide basic
controls from inside Mushclient. Note: There are occational
problems, caused by the fact that you are forced to call the
Winamp plugin, but it is not closed properly in some cases, like
when closing Winamp, 'then' closing Mushclient. Sometimes closing
them in the wrong order causes Mushclient to crash when closing.
This isn't fixable as near as I can tell.

This is also an untested plugin, since the original code was not
in a seperate plugin and needed to intergrate the output with other
things in the info bar. Adjustments may be needed.

This uses the Winamp plugin here (I think):

http://www.winamp.com/plugins/details.php?id=6538

A better one now exists with more features, called "ActiveWinamp",
but using it will require extensive changes to this plugin and
the automatic functions (i.e. events) will still not be usable as
they would be in a browser or application. This is due to how the
object is created. When created as with this plugin, the object is
tied to the script for commands, like winamp.play, but there is
nothing 'listening' for events from winamp, so it has no way to
know when such a thing has been sent or what script to call for
it. The 'Song' function is an example of one not available due to
this. In other words, you can 'command' winamp from here, but this
plugin can't be commanded by or told anything by winamp, except
when specifically requested. This is why the CalcTime timer
periodically asks Winamp the song name, to see if it has changed.

]]>
</description>

</plugin>


<!--  Aliases  -->

<aliases>
  <alias
   name="Close_Winamp"
   match="WinampKill"
   group="WinAmp"
   send_to="12"
   menu="y"
   sequence="101"
  >
  <send>winamp.stop
winamp=""
enablealias "Open_Winamp",1
enablegroup "WinAmp",0</send>
  </alias>
  <alias
   name="Next_Track"
   match="Next Track"
   group="WinAmp"
   send_to="12"
   menu="y"
   sequence="103"
  >
  <send>winamp.fastforward</send>
  </alias>
  <alias
   name="Toggle_Repeat"
   match="ToggleRepeat"
   group="WinAmp"
   send_to="12"
   menu="y"
   sequence="107"
  >
  <send>if winamp.RepeatStatus then
  note "Winamp: Repeat Off"
  winamp.RepeatStatus = vbFalse
else
  note "Winamp: Repeat On"
  winamp.RepeatStatus = vbTrue
end if</send>
  </alias>
  <alias
   name="Open_Winamp"
   script="Open_Winamp"
   match="OpenWinamp"
   enabled="y"
   menu="y"
   sequence="100"
  >
  </alias>
  <alias
   name="Pause_Winamp"
   match="PauseSong"
   group="WinAmp"
   send_to="12"
   menu="y"
   sequence="106"
  >
  <send>winamp.pause</send>
  </alias>
  <alias
   name="Previous_Track"
   match="Previous Track"
   group="WinAmp"
   send_to="12"
   menu="y"
   sequence="102"
  >
  <send>winamp.rewind</send>
  </alias>
  <alias
   name="Play"
   match="WMPlay"
   group="WinAmp"
   send_to="12"
   menu="y"
   sequence="104"
  >
  <send>winamp.play</send>
  </alias>
  <alias
   name="Toggle_Shuffle"
   match="ToggleShuffle"
   group="WinAmp"
   send_to="12"
   menu="y"
   sequence="107"
  >
  <send>if winamp.ShuffleStatus then
  note "Winamp: Shuffle Off"
  winamp.ShuffleStatus = vbFalse
else
  note "Winamp: Shuffle On"
  winamp.ShuffleStatus = vbTrue
end if</send>
  </alias>
  <alias
   name="Stop"
   match="WMStop"
   group="WinAmp"
   send_to="12"
   menu="y"
   sequence="105"
  >
  <send>winamp.stop</send>
  </alias>
</aliases>

<!--  Timers  -->

<timers>
  <timer name="CalcTime" script="CalcTime" enabled="y" second="5.00" >

  </timer>
  <timer name="Volume_Adjust" script="AdjVolume" enabled="y" second="1.00" active_closed="y" >

  </timer>
</timers>

<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="Winamp_Plugin:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
dim winamp
enablealias "Open_Winamp",1
enablegroup "WinAmp",0
'dim WindowObject
'set WindowObject = createobject("MUClientWindow.TextBox")
'WindowObject.Topmost = True
'WindowObject.SetTitle "Channel Window"
'WindowObject.SetPosition 11830, 0, 7190, 12000'300, 500, 12000, 3000
'WindowObject.Locked = True
'WindowObject.BackgroundColor = vbBlack


Sub OnHelp (sName, sLine, wildcards)
  world.Note world.GetPluginInfo (world.GetPluginID, 3)
End Sub

sub Open_Winamp (name, output, wilds)
  set winamp=createobject("WinampCOM.application")
  if winamp.PlayListCount < 1 then
    winamp.AddFile("C:\My Documents\My Music\Playlists\Favorites.m3u")
    winamp.play
    winamp.fastforward
  end if
  enablealias "Open_Winamp",0
  enablegroup "WinAmp",1
  'Set winamp.SongChange = GetRef("song")
end sub

'sub song(song) 'Not usable, since there is no way to connect the 'event' to the function.
'  note song
'end sub

sub OnPluginClose
  set winamp = Nothing
end sub

sub CalcTime(Name)
  if typename(winamp) = "IApplication" then
    world.infoclear
    world.InfoFont "Calisto MT",8,1
    world.infocolour "midnightblue"
    world.info "Winamp: "
    world.InfoFont "Lucida Handwriting",6,1
    world.InfoColour "black"
    world.info getvariable("CSong")
  end if
end sub

sub AdjVolume (name) 'This was added to deal with songs that where not the same volume.
                     'By adjusting up or down, they would all sound the same, even when not.
  dim Slist(10)
  Slist(0) = "Princess Mononoke"
  Slist(1) = "Loved By The Sun"
  Slist(2) = "My Will (English"
  Slist(3) = "Nuovo interprete"
  Slist(4) = "Alchemy of Love"
  if typename(winamp) = "IApplication" then
    temp = winamp.CurrentSongTitle
    'note temp & "  " & getvariable("CSong")
    if temp <> getvariable("CSong") then
      setvariable "CSong",temp
      fnd = 0
      for count = 0 to 4
        if instr (temp,Slist(count)) then
          fnd = 1
          exit for
        end if
      next
      if fnd then
        winamp.SetVolume(255)
      else
        winamp.SetVolume(179) ' 70%
      end if
    end if
  end if
end sub

]]>
</script> 

</muclient>

But heh, its better than nothing. ;) If you used Python or Lua instead to make on for the new ActiveWinamp (or even remake this one), those 'do' provide a way to accept events from Winamp, which is the fatal flaw that VBScript, JScript and others have and why I had to use 'CurrentSongTitle' to retrieve the name every 30 seconds, instead of just letting Winamp tell Mushclient when the song changed and checking the name once after. :(
[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.


11,379 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 FutureQuest]