Jump to content

How i can change the color of a text?


Recommended Posts

I recently configured a mod to say a custom text, for example "My (Item) its almost broken", but now I would like to know how I can change the color of the text or make it customizable.

Spoiler

 

local function CheckItemAndSendWarning(item, equipslot)
    local warning_percent = items[equipslot][item.prefab]
    if warning_percent and item.replica.inventoryitem.classified
      and item.replica.inventoryitem.classified.percentused:value() <= warning_percent then
        ThePlayer.components.talker:Say("My "..item.name.." its almost broken!")
    end
end

 

someone could help me?

 

 

Link to comment
Share on other sites

I looked into the "talker" component real quick and it looks like the talker:Say function has a color parameter. The parameters look like this: (script, time, noanim, force, nobroadcast, colour, text_filter_context, original_author_netid, onfinishedlinesfn, sgparam), "script" being the string that's being said. So your code would look like this:

ThePlayer.components.talker:Say("My "..item.name.." its almost broken!", nil, nil, nil, nil, {0, 0, 0, 1})

Note how the color is a table. All of its values range from 0 to 1 and, in order, they are: red, green, blue, alpha. The first three are pretty self-explanatory if you understand how colors work, the alpha is simply the transparency of it. I recommend leaving that one to 1.

When it comes to RGB (red, green, blue), if you know the color you want to use and know its RGB values, I recommend writing it like this:

{0/255, 0/255, 0/255, 1}

Just replace each 0 with the respective RGB values of your color.

  • Big Ups 1
Link to comment
Share on other sites

1 hour ago, ariadnesGambit said:

I looked into the "talker" component real quick and it looks like the talker:Say function has a color parameter. The parameters look like this: (script, time, noanim, force, nobroadcast, colour, text_filter_context, original_author_netid, onfinishedlinesfn, sgparam), "script" being the string that's being said. So your code would look like this:

ThePlayer.components.talker:Say("My "..item.name.." its almost broken!", nil, nil, nil, nil, {0, 0, 0, 1})

Note how the color is a table. All of its values range from 0 to 1 and, in order, they are: red, green, blue, alpha. The first three are pretty self-explanatory if you understand how colors work, the alpha is simply the transparency of it. I recommend leaving that one to 1.

When it comes to RGB (red, green, blue), if you know the color you want to use and know its RGB values, I recommend writing it like this:

{0/255, 0/255, 0/255, 1}

Just replace each 0 with the respective RGB values of your color.

image.thumb.png.5829f1f34c47ff0f59759a9f71d74406.png

THANK YOU!!!!!!!

  • GL Happy 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...