Finding a Multiple in a Variable

Discussion in 'RPG Maker MV' started by BloodletterQ, Nov 14, 2015.

    Tags:
  1. BloodletterQ

    BloodletterQ Chaotic Neutral Assassin Veteran

    Messages:
    1,447
    Likes Received:
    1,044
    Location:
    My head's in the clouds at least...
    First Language:
    English
    Primarily Uses:
    N/A
    Hey everyone.

    Wondering how I can find multiples of a certain number. IE: Setting a variable to go up every five levels for instance.
     
    #1
  2. Zoltor

    Zoltor Veteran Veteran

    Messages:
    1,550
    Likes Received:
    207
    First Language:
    English
    The most direct way, is to have 3 different variables, one of them records the characters current lv, and the other to run a division calculation with such, putting the end results into the 3rd variable.
     
    Last edited by a moderator: Nov 14, 2015
    #2
  3. Andar

    Andar Veteran Veteran

    Messages:
    27,928
    Likes Received:
    6,304
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    The easiest way is to use the modulo operand in control variables.


    If the modulo to a number is zero, the original value was a multiple of the number.
     
    #3
  4. BloodletterQ

    BloodletterQ Chaotic Neutral Assassin Veteran

    Messages:
    1,447
    Likes Received:
    1,044
    Location:
    My head's in the clouds at least...
    First Language:
    English
    Primarily Uses:
    N/A
    Mind showing me the process for it if it's not too much trouble?
     
    #4
  5. Andar

    Andar Veteran Veteran

    Messages:
    27,928
    Likes Received:
    6,304
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    If the number you want to check is in variable 012 for example and you want to check if it's a multiple of 7, then you make a single command


    control variables [012] , Operation = modulo (mod), operant = 7


    Then conditional branche, if variable 012 is now zero then it was a multiple of 7 - if it has a value between 1 and 6 (the rest/modulo after a division by 7) then it wasn't a multiple of 7.


    If you want to keep the original value of V[012], then copy it to a different variable before checking
     
    #5

Share This Page