send to note, and others

Posted by Tsunami on Sat 16 Apr 2005 06:39 PM — 8 posts, 33,506 views.

USA #0
Something I'v been wishing for is an option that will convert anything that should have been sent to a MUD, and instead note it to the screen. I like to test/debug my plugins while disconnected, and this would save me having to go through my code and switch all the sends to notes and back, etc...

Also, a problem I posted on a little while ago while you were AWOL Nick. You may have fixed it in 3.66, because I haven't had the chance to check it yet. Line wrapping pays no attention to whether it is enabled or not, and only to the number of characters it is to wrap to. This was a problem as of 3.65.
USA #1
Send to Output is what you're looking for.
USA #2
Sorry Flannel, I'm not quite sure what you mean? Is that a script function, or are you talking about the option in the trigger/alias creation dialog?

I'v done some more testing with the line wrapping thing and this is what I'v found. MC always wraps to the number of characters specified, regardless of whether line-wrapping is selected or note. If it is selected however, then MC will wrap at word boundarys only, and it pays attention to the indent paragraphs option. Is that how it should be? It seems a little misleading to me.
USA #3
Output is a "send to" option, it's the third one down from the top.
Oh, you want a 'testing' option to automatically convert everything.
You could just write a dummy server to connect to, phantom will do this (of course it will echo back everything).
USA #4
ah yes, I hadn't thought of a dummy server. I'll give it a go.
Greece #5
Or you could use cat.exe, from poromenos.org if you want to read an entire file in.
Australia Forum Administrator #6
This is where Lua comes into its own. You can reassign the behaviour of the script functions by doing a simple assignment. eg.


Send = Note
Send ("say hello")


This example moves the address of the Note routine to replace the address of the Send routine in Lua's internal tables, so that subsequent Send is actually doing the Note function.

You could put that first line at the start (or logical start anyway) of your script file whenever you wanted to test offline. Then to restore normal behaviour comment it out, and reload the script file to force the script space to be re-initialised (ie. the correct Send routine to be installed).
Australia Forum Administrator #7
This approach would only catch scripted Sends of course, not ones where the triggers did their own sending (send to world).

You can get fancier for the scripted approach by writing your own function, which colours the line to make it more obvious, like this:


function MySend (x)
  ColourNote ("blue", "white", x)
end -- function

Send = MySend

Send ("say hello")


In this example I am defining my own "Send" function that does a ColourNote, so the replaced Sends stand out.

The only problem with the above example is that it assumes a single argument to Send, whereas in the Lua interface you can have multiple arguments. A slightly more complicated replacement function will handle that:


function MySend (...)
  for i, v in ipairs (arg) do
    ColourTell ("blue", "white", v)
  end -- for
 Note ("")
end -- function

Send = MySend

Send ("say ", "hello")


This uses "..." to specify multiple arguments to be collected in the "arg" table, and then iterates through that to display each one using ColourTell (to keep them on the same line) and finishes with a Note to end the line.