Problems with Drifty's "Equipment Optimizer" code

Discussion in 'Javascript/Plugin Support' started by Parallax Panda, Aug 30, 2019.

Thread Status:
Not open for further replies.
  1. Parallax Panda

    Parallax Panda Got into VxAce ~2014 and never stopped... Veteran

    Messages:
    695
    Likes Received:
    1,035
    Location:
    Fukuoka, Japan
    First Language:
    Swedish
    Primarily Uses:
    RMMV
    Okay so I wanted to do a common event, bound to a key (using yanfly plugin) that would optimize the entire party's equipment when the button is pressed. Like Drifty did in his game Legend of Driftwood. I even looked at a "tutorial" where he shows the code snippet used in that common event and I'm positive I've written it just like he has - but it doesn't seem to work for me.

    var length = $gameParty.allMembers().length;
    for (var i = 0; i < length; ++i) {
    var actor = $gameParty.allMembers();
    If (actor) actor.optimizeEquipments();
    }


    The video tutorial can be found here (watch from ~19:32 and you get right to where drifty talks about the code):


    Thank you for for reading. :kaoluv:
     
    #1
  2. ShadowDragon

    ShadowDragon Veteran Veteran

    Messages:
    911
    Likes Received:
    279
    Location:
    Netherlands
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    var length = $gameParty.allMembers().length;
    for (var i = 0; i < length; ++i) {
    var actor = $gameParty.allMembers();
    If (actor) actor.optimizeEquipments();
    }


    You missed the "[ i ]"
    var actor = $gameParty.allMembers()

    so you need to place behind it like I did in the top part ^^
    or it wont read " i " without any purpose.
     
    #2
  3. Parallax Panda

    Parallax Panda Got into VxAce ~2014 and never stopped... Veteran

    Messages:
    695
    Likes Received:
    1,035
    Location:
    Fukuoka, Japan
    First Language:
    Swedish
    Primarily Uses:
    RMMV
    @ShadowDragon
    Thank you for pointing that out. I guess I'm a bit tired. I fixed it but... it still doesn't work for me? :kaocry:

    Here's a screenshot of the entire event. I guess it's easier to help if you have a clear picture of what's going on:
    [​IMG]

    I bet the problem is something obvious but my sleepy eyes just can't see it.
     
    #3
  4. caethyril

    caethyril ^_^ Veteran

    Messages:
    1,279
    Likes Received:
    799
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    "if" needs to have a lowercase "i", try this instead~
    Code:
    var length = $gameParty.allMembers().length;
    for (var i = 0; i < length; i++) {
      var actor = $gameParty.allMembers()[i];
      if (actor) actor.optimizeEquipments();
    }
     
    #4
  5. ShadowDragon

    ShadowDragon Veteran Veteran

    Messages:
    911
    Likes Received:
    279
    Location:
    Netherlands
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    totally overreaded the "If" statement, sometimes you read to fast and notice it later on lowercase "if".
    Nice catch on that on @caethyril ^^ (always keep your eyes open for the most tiny mistakes)
     
    #5
    caethyril likes this.
  6. Parallax Panda

    Parallax Panda Got into VxAce ~2014 and never stopped... Veteran

    Messages:
    695
    Likes Received:
    1,035
    Location:
    Fukuoka, Japan
    First Language:
    Swedish
    Primarily Uses:
    RMMV
    @caethyril
    Wow, thank you. I totally didn't see that. Now it's finally working!

    @ShadowDragon
    You and me both. It's such a relief to finally have this feature working. Thanks for your help as well.
     
    #6
    caethyril likes this.
  7. Shaz

    Shaz Veteran Veteran

    Messages:
    37,807
    Likes Received:
    11,516
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    um ...

    Code:
    $gameParty.allMembers().forEach(function(actor) { actor.optimizeEquipments(); })
     
    #7
    Parallax Panda likes this.
  8. Parallax Panda

    Parallax Panda Got into VxAce ~2014 and never stopped... Veteran

    Messages:
    695
    Likes Received:
    1,035
    Location:
    Fukuoka, Japan
    First Language:
    Swedish
    Primarily Uses:
    RMMV
    @Shaz
    Oh snap. That code is way more clean (and works just fine). Thank you for bringing that to light. :kaoluv:
     
    #8
    Shaz likes this.
  9. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,972
    Likes Received:
    10,668
    First Language:
    English
    Primarily Uses:
    RMVXA

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #9
Thread Status:
Not open for further replies.

Share This Page