# [Solved] Modulo Does not always work on Real Numbers

Discussion in 'Triggers & Scripts' started by Veronnis, Aug 14, 2019.

1. ### Veronnis

Joined:
Jul 19, 2010
Messages:
134
Resources:
6
Models:
2
Icons:
1
Maps:
3
Resources:
6
Does anyone know what I'm doing wrong here? I don't understand why this is failing, please note the problem appears to be caused solely by the Modulo condition, as everything works fine when it's gone. Purpose: Use the modulo as a frequency interval for the spell's effect.

• Curse a Unit
• Events
• Player - Player 1 (Red) issues Mouse Down event
• Conditions
• (Trigger Mouse Button) Equal to Left Mouse Button
• Actions
• Set DOTsActive = (DOTsActive + 1)
• Set TimeCounter[DOTsActive] = 0.00
• Set EffectModulo[DOTsActive] = 0.50
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• DOTsActive Equal to 1
• Then - Actions
• Trigger - Turn on Effect Loop <gen>
• Else - Actions

• Effect Loop
• Events
• Time - Every 0.10 seconds of game time
• Conditions
• Actions
• For each (Integer GenericLoopCount) from 1 to DOTsActive, do (Actions)
• Loop - Actions
• Set TimeCounter[GenericLoopCount] = (TimeCounter[GenericLoopCount] + 0.10)
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (TimeCounter[GenericLoopCount] mod EffectModulo[GenericLoopCount]) Equal to 0.00
• Then - Actions
• -------- Make an explosion --------
• Else - Actions
• -------- Do nothing --------

2. ### Pyrogasm

Joined:
Feb 27, 2007
Messages:
2,793
Resources:
1
Spells:
1
Resources:
1
Operations on real numbers aren't always precise so you are probably simply not getting a modulo remainder of exactly 0. If you change that condition to < 0.10 (or some other small number) I anticipate it will work. This is why it is generally always recommended to use integers for time counters, not reals.

3. ### Veronnis

Joined:
Jul 19, 2010
Messages:
134
Resources:
6
Models:
2
Icons:
1
Maps:
3
Resources:
6
I appreciate your response and thought this might be the case. Since the string return was yield 0.00 I thought I would be good, but in reality its probably 0.00001 or something. Thanks for the verification!