• 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.

[vJASS] SetTextTagColor to a non defualt hides the texttag?!

Status
Not open for further replies.
Level 2
Joined
Jul 1, 2012
Messages
25
JASS:
        local Town this = 1
        local integer numberOfTowns
        local unit u
        local texttag tt
            loop
                set u = this.town
                set this.townX = GetUnitX(u)
                set this.townY = GetUnitY(u)
                
                //Town Texttag
                set tt = CreateTextTag()
                call SetTextTagText(tt, this.townName, 13.5 * 0.0023)
                call SetTextTagPos(tt, this.townX - 50, this.townY + 15, 0.0)
                call SetTextTagPermanent(tt, true)
                call SetTextTagColor(tt, 255, 220, 0, 255)
                //call colorTag(tt, this.townType)
                
                //Loop functions
                exitwhen this == numberOfTowns
                set this = this + 1
            endloop

Hello I got this function here that bugs me a little. I am creating a texttag 8 times (the value of numberOfTowns) that i want to set the color of. However setting the color only works for 3 of them, the rest turn invisible. If I don't set the color or set it to the deafult (tt, 255, 255, 255, 255) they all remain visible.

I'm totally clueless, anyone else has encountered this before?
 
i do it this way i made a function w a string array
JASS:
private function PlayerColorSetting takes nothing returns nothing
    //-------- Player colors. --------
    set playerColors[0] = "|c00ff0303" //red p0
    set playerColors[1] = "|c000042ff" //blue p1
    set playerColors[2] = "|c001ce6b9" //teal p2
    set playerColors[3] = "|c00540081" //purple p3
    set playerColors[4] = "|c00fffc01" //yellow
    set playerColors[5] = "|c00feba0e" //orange
    set playerColors[6] = "|c0020c000" //green pc
    set playerColors[7] = "|c00e55bb0" //pink
    //-------- Gold color --------
    set playerColors[8] = "|cffffcc00" //gold    
endfunction
basically to make it work i do

JASS:
    local string color = "|r"
    call MultiboardSetItemValue( mbi, playerColors[8] + "Round" + color )

this way round will be colored
 
Level 2
Joined
Jul 1, 2012
Messages
25
i do it this way i made a function w a string array
JASS:
private function PlayerColorSetting takes nothing returns nothing
    //-------- Player colors. --------
    set playerColors[0] = "|c00ff0303" //red p0
    set playerColors[1] = "|c000042ff" //blue p1
    set playerColors[2] = "|c001ce6b9" //teal p2
    set playerColors[3] = "|c00540081" //purple p3
    set playerColors[4] = "|c00fffc01" //yellow
    set playerColors[5] = "|c00feba0e" //orange
    set playerColors[6] = "|c0020c000" //green pc
    set playerColors[7] = "|c00e55bb0" //pink
    //-------- Gold color --------
    set playerColors[8] = "|cffffcc00" //gold    
endfunction
basically to make it work i do

JASS:
    local string color = "|r"
    call MultiboardSetItemValue( mbi, playerColors[8] + "Round" + color )

this way round will be colored

Yes I used something simmilar to this before but opted for this new way because it looks better to me and is easier to follow. Also of general interest in the way wc3 works i want to know why my way won't work.
 
Level 2
Joined
Jul 1, 2012
Messages
25
local integer numberOfTowns
Give it some value and make sure the loop can hit that number.

Alright I guess I wasn't clear enough I'll post the whole trigger:

JASS:
function createTowns takes Town this, unit u, string townNameString, integer townTypeInt returns nothing
        set this.town = u
        set this.townName = townNameString
        set this.townType = townTypeInt
        set u = null
    endfunction

function setTownNames takes nothing returns Town
        local Town this = 1
            call createTowns(this, gg_unit_h001_0005, "name", LUMBER_TYPE)
            set this = this + 1
            call createTowns(this, gg_unit_h001_0004, "name", LUMBER_TYPE)
            set this = this + 1
            call createTowns(this, gg_unit_h001_0002, "name", TRADE_TYPE)
            set this = this + 1
            call createTowns(this, gg_unit_h001_0003, "name", LUMBER_TYPE)
            set this = this + 1
            call createTowns(this, gg_unit_h001_0007, "name", GOLD_TYPE)
            set this = this + 1
            call createTowns(this, gg_unit_h001_0008, "name", GOLD_TYPE)
            set this = this + 1
            call createTowns(this, gg_unit_h002_0001, "name", TRADE_TYPE)
            set this = this + 1
            call createTowns(this, gg_unit_h003_0000, "name", GOLD_TYPE)
        return this
    endfunction

JASS:
    function initializeTownsAction takes nothing returns boolean
        local Town this = 1
        local integer numberOfTowns
        local unit u
        local texttag tt
        
            set numberOfTowns = setTownNames()//Returns 8
            loop
                set u = this.town
                set this.townX = GetUnitX(u)
                set this.townY = GetUnitY(u)
                
                //Town Texttag
                set tt = CreateTextTag()
                call SetTextTagText(tt, this.townName, 13.5 * 0.0023)
                call SetTextTagPos(tt, this.townX - 50, this.townY + 15, 0.0)
                call SetTextTagPermanent(tt, true)
                call SetTextTagColor(tt, 255, 220, 0, 255)
                //call colorTag(tt, this.townType)
                
                //Loop functions
                exitwhen this == numberOfTowns
                set this = this + 1
            endloop
        set u = null
        set tt = null
        return false
    endfunction

    //===========================================================================
    function InitTrig_Initialize_Towns takes nothing returns nothing
        set gg_trg_Initialize_Towns = CreateTrigger()
        call TriggerAddCondition(gg_trg_Initialize_Towns, Filter(function initializeTownsAction))
    endfunction

This is ofc an initialization trigger, and the loop always works.
 
Status
Not open for further replies.
Top