Auto Passive States JavaScript code

Discussion in 'Javascript/Plugin Support' started by Tatsumaro, Apr 22, 2018.

  1. Tatsumaro

    Tatsumaro Veteran Veteran

    Messages:
    205
    Likes Received:
    40
    First Language:
    Portugues
    Primarily Uses:
    RMMV
    Hi, i need help whit some code. I'm using YEP.13 – Auto Passive States, i need help white same JavaScript code. I'm using this code only be active if the player is using a sword.
    Auto Passive States.jpg
    Code:
    <Custom Passive Condition>
    if (user.hasSkill(648)) {
    condition = false;
    } else {
    var weapons = user.weapons();
    var arma = 2;
    condition = false;
    for (var i = 0; i < weapons.length; ++i) {
      var weapon = weapons[i];
      if (weapon && weapon.wtypeId === arma) {
        condition = true;
        break;
      }
    }
    }
    </Custom Passive Condition>
    What i need is remake the same code but for Armor Types, for the number 6 to be more specific.
    Auto Passive States2.jpg
     
    #1
  2. Tatsumaro

    Tatsumaro Veteran Veteran

    Messages:
    205
    Likes Received:
    40
    First Language:
    Portugues
    Primarily Uses:
    RMMV
  3. Poryg

    Poryg Dark Lord of the Castle of Javascreeps Veteran

    Messages:
    3,931
    Likes Received:
    9,934
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    Substitute all weapons by armors, arma 2 for arma 6 and wTypeId for aTypeId and you are set.
     
    #3
    Tatsumaro likes this.
  4. Tatsumaro

    Tatsumaro Veteran Veteran

    Messages:
    205
    Likes Received:
    40
    First Language:
    Portugues
    Primarily Uses:
    RMMV
    I think i made a mistake :) i got a error on console.
    Auto Passive States JavaScript code3.png

    I have the weapons whit the same passive state and only the new code is generating this error
     
    #4
  5. Poryg

    Poryg Dark Lord of the Castle of Javascreeps Veteran

    Messages:
    3,931
    Likes Received:
    9,934
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    That is because you did not substitute everything properly. Place the two codes next to each other and substitute everything properly, keeping singular and plural where they need to be.
     
    #5
    Tatsumaro likes this.
  6. Tatsumaro

    Tatsumaro Veteran Veteran

    Messages:
    205
    Likes Received:
    40
    First Language:
    Portugues
    Primarily Uses:
    RMMV
    Ok i will tray, i did not change the weapon

    if (weapon && weapon.wtypeId === arma)

    I only change Wtypeld

    if (weapon && weapon.aTypeId === arma)

    This mas be the error :9 im going to give it a tray, thanks
     
    #6
  7. Poryg

    Poryg Dark Lord of the Castle of Javascreeps Veteran

    Messages:
    3,931
    Likes Received:
    9,934
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    And you also, in one place, typed armors instead of armor.
     
    #7
    Tatsumaro likes this.
  8. Tatsumaro

    Tatsumaro Veteran Veteran

    Messages:
    205
    Likes Received:
    40
    First Language:
    Portugues
    Primarily Uses:
    RMMV
    That is perfect. Thanks :)
     
    #8

Share This Page