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

[Solved] floating text trigger sometimes work sometimes don't

Status
Not open for further replies.
Level 4
Joined
Sep 11, 2018
Messages
74
Sometimes after countdown '3' it disappears without '2' and '1'. Sometimes it works well. Sometimes only '3' and '2' work. Any idea?
1problem.jpg
 

Dr Super Good

Spell Reviewer
Level 65
Joined
Jan 18, 2005
Messages
27,290
Using Integer A, which is a global variable, in a non-instant way. Basically if any other Integer A loop runs during that time it will break.

Solution is to use either a local variable (JASS) or a unique global variable for this trigger (if only 1 thread of the trigger can exist at any time). If the trigger can fire multiple times at once then one has to use an instancing system.

Might also be a good idea to use a timer instead of Wait as timers are accurate to game time.
 
Level 4
Joined
Sep 11, 2018
Messages
74
You can also locally shadow Integer A so it behaves as a local integer (like Dr Super Good suggested JASS can do) but can be accessed in GUI by putting this as the first line of your actions:
  • Actions
    • Custom script: local integer bj_forLoopIndexA = 0
It doesn't work. Same problem still occurs
 
@Pyrogasm Not quite.
Referencing Integer A in GUI calls a Blizzard.j function which will return the value of the global variable.
For this to work you'd have to shadow both bj_forLoopAIndex and bj_forLoopAIndexEnd and read from bj_forLoopAIndex directly inside the loop.
  • Actions
    • Custom script: local integer bj_forLoopAIndex
    • Custom script: local integer bj_forLoopAIndexEnd
    • For each (Integer A) from 1 to 10, do (Actions)
      • Loop - Actions
        • Custom script: set udg_IntVar = bj_forLoopAIndex
At this point you might as well just use a unique global variable as the doctor suggested and shadow it if needed.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
I actually had no idea the end index was stored globally; makes complete sense, but I didn't think about it. Since you can't shadow two variables that won't work either. I also had it as IndexA rather than AIndex, which is other the reason what I wrote didn't work. All around not a good solution to try shadowing.
 
Since you can't shadow two variables that won't work either.
You can shadow any number of global variables as far as I know.
So which one is the solution? I'm at lost here.
Use a For Each Integer Variable loop instead of the Integer A one and create a new unique integer variable for it.
Let the floating text destroy itself so that we don't have to worry about the Last Created Floating Text getting overwritten elsewhere during the wait.
If the trigger cannot run more than once at a time, you can drop the custom script action, otherwise make sure the variable name in the custom script matches the name of your loop variable but with the "udg_" prefix attached.
  • Actions
    • Custom script: local integer udg_MyIntegerVariable
    • For each (Integer MyIntegerVariable) from 1 to 3, do (Actions)
      • Loop - Actions
        • Floating Text - Create floating text that reads countdown[MyIntegerVariable] at (Center of duelmainlocation) with Z offset 0.00, using font size 30.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
        • Floating Text - Change (Last created floating text): Disable permanence
        • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
        • Wait 1.00 seconds
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
You can shadow any number of global variables as far as I know.
Tested and I was able to shadow two integers properly. Was the single variable thing just a myth perpetuated from years ago? I remember it not being a viable solution for MUI-ability in GUI many times because you couldn't shadow too many variables.

To reiterate: do what Illidan suggested.
 
Status
Not open for further replies.
Top