deleteLine() versus echo()

Post Reply
goose
Posts: 13
Joined: Sun Jun 14, 2009 2:51 pm

deleteLine() versus echo()

Post by goose »

I'm trying to make what seems like a simple trigger that replaces a line with another in the output, with some fancy colours and whatnot.

For example something like:
You have some things.
replaced with
"You have "..things.." things."

Now, I'm doing this simply by something like this:

Code: Select all

fg("blue")
echo("You have "..things)
fg("green")
echo("th")
and so on. That's all well and good, but I can't seem to delete the original line AND show the echoes at the same time. If I do selectString(line,1) and replace("") before the rest, the echoes are shown, but without any of the colours. If I do deleteLine(), nothing is shown, but if I scroll up and down, the echoes are shown with all the colours, but on the previous line (in this case the command echo)

On another related note, echo("\n") seems to show a bell instead of a newline when used after deleteLine(), but a newline in a random place if used after replace("") :?

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: deleteLine() versus echo()

Post by Heiko »

Are you using beta-14 or later?

goose
Posts: 13
Joined: Sun Jun 14, 2009 2:51 pm

Re: deleteLine() versus echo()

Post by goose »

Latest git.

You can ignore what I said about newlines in random places as it seems I had a few insertText() mixed up in my echo():s when that happened. The rest still stands.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: deleteLine() versus echo()

Post by Heiko »

You might have found a real bug. I'll look into the issue.

The echo() function appends text at the end of the current line. Note that during trigger processing a line does not represent a line on the screen, but the line as sent by the MUD (without word wrap, screen width etc.) plus what you've added via echo() or insertText(). Such a line may result in many screen lines when word wrap is performed in a second step before the next line from the MUD is being processed.
Consequently, if you call deleteLine() the entire echos() will be gone - even if your echos include linebreaks. As a result, you'll have to call deleteLine() first and then do your echos() afterwards. If this still doesn't work for whatever reason, move the cursor manually and then use insertText() to print (echo() doesn't respect cursor position).

goose
Posts: 13
Joined: Sun Jun 14, 2009 2:51 pm

Re: deleteLine() versus echo()

Post by goose »

I am using deleteLine() before the echoes. That deletes the line and only shows the echoes, on the preceding line, when I scroll up and down first.

I'll have to screw around with the cursor positions and insertText() a bit, but it seems rather a lot of trouble for what seems like a simple substitution trigger :(

Edit:
Right.

Code: Select all

selectString(line,1)
replace("")

moveCursorEnd("main")
fg("blue")
insertText("SCRYING: ")

moveCursorEnd("main")
fg("yellow")
inserText(scrytar)

moveCursorEnd("main")
fg("blue")
insertText(" at ")

moveCursorEnd("main")
fg("white")
inserText(matches[3])

moveCursorEnd("main")
fg("blue")
insertText(" in ")

moveCursorEnd("main")
fg("white")
inserText(matches[2])
That's what I'm trying now. But that's just producing "SCRYING: " in yellow. Would it be possible to get a basic walkthrough on how to do this? From memory, the tintin equivalent (Which I'm guessing most MUDders should be able to interpret) of this specific problem would be something like:

Code: Select all

#sub {An image of %1 appears reflected within the bowl, shifting with the rippling water to display %2.} {<040>SCRYING: <030>$scrytar <040>at <070>%2 <040>in <070>%1}

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: deleteLine() versus echo()

Post by Heiko »

Looks like you've found a bug. I'll fix it. What happens if you do replace(" ") instead of replace("")?

goose
Posts: 13
Joined: Sun Jun 14, 2009 2:51 pm

Re: deleteLine() versus echo()

Post by goose »

putting a space in the replace() just adds an extra space after the yellow "SCRYING: " (seen when highlighting it)

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: deleteLine() versus echo()

Post by Heiko »

This script will fix your problem and do what you want:

Code: Select all

selectString(line,1)
replace("")  
resetFormat();  

    fg("red")
    echo("SCRYING: ")

    fg("yellow")
    echo("test1")

    fg("blue")
    echo(" at ")

    fg("white")
    echo("test2")

    fg("blue")
    echo(" in ")

    fg("white")
    echo("test3");
    
    fg("pink")
    echo(" ***END*** ")
I still consider this a bug though and will fix it.

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

insertText() outside of wordwrap

Post by Caled »

One thing I am really liking about insertText() is the ability to print text to the screen outside the wordwrap. Basically, I begin my wordwrap at 100 characters, and I have another 20-30 characters of blank space to the right of that point.

I echo short, important notes to myself about combat, to that free space, using the pecho() function I have posted to the scripts section.

Of course, this is also only possible if I print to the previous line, which has already had wordwrap applied to it. If I print to the current line, it gets wrapped to the next line (which is expected behavious, I know).

Do you know if there is a way I can make it print the text to the current line -after- wordwrap has been applied? To be honest I don't fully understand the contents of this thread, but I think this it is related, at least in part, to what I am trying to do. (Let me know if it isn't and I will report to a new thread if necessary).

Post Reply