Mudlet features and API requests

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: Mudlet API requests

Post by Rakon »

I hear that a lot. 'It's not a bug, its a feature.' However, I do not agree with you. This is a bug. Copy (if its stated intention is to copy the formatting of a line over) then it needs to copy ALL formatting over, regardless of if the formatting is from a permTrigger or a TempTrigger. Currently this is not the case, and THIS is a bug.

Yetzederixx
Posts: 186
Joined: Sun Nov 14, 2010 5:57 am

Re: Mudlet API requests

Post by Yetzederixx »

When I created my highlighting triggers I used functions to return a color value useable by cecho, then I strip out the name, only one name per line on mine, prefix (WAR) or black space and then prefix [GROUP ID] and finally color the name, and then echo it wherever I want.

Code: Select all

     [BR]Kulek                        Conclave Common Room
(WAR)[WR]Cedany                       Meeting Room
Code: [show] | [select all] lua
-- something to this effect
cecho("windowname", getColor(name) .. " " .. name)

User avatar
Vadi
Posts: 5050
Joined: Sat Mar 14, 2009 3:13 pm

Re: Mudlet API requests

Post by Vadi »

It's not a bug, it is copying all of the formatting at the time you called copy.

Perhaps a postProcessing event would be nice - I think I needed it for something else as well, if it won't impact performance too much.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Mudlet API requests

Post by tsuujin »

an alternate solution may be to simply parse triggers as they're appended into miniconsoles.

User avatar
Vadi
Posts: 5050
Joined: Sat Mar 14, 2009 3:13 pm

Re: Mudlet API requests

Post by Vadi »

You mean re-parse triggers on lines that were appended? That'd require the triggers then to know their context...

Yetzederixx
Posts: 186
Joined: Sun Nov 14, 2010 5:57 am

Re: Mudlet API requests

Post by Yetzederixx »

Z/CMUD use tabbed windows which have their own settings. This may be what tsuujin is semi-suggesting, an ability to have miniconsoles to have their own triggers.

setTempTrigger("window", pattern, commands) ??

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Mudlet API requests

Post by tsuujin »

Ok, I've got something -partially- working.
Code: [show] | [select all] lua
function grabFormattedChannel(channel)
	count = 0
	-- See how many lines up the channel starts.
	moveCursorEnd("main")
	while selectString(channel,1) == -1 do
		if count > 5 then break end -- failsafe. Nothing should be longer than this...	
		moveCursor("main",0,getLineCount()-count)
		
		count = count + 1
	end
	-- now just move it back to start!
	while count > 0 do
		count = count - 1
		moveCursor("main",0,getLineCount()-count)
		selectCurrentLine()
		copy()
		appendBuffer("main chat")
		deselect()
	end
	moveCursorEnd("main")
end
if you just call it from the command line or an alias with some test word as the channel, it works great. However, if you attempt to call it from a tempLineTrigger(1,1...) then it does -not- work. I haven't figured out why this is yet, but the function itself is sound.

All it does is work backwards from the last line until it finds the string you use for "channel" and then works from that point forwards appending as it goes.

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

Re: Mudlet API requests

Post by Heiko »

@Tsujin
Your script doesn't work in trigger mode because the current line that is being triggered on hasn't been wrapped yet and is represented in the buffer as one long line that includes all line breaks.

A few functions behave differently when in trigger mode (especially echo() and insertText(). However, if you run your script on any other buffer but the main console i.e. the mini console where you actually paste your copied text, it should work perfectly - also in trigger mode.

@Rakon
Your analysis of the problem is correct. However, changing the execution order of tempTrigs from bottom to top wouldn't really solve the problem in a general way because you might define tempTriggers that are dependent on some other trigger that is executed at a later point in time. A proper solution would be to add the same kind of forced order of parent->child execution that is being enforced for permanent trigger objects to tempTriggers. You could then make your own tempTrigger chains. I'll add something like this in the future.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Mudlet API requests

Post by tsuujin »

Heiko wrote:@Tsujin
Your script doesn't work in trigger mode because the current line that is being triggered on hasn't been wrapped yet and is represented in the buffer as one long line that includes all line breaks.

A few functions behave differently when in trigger mode (especially echo() and insertText(). However, if you run your script on any other buffer but the main console i.e. the mini console where you actually paste your copied text, it should work perfectly - also in trigger mode.
Isn't this the point of a tempLineTrigger? To process something after the wrapping on the current line has already been done, and be able to go backwards?

User avatar
Vadi
Posts: 5050
Joined: Sat Mar 14, 2009 3:13 pm

Re: Mudlet API requests

Post by Vadi »

It's one of the uses... not the whole point though, I'd say. The 'span over multiple lines without requiring a trigger pattern' lends itself to easy 'forward' on-demand triggers.

Post Reply