Alternative colors on say/tell/group/buddy

Post Reply
noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Alternative colors on say/tell/group/buddy

Post 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

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

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

Post 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?

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

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

Post 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()

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

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

Post 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

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

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

Post 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.

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

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

Post by noblestone »

Thanks :)

Post Reply