Jump to content

Recommended Posts

Talker component has a table variable you can set colour.

Taken from components/talker.lua:37-39:

    if inst.components.talker.colour then
        inst.components.talker.widget.text:SetColour(inst.components.talker.colour.x, inst.components.talker.colour.y, inst.components.talker.colour.z, 1)
    end

 

1 hour ago, LordTrolldork said:

Sorry I'm replying so late, I didn't see this, but where exactly do I put this code?

Under the assumption that this is a custom character.

 

Let's look at prefabs/wilson.lua and prefabs/player_common.lua.

prefabs/player_common.lua:19, 187, 304-306::

local function MakePlayerCharacter(name, customprefabs, customassets, customfn, starting_inventory)
...
        inst:AddComponent("talker")
...
        if customfn then
            customfn(inst)
        end

prefabs/wilson.lua:16, 43, 45::

local fn = function(inst)
...
end
...
return MakePlayerCharacter("wilson", prefabs, assets, fn)

So in this case the prefabs/player_common.lua puts in the talker component which enables the text-over-the-head and sounds.

If we wanted to make all Wilsons talk in pure red, we would edit the function 'fn' in prefabs/wilson.lua.

This is a callback defined in prefabs/player_common.lua's MakePlayerCharacter that happens after all of the base player components are loaded in.

 

Thus Wilson's 'fn' would have:

    inst.components.talker.colour = {}
    inst.components.talker.colour.x = 255.0/255.0
    inst.components.talker.colour.y =   0.0/255.0
    inst.components.talker.colour.z =   0.0/255.0

 

 

If this isn't for a custom character, then you would need to add a prefab post init with it checking for the talker component and finally adding in your custom colouring.

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
×
  • Create New...