• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Mod below 1

Status
Not open for further replies.
Level 13
Joined
Jun 22, 2004
Messages
783
Quick question, I was just trying something out something mathematical in the editor, however I bumped into something.

Example:
0.100 mod 0.100

Normally this would result in 0.000 however according to the editor it returns me 0.100. Anyone experience the same thing, if so does anyone know why?

cheers
 
Level 13
Joined
Jun 22, 2004
Messages
783
Divisor is set in another trigger that also calls the trigger in question.

  • Set _timerInterval = 0.10
  • Set _timerMax = 5.00
  • Trigger - Turn on Timer <gen>
The Trigger looks like this:

  • Timer
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • _timerTracker Less than _timerMax
        • Then - Actions
          • If (_timerTracker Equal to 0.00) then do (Set _timerActive = True) else do (Do nothing)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • _timerPaused Equal to False
            • Then - Actions
              • Set _timerTracker = (_timerTracker + 0.01)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (_timerInterval mod _timerTracker) Equal to _timerInterval
                • Then - Actions
                  • Game - Display to (All players) the text: (Timer = + (String(_timerTracker)))
                • Else - Actions
            • Else - Actions
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • -------- Reset settings --------
          • Set _timerTracker = 0.00
          • Set _timerActive = False
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,206
The modulo opperator makes no sense in real based calculations. How can an opperator which returns the remainder left from integer division be applied to real numbers where there is no remainder from division?

You have 2 approaches to this problem.
1. Write your own function that takes 2 reals and returns a real that meets your requirements.
2. Change your input into integers which do comply with the behaviour of the modulus opperation.

In your case I think 2 is the more sensible approach. I think the behaviour you want will be obtained by multiplying both input reals to whole numbers, performing the modulus and then dividing them back into reals by dividing by the multiple (transform scale twice).
 
Level 13
Joined
Jun 22, 2004
Messages
783
Well the reason I used modulo on decimal numbers in the first place cause I was allowed to use it with a real number (thinking it would be a modf(or something similar function)) but I couldn't come to a conclusion as to why it would result 0.100 (the same number as the divisor). Anyway I did a simple work around the condition, which looks like this:


  • ((Integer((_timerTracker x 100.00))) mod (Integer((_timerInterval x 100.00)))) Equal to 0
Cheers for the extra info
 
Status
Not open for further replies.
Top