[Mudlet] Capturing all data between prompts, elegantly?

Is there an elegant way to capture all data between a sending a command and the next prompt. I can do it by capturing everything as a temp trigger and then disabling the trigger on prompt, but I was wondering if there's a more elegant way? I'm also using Svo, if that matters.

Comments

  • I'm not entirely sure I know what you mean by "capture all data", but if you just want to end up with a table of all the lines that come between sending the command and getting a prompt, the simplest way I can think of would be something like the following. Create two triggers, which I'll call "trigger 1" and "trigger 2".

    trigger 1:
    type: lua
    pattern: return true
    script:
        captured_lines = captured_lines or {}
        captured_lines[#captured_lines] = line

    trigger 2:
    type: lua
    pattern: return isPrompt()
    script:
        disableTrigger("trigger 1")

    Trigger 1 should be disabled by default. When you want to send your command, do
        captured_lines = {}
        enableTrigger("trigger 1")
        send(command)

    After the prompt, the table captured_lines will contain all the lines that came between when you sent the command and the next prompt.

    If instead you want the capture to start when your command goes through, just move the
       captured_lines = {}
       enableTrigger("trigger 1")
    part to a trigger that fires when the command goes through.

    I'm not entirely sure why you'd want to do this. I suspect that depending on what you're ultimately going for, it would probably be best to do it with a trigger chain, but it's hard to say without a better idea of what you're trying to acheive.
  • That is pretty much what I was after and doing. I didn't know know about return isPrompt() though, thanks!
    I didn't need a temp trigger though, cool. I like that.

    Thanks for the help!
  • It was just to copy books and news posts. Here is the little thing to copy books to the filesystem, one page at a time. I didn't fool around with it too much to get config pagelength to be set to 250 and back, or to do a whole book at once. Just does it one page at a time. bookcopy <bookid> <page number> and writes it in /tmp/bookid-pagenumber.txt.

    Not the best solution or the prettiest, but works well enough. http://pastebin.com/nc21pDii
Sign In or Register to comment.