Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ user list to notepad

user list to notepad

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


Posted by Herb   United Kingdom  (5 posts)  Bio
Date Tue 06 Aug 2002 08:24 AM (UTC)
Message
I would like to display the mud users list in a separate window.
I can use a trigger to catch and output the first line of the user list to the notepad, but I would like to output the whole list.
The list always finishes with the same string. (blah blah visible players.)
Can I use the first line to start outputting to the notepad and the last line as a trigger to stop?

*******************************************************

herbert@asylum-mud.org Co-founder of Asylum MUD
http://www.asylum-mud.org/
telnet asylum-mud.org 6715
telnet www.asylum-mud.org (portless)

*******************************************************
Top

Posted by Vaejor   (120 posts)  Bio
Date Reply #1 on Tue 06 Aug 2002 12:40 PM (UTC)
Message
If you are using scripting, you can do this.

You didn't mention if the first line was a unique triggerable string(aka some sort of heading for the list), but I'll assume it is, as most muds like to show their name on the top of these sorts of lists.

Create an alias that calls function1 that sets up your first trigger for the first line to catch.

Your first trigger should call function2 which sets up all other triggers. In this case, you could probably do it with just a ^(.*)$ regexp to catch the entirety of every line, but you may want to limit it some more if you can so that you don't pick up extra communications possibly occuring while you scroll through the list. If there are no pauses while displaying the list, you shouldn't have the problem with extra communications.

For the trigger that catches the last line, call function3 that deletes all the triggers created throughout this functionality to clean itself up.


Short incomplete VBScript example:

data to process:
Mushclient Users
Vaejor the Board Reader
Herb the Question Asker
There are 2 users online.


alias: nwho
  sends: who
  script: nwho_initialize
  

Sub nwho_initialize(ByVal strName, ByVal strOutput, ByVal astrParam())
  world.AddTrigger "nwho_first_line", "*Mushclient Users", ...., "nwho_start"
'                                                                 ^
'                                                                 ScriptName portion of AddTrigger
End Sub

Sub nwho_start(ByVal strName, ByVal strOutput, ByVal astrParam())
  world.DeleteTrigger "nwho_first_line"
' The next line should be either made to output to notepad, or call a script
'   which outputs it to a specifically named notepad
  world.AddTrigger "nwho_data_line", "*", ....
  world.AddTrigger "nwho_last_line", "There are * users online.", ...., "nwho_stop"
End Sub

Sub nwho_stop(ByVal strName, ByVal strOutput, ByVal astrParam())
  world.DeleteTrigger "nwho_data_line"
  world.DeleteTrigger "nwho_last_line"
End Sub
Top

Posted by Herb   United Kingdom  (5 posts)  Bio
Date Reply #2 on Wed 07 Aug 2002 11:16 AM (UTC)
Message
thanks for the pointers Vaejor
I couldnt actually work out how to set output to notepad for addtrigger so I wrote the triggers individually and used enabletrigger in the script.

Is there anyway to specify output to a given notepad?
It would suit me to have several triggers all outputting to the same notepad.

*******************************************************

herbert@asylum-mud.org Co-founder of Asylum MUD
http://www.asylum-mud.org/
telnet asylum-mud.org 6715
telnet www.asylum-mud.org (portless)

*******************************************************
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 07 Aug 2002 11:51 AM (UTC)
Message
If you have multiple triggers with no label, they will output to the same notepad.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Vaejor   (120 posts)  Bio
Date Reply #4 on Wed 07 Aug 2002 12:45 PM (UTC)
Message
I use several notepads in order to store some data from the mud. I tend to call a central script who's entire purpose is to do a world.AppendToNotepad ...

Here's a copy of one of those scripts. It includes code to remove prompts at the beginning of the line and to insert a small date/time stamp before the line.


Sub catch_tonotepad(ByVal strName, ByVal strLine, ByVal astrParam())
'Remove extra spaces at beginning or end of data
  strLine = Trim(strLine)
'Trim all prompts at the beginning of the line.  Prompts in this case are always "> "(minus the quotes)
  Do While (Left(strLine, 2) = "> ")
    strLine = Mid(strLine, 3, Len(strLine) - 2)
  Loop
'the formatdatetime combo causes month/date hour:minute:second output
'eg:
'08/07 7:22:53 : Vaejor licks you.
  world.AppendToNotepad "MudName", Left(formatdatetime(now(), 2), 5) & " " & Left(formatdatetime(now(), 3), 8) & ": " & strLine & vbCrLf
End Sub


Alternatively, in order to do it more simply without this part of the code, you will have to use world.AddTriggerEx() which contains 2 additional input parameters. One of those is SendTo, which you can set to 5 for 'Send to Notepad (append)' which will send it to a default named notepad for everything sent this way, I believe. You can find more information on this at:

http://www.gammon.com.au/scripts/function.php?name=AddTriggerEx&searchfor=
Top

Posted by Herb   United Kingdom  (5 posts)  Bio
Date Reply #5 on Thu 08 Aug 2002 10:32 AM (UTC)
Message
OK sorted, thanks for the help!

*******************************************************

herbert@asylum-mud.org Co-founder of Asylum MUD
http://www.asylum-mud.org/
telnet asylum-mud.org 6715
telnet www.asylum-mud.org (portless)

*******************************************************
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.


19,586 views.

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

Go to topic:           Search the forum


[Go to top] top

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