• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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