Page 1 of 1

Alternative colors on say/tell/group/buddy

Posted: Fri Nov 21, 2014 2:00 am
by noblestone
Whats proper script for this, just for fun.

Alternative color per line, then next line different color. Auto select random colors. Any ideas?

Help would be appreciated! Thanks

Re: Alternative colors on say/tell/group/buddy

Posted: Fri Nov 21, 2014 10:16 pm
by noblestone
Code: [show] | [select all] lua
function bcol(args)
        local str = ""
        local colours = { "|C|", "|W|",  "|Y|", "|BW|" }
        local pass = 1

        for char in args:gmatch"." do
                str = str .. colours[pass] .. char
                if pass == #colours then pass = 1 end
                pass = math.random (1,4)
        end

        return (str)
end
That is for random colors inside sentence, what I want is random color per sentence i entered, like say hey there. then say I am fine, both random colors, how?

Re: Alternative colors on say/tell/group/buddy

Posted: Sat Nov 22, 2014 5:23 am
by Belgarath
You can use the global color_table to pick out one per line.
Code: [show] | [select all] lua
local t = {}
for k in pairs(color_table) do t[#t+1] = k end
local col = t[math.random(#t)]
fg(col)
resetFormat()

Re: Alternative colors on say/tell/group/buddy

Posted: Sat Nov 22, 2014 5:47 am
by noblestone
My alias for buddy set is:

^b (.*)$

triggers:

send( "b |n|{" ..bcol("Apoc") .. "|n|} |c|" .. matches[2] )

However I want that random color script to only work on matches[2]

In game colors are B BB C BC P BP BW W BG G Y BY R BR - you get the drift.

Doable? How? Thanks

Re: Alternative colors on say/tell/group/buddy

Posted: Sat Nov 22, 2014 6:51 am
by Belgarath
Yes, whatever you're asking is doable. How? Edit your alias: ^b(?: (.*))?$

Then it is simple if..then logic.

I'm still unsure what you want to do with your script/alias, but looking at your example there, you'll want to call it with expandAlias, not send.

You're welcome.

Re: Alternative colors on say/tell/group/buddy

Posted: Sat Nov 22, 2014 6:56 am
by noblestone
Thanks :)