Page 1 of 1

Using colors on echo

Posted: 15 Jun 2017, 04:53
by Forboding Angel
All last night I was fighting with this.

In my resource bar widget I was adding audiovisual prompts for when someone is fucking up their eco. On the resourcebar metal is colored a light blue, energy yellow and supply green, so I wanted to add colors messages matching this scheme.

I was originally using echos to do it, but the color works only for the first message sent. After that, the messages don't show at all and echos from other widgets will display ÆÆ before the echo.

I also went so far as to use sendmessagetoplayer with the exact same results:
Image

A very simplistic example of what I was doing boils down to this:

Code: Select all

local skyblue = "\255\136\197\226"
if resourcePrompts ~= 0 then
    Spring.PlaySoundFile("sounds/ui/useyourmetal.wav", 1)
    Spring.SendMessageToPlayer(myPlayerID,skyblue..[[You are excessing metal! Consider using O.R.B.s to build units faster and spend metal more effectively!]])
end
Gajop had me try adding \b at the end of the string, but I got no satisfactory results.

Re: Using colors on echo

Posted: 10 Jul 2017, 19:55
by abma
is resourcePrompts changed afterwards? does the code run at all?

the code run multiple times in a widget worked for me:

Code: Select all

local skyblue = "\255\136\197\226"
if resourcePrompts ~= 0 then
    Spring.PlaySoundFile("sounds/ui/useyourmetal.wav", 1)
    Spring.SendMessageToPlayer(0,skyblue..[[You are excessing metal! Consider using O.R.B.s to build units faster and spend metal more effectively!]])
end
(assuming you are currently player 0)

Re: Using colors on echo

Posted: 10 Jul 2017, 21:32
by Forboding Angel
That is run in a loop that is checking for warninglevel. I tried coloring in another widget and got the same results.

It's this widget: https://github.com/EvolutionRTS/Evoluti ... rceBar.lua