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
1,064
Reaction score
1,326
First Language
Swedish
Primarily Uses
RMVXA
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
2,892
Reaction score
1,026
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
1,064
Reaction score
1,326
First Language
Swedish
Primarily Uses
RMVXA
@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
2,087
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
"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
2,892
Reaction score
1,026
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
1,064
Reaction score
1,326
First Language
Swedish
Primarily Uses
RMVXA
@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
40,098
Reaction score
13,704
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
1,064
Reaction score
1,326
First Language
Swedish
Primarily Uses
RMVXA
@Shaz
Oh snap. That code is way more clean (and works just fine). Thank you for bringing that to light. :kaoluv:
 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,975
Members
137,563
Latest member
cexojow
Top