user list to notepad

Posted by Herb on Tue 06 Aug 2002 08:24 AM — 6 posts, 26,368 views.

United Kingdom #0
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?
#1
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
United Kingdom #2
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.
Australia Forum Administrator #3
If you have multiple triggers with no label, they will output to the same notepad.
#4
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=
United Kingdom #5
OK sorted, thanks for the help!