Problems with Drifty's "Equipment Optimizer" code

Status
Not open for further replies.

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
775
Reaction score
1,059
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:
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,033
Reaction score
325
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.
 

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
775
Reaction score
1,059
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:

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

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,385
Reaction score
866
First Language
EN
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();
}
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,033
Reaction score
325
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)
 

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
775
Reaction score
1,059
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,315
Reaction score
11,917
First Language
English
Primarily Uses
RMMV
um ...

Code:
$gameParty.allMembers().forEach(function(actor) { actor.optimizeEquipments(); })
 

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
775
Reaction score
1,059
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:
 

Kes

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,426
Reaction score
10,849
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.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

It's almost new year, again!
Succesfully finished a quest of saving my kitty who fell from a wall!

+25XP

MrKiwi leveled up!
MrKiwi learned how to save his kitty!
Final sprint for me, although a long one. If everything goes well, I'll graduate by the end of the year. Then I'll have to take the Bar classes and exams (4 months), then I'm off to practicing law (as an intern for 6 months, paid of course, then I'll be a full fledged attorney).
I think there is something wrong with my cat. He is acting CATatonic.
Want to find a quick answer? Say the wrong one and SOMEONE will fall all over themselves to correct you.

Forum statistics

Threads
93,572
Messages
913,586
Members
123,105
Latest member
djag1
Top