Okay, I have been able to modify Garrion's ChatWindow plugin to suit my game. It even captures colors from the styles, but because I need it to break up lines, I am having an issue on how to iterate or break up the style. What happens, is as long as the line is shorter than the window, it looks perfect but if it has to go into the part where it needs to be broken up, I don't know what to do with the style to properly break it up, so it doesn't keep sending the whole thing. Here's the code for anyone interested: http://mushclient.pastebin.com/d11c28506. The area that I'm having problems with is this:
Any suggestions on how to handle this properly or in a way that will work would be appreciated.
Thanks a bunch,
KeB
-- capture chats
function chats (name, line, wildcards, styles)
if #line < wrap_column then
add_line (styles) --Works fine
refresh()
return
end -- if
-- wrap long lines, at a space if possible
if #line >= 1 then
while #line > wrap_column do
-- find a space not followed by a space, closest to the end of the line
local col = string.find (line:sub (1, wrap_column), "%s%S*$")
if col and col > 2 then
col = col - 1 -- use the space to indent
else
col = wrap_column -- just cut off at wrap_column
end -- if
-- add_line (line:sub (1, col))
add_line( styles ) --Keeps sending the full style
line = line:sub (col + 1, #line)
refresh()
end -- while line > max
end -- if
if #line > 0 then
add_line (styles)
refresh()
end
end -- chats
Any suggestions on how to handle this properly or in a way that will work would be appreciated.
Thanks a bunch,
KeB