• 🏆 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!

Arithmetic comparison fails D:

Status
Not open for further replies.
Hello there :D

I've run into a strange problem here... An arithmetic comparison simply fails:

JASS:
set Time = Time + 0.05
if Time >= TrainingTime then
    call this.Finish() // This will create a unit
endif

This portion of code is run every 0.05 second. However the method Finish is only called then Time > TrainingTime (noticed that by using game messages)

If I change the comparison to

JASS:
if Time == TrainingTime then

Then it works as it should...
What could be causing it and how to solve it?

Thanks!
Hossomi
 
I have tried using integers like InfinateAnswers said. However that way I get another problem:

JASS:
local integer Percent = Time/TrainingTime*50
//50 is the size of a life bar, let's say

That will always return 0 or 1 no matter what value that division results. I've also tried using R2I in all possible ways xD
Even if the variable was real, the result was the same. Looks like dividing integers will always return only the integer part of the result, so I tried converting both values to real using R2I. Same result, though...
 
Status
Not open for further replies.
Top