Kryz Posted May 20, 2023 Share Posted May 20, 2023 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 https://forums.kleientertainment.com/forums/topic/147882-how-i-can-change-the-color-of-a-text/ Share on other sites More sharing options...
ClumsyPenny Posted May 20, 2023 Share Posted May 20, 2023 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. 1 Link to comment https://forums.kleientertainment.com/forums/topic/147882-how-i-can-change-the-color-of-a-text/#findComment-1635926 Share on other sites More sharing options...
Kryz Posted May 20, 2023 Author Share Posted May 20, 2023 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. THANK YOU!!!!!!! 1 Link to comment https://forums.kleientertainment.com/forums/topic/147882-how-i-can-change-the-color-of-a-text/#findComment-1635930 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now