• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Real to Integer in loop

Status
Not open for further replies.
Level 13
Joined
Jun 22, 2004
Messages
783
I bumped into something in the following trigger.


  • microTimer
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set microTimer = (microTimer + 0.10)
          • Game - Display to (All players) the text: (Micro Timer = + (String(microTimer)))
          • Game - Display to (All players) the text: (Timer = + (String((Integer((microTimer x 10.00))))))
What happens is that the "Timer"(3 action line) which translates the real number into a workable integer glitches at the begin of the loop.
When it hits the loop for the 3rd time, the integer remains 2. (it glitches at 4th time when I use 0.01 and multiply it by 100).

perhaps anyone can explain why this behaves in the fashion it does.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Well it works, yes. however when the real number says 0.03 the integer returns 2, which is supposed to be 3.

Well, I noticed something on the 30 or more second the counter begins to bug.

For example, I get the result 56.999 and 67.999. I think this is better done as JASS because GUI uses many function calls which may not give accurate results especially when dealing with loops.
 
Level 13
Joined
Jun 22, 2004
Messages
783
Well this has nothing to do with the loop (thats a different variable), I am talking about the conversion from real to integer that bugs, and I can't seem to find out why (it's not a vital problem, just something I noticed).
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
Sorry, i misread and thought you were displaying integer A value.
Starquizer is partially right, the problem is that you aren't adding exactly 0.10 (when you don't type the other decimals, the number isn't really accurate).
Try converting the trigger to JASS and instead of 0.10, type 0.100000 or so and it should work properly.
 
Status
Not open for further replies.
Top