JS formula help

Discussion in 'Javascript/Plugin Support' started by firestalker, Jun 28, 2018.

  1. firestalker

    firestalker Veteran Veteran

    Messages:
    326
    Likes Received:
    37
    First Language:
    English
    Primarily Uses:
    RMMV
    I want to make a formula based on levels (so it grows) but I want the first level to be 5 and ever level after that only 1 more than that.

    If I do:
    the trait will be 6 and the next level will be 11.

    What I want is for level 1 to be 5 and level 2 to be 6...

    How can I make a formula that will do this action?
     
    #1
  2. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,554
    Likes Received:
    977
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Level 1 is 5, level 2 is 6, level 3 is 7...
     
    #2
  3. firestalker

    firestalker Veteran Veteran

    Messages:
    326
    Likes Received:
    37
    First Language:
    English
    Primarily Uses:
    RMMV
    Thanks.... That's it.

    One more thing.... Can you tell me how to make the number random? Like take that formula:
    then add a modifier with a random integer so that the trait isn't so stagnant?
     
    #3
  4. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,554
    Likes Received:
    977
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    The code below gives a random integer between 0 and max-1.
    Code:
     
    Math.randomInt(max)
    
    Note: This is not a native function of Javascript, this is something that the RMMV developers added.
    To do this with only native Javascript it would be:
    Code:
     
    Math.floor(max * Math.random())
    
     
    #4
  5. firestalker

    firestalker Veteran Veteran

    Messages:
    326
    Likes Received:
    37
    First Language:
    English
    Primarily Uses:
    RMMV
    Thank you
     
    #5

Share This Page