How to fix a broken prompt that's missing a newline?

Post Reply
InTheWorks
Posts: 18
Joined: Sat Sep 10, 2011 7:37 am

How to fix a broken prompt that's missing a newline?

Post by InTheWorks »

The mud I play on has a broken prompt that sometimes does not contain a newline. For example, sending w;w in a room with no west exit gives this:

Alas, you cannot go that way. . . .
< 204h/204H 118v/118V P: std > Alas, you cannot go that way. . . .
< 204h/204H 118v/118V P: std >

I'm trying to create a script that will detect this condition and force a line break so that:

1. It looks nice
2. triggers that depend on ^ and $ work properly.

I've got a wrapping trigger that mostly works (and it's placed before all other triggers).

My regex trigger looks like this:
Code: [show] | [select all] lua
^(<[^>]+> )(.+)$
And the script looks like this:
Code: [show] | [select all] lua
local x = selectString("> ", 1) + 2 -- find the end of the prompt
local y = getLineNumber()           -- need the absolute line number too
moveCursor("main", x, y)            -- move the cursor to where the newline _should_ be
insertText("\n")                           -- and insert the newline
which gives me this:

Alas, you cannot go that way. . . .
< 204h/204H 118v/118V P: std >
Alas, you cannot go that way. . . .
< 204h/204H 118v/118V P: std >

which works great, except for one little problem. I'm doing "proper" prompt detection with a second trigger. This trigger parses the info in the prompt for further processing. It also looks for text between the prompts and reacts to things and echos stuff. To illustrate the problem I altered the script in my prompt detection to simply echo("testing\n")

with the wrapping trigger above turned off, I get output like this:

Alas, you cannot go that way. . . .
< 204h/204H 118v/118V P: std > Alas, you cannot go that way. . . .testing
< 204h/204H 118v/118V P: std > testing

with the wrapping trigger turned on, I get this:

Alas, you cannot go that way. . . .
< 204h/204H 118v/118V P: std >
Alas, you cannot go that way. . . .testing
< 204h/204H 118v/118V P: std > testing

what I would like to see is:

Alas, you cannot go that way. . . .
< 204h/204H 118v/118V P: std > testing
Alas, you cannot go that way. . . .
< 204h/204H 118v/118V P: std > testing

Any idea how I can make that happen?

Post Reply