@ThompZon Would you mind adding an example code for using this system in a timer please?
I want to use your suggestions to add some indicators to channeled spells that have a trigger running "every 0.03 seconds", but have troubles understanding how your code above works.
(
[Solved] - Parabola in GUI (don't know how to adjust X and Y of Point))
I changed it to fit his use-case better, but for simplicity, I use "how I use it" for this example.
First I have a trigger somewhere (above the "actual trigger") with this util function:
JASS:
//Max dots must be less than 25, or increase number of dots in "indicatorDots" variable to have a higher max.
function ChargeString takes integer currentDots, integer maxDots returns string
local string indicatorDots = "........................."
local string indicatorText = "|c003C14DC" + SubString(indicatorDots, 0, currentDots + 1) + "|r"
return SubString(indicatorText + SubString(indicatorDots, currentDots, StringLength(indicatorDots)), 0, 13 + maxDots) //12 chars for color-code + reset, then + 1, because index thingies...
endfunction
What it does is make first "currentDots" the hard-coded color, then "reset color" and have additional dots up to maxDots. The "|c003C14DC" is just a color and can be changed to your favorite color.
Then use it to charge up, and update a floating text, you need an integer variable that you need to keep track of "current charge" and the floatingtext.
I use a hashtable in this example.
Setup a floating text and save it.
Note that (Key ChargeUpFloatingText) is String hash.
-
TextSetup
-
Events
-
Unit - A unit Starts the effect of an ability
-
Conditions
-
Actions
-
Custom script: set udg_temp_string = ChargeString(0, 20)
-
Floating Text - Create floating text that reads temp_string above (Triggering unit) with Z offset 70.00, using font size 9.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
-
Hashtable - Save Handle Of(Last created floating text) as (Key (Triggering unit)) of (Key ChargeUpFloatingText) in heroes_hash
-
Hashtable - Save 0 as (Key (Triggering unit)) of (Key ChargeUp Value) in heroes_hash
-
Trigger - Turn on TextTick <gen>
Then update it in the "tick" trigger. Update the "charge counter", update the floating text.
Note that I don't have a way of keeping track of the unit with this minimal example, but otherwise MUI (each unit can have one).
-
TextTick
-
Events
-
Time - Every 0.10 seconds of game time
-
Conditions
-
Actions
-
Set temp_unit = Bounty Hunter 0158 <gen>
-
Custom script: set udg_temp_integer1 = GetHandleId(udg_temp_unit)
-
Set temp_floating_text = (Load temp_integer1 of (Key ChargeUpFloatingText) in heroes_hashIf the label is not found, this function returns NULL.)
-
Set temp_integer2 = (Load temp_integer1 of (Key ChargeUp Value) from heroes_hash) + 1
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
temp_integer2 Less than 20
-
Then - Actions
-
Hashtable - Save temp_integer2 as temp_integer1 of (Key ChargeUp Value) in heroes_hash
-
Custom script: set udg_temp_string = ChargeString(udg_temp_integer2, 20)
-
Else - Actions
-
Hashtable - Save 0 as temp_integer1 of (Key ChargeUp Value) in heroes_hash
-
Custom script: set udg_temp_string = ChargeString(0, 20)
-
Floating Text - Change text of temp_floating_text to temp_string using font size 9.00
Also note that this example does not keep tracks of what the unit is doing, updates the floating-text-position if unit moves and it "cycles" back to 0 upon reaching the max (20).
Of course, you want to have events if channeling stops, a way of destroying the floating text, etc.
This is my "low-tech bar-system"
Was this example good?
Edit: Attached test map (saved with version 1.31.1)