line = getCurrentLine() doesn't update line variable globally - does wiki just mean line variable is locally updated?

Post Reply
Lucky24
Posts: 51
Joined: Sun Sep 12, 2010 1:50 am

line = getCurrentLine() doesn't update line variable globally - does wiki just mean line variable is locally updated?

Post by Lucky24 »

In short: I want to replace text and have triggers that match after the first one match on the replaced text instead of the original. Wiki seems to indicate after running 'replace(text)' that doing 'line = getCurrentLine()' should update line for subsequent triggers to the replaced line text, but this does not seem to work for me in 4.91.

So, I'm looking at the getCurrentLine() documentation in the wiki, and it seems to indicate doing the following should update the "line" variable after running replace(), but it doesn't seem to be doing that for my triggers in 4 .9.1:

line = getCurrentLine()


Here's the Trigger:

Trigger Match (substring): "

Trigger Body:
local numOfMatches = #matches
for i=1,numOfMatches,1 do
selectString(tostring(matches),1)
replace([["]])
deselect()
end
line = getCurrentLine()

On the next trigger, the line variable is back to what it was before the replace() was run

From:
https://wiki.mudlet.org/w/Manual:UI_Functions

"When triggers change the content of the buffer, the variable line will not be adjusted and thus hold an outdated string. line = getCurrentLine() will update line to the real content of the current buffer. "

Does line get fed to each trigger, regardless of what a trigger does to the line variable? If so, it seems like parsing some URI/HTML codes on the first trigger, so that subsequent triggers match the same text as what's displayed on the console is not possible.

This is necessary because my MUD uses HTML formatting and URI encoding, so I'm trying to parse out all the HTML encoded characters (& etc), and not make people have to match those pre-parsed & and " and < and > in their triggers they define below this top-level replace().

Lucky24
Posts: 51
Joined: Sun Sep 12, 2010 1:50 am

Re: line = getCurrentLine() doesn't update line variable globally - does wiki just mean line variable is locally updated

Post by Lucky24 »

What's really weird, is that if I do a feedTriggers([[&quot]]), triggers below the selectString([["]]); replace([["]]); line=getCurrentLine() do match properly the replaced character (this replaces " with a single quote), but lines that arrive from the server do not, and still use the original line variable, before the replace.

User avatar
demonnic
Posts: 650
Joined: Sat Dec 05, 2009 3:19 pm

Re: line = getCurrentLine() doesn't update line variable globally - does wiki just mean line variable is locally updated

Post by demonnic »

The line variable and what the triggers match against are not the same thing per se. The triggers are always checked against the output from the game itself, even if you change what is held in the line variable. Also the line variable only holds text, whereas triggers can match based on ansi color, telnet GA signal arriving with the line, etc.

User avatar
SlySven
Posts: 960
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: line = getCurrentLine() doesn't update line variable globally - does wiki just mean line variable is locally updated

Post by SlySven »

Which MUD - and are you sure you are not seeing MXP stuff?

Post Reply