Using colors on echo

Using colors on echo

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Using colors on echo

Post 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.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Using colors on echo

Post 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)
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Using colors on echo

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

Return to “Lua Scripts”