• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Lua] GetPlayerColorTexture

A small Lua function to get the PlayerColor FilePath of a player, the function respects enabled ally-enemy color mode. Might be of use in custom UI code.
Lua:
--By Tasyen
---GetPlayerColorTexture
---@param player player
---@param enforcePlayerColor? boolean  (true) ignore enemy ally color mode
---@return string
function GetPlayerColorTexture(player, enforcePlayerColor)
    -- normal mode
    if GetAllyColorFilterState() == 0 or enforcePlayerColor then
        if GetHandleId(GetPlayerColor(player)) < 10 then
            return "ReplaceableTextures\\TeamColor\\TeamColor0"..GetHandleId(GetPlayerColor(player))
        else
            return "ReplaceableTextures\\TeamColor\\TeamColor"..GetHandleId(GetPlayerColor(player))
        end
    else
    -- enemy friend self mode
        if player == GetLocalPlayer() then
            return "ReplaceableTextures\\TeamColor\\TeamColor01"
        elseif player == Player(PLAYER_NEUTRAL_AGGRESSIVE) then
            return "ReplaceableTextures\\TeamColor\\TeamColor24"
        elseif IsPlayerAlly(player, GetLocalPlayer()) then
            return "ReplaceableTextures\\TeamColor\\TeamColor02"
        elseif IsPlayerEnemy(player, GetLocalPlayer()) then
            return "ReplaceableTextures\\TeamColor\\TeamColor00"
        else
            return "ReplaceableTextures\\TeamColor\\TeamColor00"
        end
    end
end
 
Last edited:
Top