I'm creating units and attaching to them a text tag. If unit dies the text tag is removed automatically. But I have a problem with removing tags when I want to kill units using trigger. There is no data that can hold links to created text tags like unit group or player group. How to remove unused text tags? :)
yes there is a variable but I'm letting create units for player. There are unknown number of units with their tags. As for units I can add new unit to unit group and get to them all using Pick each unit from unit group but I cant do it with text tags.
If I knew there will be specific number of tags I could make specific number of tag variables or a array of them but I simply don't know it as it depends on player and game :P
here I give example what I can do:
Event:
Unit enter regionX
Action
create text tag with text "REGION UNIT" and attach it to triggering unit
Event:
120 secs of game time expires
Action:
**delete every text tag**
My question is how to delete them if I don't know how many units will enter regionX
I can use this function but problem is that I don't know how to store LIST of tags that are created during gameplay so I can delete them with delete text tag function.
I can create tag and delete last created tag - its easy
I can create tag and save it in variable then delete tag in variable - its easy
but
when a trigger creates tags (no one knows how many) then I couldn't find any data that can store those tags to delete them when I want to
probably not the most helpful, but i really dont get you gemGreg. you want to be able to create text tags, and not reference or store them in a varaible, but be able to destroy them whenever you want....
either you dont know about local variables (say for creating a text tag for 2 seconds then destroying it after 2 seconds without having to use global variables) or your whole method of programming is either way behind most everyone or you are leaps ahead of us.... unfortunately im going to guess the first option.
maybe youre wanting to wish there was a 'text tag group' like 'player group' so you could bunch a handful up then destroy them simotaneously. this is just a tool of convinience when it comes down to it. im going to suggest like everyone else; use a varaible (global or local). but i do think theyre auto garbage colelcted when attached to units and the unit gets destroyed like any other actor. so if it just fades to transparent after so long when you create it or whatnot then theres no need to destroy it if the unit gets destroyed/killed soon enough. and even then i doubt enough could stack up on a unit to warrant any performance issues. not the best thing to suggest, but still a fact of sc2 auto garbage colelction system regardless to keep in mind-
I think I understand your problem, and I beleive if you gave us more information about your map and how it works, it could easily be solved.
If I understand you right, you would need something like :
1) A global variable named: "textTags", type: text tag, set it to array and put the size to let say 100 (I dont know what is the limit in SC2).
2) A global variable named: "numberOfTextTags": type: interger, initial value = 0 (this will be counting the numbers of text tags that were handed out between the wipes
3) Your normal trigger that hands out the text tags:
ie:
Event: "unit does this"
Action: - Create text tag "hello"
- set variable "textTags[numberOfTextTags]" = last created text tag
- attach last created text tag to triggering unit
- numberOfTextTags = numberOfTextTags + 1 (<<< this is the arithmetic function)
4) Your second trigger that wipes the text tags: (this is a loop that will wipe the array "textTags" which stored all the previous tags in itself
ie:
Event: "Unit dies"
local variable: localClearingCounter = 0 (integer)
Action: - WHILE "localClearingCounter" < numberOfTextTags DO
-Destroy text tags "textTags[localClearingCounter]"
- set variable "numberOfTextTags = 0" (to reset it, you dont have to refresh the local variables as they will reset themselves when the trigger fire itself)
I know that can be messy to understand, but hopefully it helped a bit.. good luck and don't hesitate to ask if you need more help.
ps: global variable are set in the left pannel (where you see triggers) while local variable are set INSIDE the triggers (in the right pannel, those cannot be accessed by other triggers)
I'm creating units and attaching to them a text tag. If unit dies the text tag is removed automatically. But I have a problem with removing tags when I want to kill units using trigger. There is no data that can hold links to created text tags like unit group or player group. How to remove unused text tags? :)
Um, yes there is.
You can create a variable of type "Text Tag".
@RileyStarcraft: Go
yes there is a variable but I'm letting create units for player. There are unknown number of units with their tags. As for units I can add new unit to unit group and get to them all using Pick each unit from unit group but I cant do it with text tags. If I knew there will be specific number of tags I could make specific number of tag variables or a array of them but I simply don't know it as it depends on player and game :P
cant you use the "destroy text tag" funtion ?
@Koronis
I can use this function but problem is that I don't know how to store LIST of tags that are created during gameplay so I can delete them with delete text tag function.
I can create tag and delete last created tag - its easy
I can create tag and save it in variable then delete tag in variable - its easy
but
when a trigger creates tags (no one knows how many) then I couldn't find any data that can store those tags to delete them when I want to
@gemGreg: Go
probably not the most helpful, but i really dont get you gemGreg. you want to be able to create text tags, and not reference or store them in a varaible, but be able to destroy them whenever you want....
either you dont know about local variables (say for creating a text tag for 2 seconds then destroying it after 2 seconds without having to use global variables) or your whole method of programming is either way behind most everyone or you are leaps ahead of us.... unfortunately im going to guess the first option.
maybe youre wanting to wish there was a 'text tag group' like 'player group' so you could bunch a handful up then destroy them simotaneously. this is just a tool of convinience when it comes down to it. im going to suggest like everyone else; use a varaible (global or local). but i do think theyre auto garbage colelcted when attached to units and the unit gets destroyed like any other actor. so if it just fades to transparent after so long when you create it or whatnot then theres no need to destroy it if the unit gets destroyed/killed soon enough. and even then i doubt enough could stack up on a unit to warrant any performance issues. not the best thing to suggest, but still a fact of sc2 auto garbage colelction system regardless to keep in mind-
@gemGreg, excuse my delayed answer :3
I think I understand your problem, and I beleive if you gave us more information about your map and how it works, it could easily be solved.
If I understand you right, you would need something like :
1) A global variable named: "textTags", type: text tag, set it to array and put the size to let say 100 (I dont know what is the limit in SC2).
2) A global variable named: "numberOfTextTags": type: interger, initial value = 0 (this will be counting the numbers of text tags that were handed out between the wipes
3) Your normal trigger that hands out the text tags:
ie:
Event: "unit does this"
Action: - Create text tag "hello"
- set variable "textTags[numberOfTextTags]" = last created text tag
- attach last created text tag to triggering unit
- numberOfTextTags = numberOfTextTags + 1 (<<< this is the arithmetic function)
4) Your second trigger that wipes the text tags: (this is a loop that will wipe the array "textTags" which stored all the previous tags in itself
ie:
Event: "Unit dies"
local variable: localClearingCounter = 0 (integer)
Action: - WHILE "localClearingCounter" < numberOfTextTags DO
-Destroy text tags "textTags[localClearingCounter]"
- set variable "numberOfTextTags = 0" (to reset it, you dont have to refresh the local variables as they will reset themselves when the trigger fire itself)
I know that can be messy to understand, but hopefully it helped a bit.. good luck and don't hesitate to ask if you need more help.
ps: global variable are set in the left pannel (where you see triggers) while local variable are set INSIDE the triggers (in the right pannel, those cannot be accessed by other triggers)