Silverskin

Villager
Member
Joined
Jun 21, 2016
Messages
27
Reaction score
12
First Language
English
Primarily Uses
Hey,


for a skill that cures all negative states, I want to write a pice of my own code inside Yanflys action sequence. It looks like this:

<target action>
for (var i = 0; i < $dataStates.length; ++i){
  if (target.isStateAffected(i)){
    if ($dataStates[stateId].meta.good){
    }
    else{ 
    target.removeState(i);
    }
  }
}
</target action>

the ".meta.good" is already coded elsewhere and works perfectly fine. It flags states as good and not affected by luk's chance of not getting it.


The two errors I keep getting are: i is undefined or unexpected token {.


However, $dataStates is an array of which you can check the array length (at least I think you can), and I literally checked these brackets 20 times and they are correct.


If you could help me with that skill and that specific line of code, I would be really thankful!
 

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
562
Reaction score
810
First Language
English
Primarily Uses
RMMV
Usually you want to do i++, instead ++i.


<target action>
for (var i = 0; i < $dataStates.length; i++) {
if (target.isStateAffected(i)) {
if ($dataStates[stateId].meta.good) {
//Do nothing
}
else{
target.removeState(i);
}
}
}
</target action>

//Optional

<target action>
var i = 0;
for (i < $dataStates.length; i++) {
if (target.isStateAffected(i)) {
if ($dataStates[stateId].meta.good) {
//Do nothing
}
else{
target.removeState(i);
}
}
}
i = 0; //Reset i
</target action>




I think that should help with i is undefined issue, hopefully.
 

Silverskin

Villager
Member
Joined
Jun 21, 2016
Messages
27
Reaction score
12
First Language
English
Primarily Uses
thank you for the quick reply!


I am a javascript noob and I will still have to learn much about math and variables.


Unfortunately, I keep getting the unexpected token { error, so I cant tell whether this has fixed it for sure.


I will go through all of yanflys tutorials again and look if he has some similar code in his tutorials.


I will reply again when I found a solution. Good night!
 

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
562
Reaction score
810
First Language
English
Primarily Uses
RMMV
I was thinking, since you seem to be getting a token error, we can remove some braces. @Saathan


<target action>
var i = 0;
for (i < $dataStates.length; i++) {
if (target.isStateAffected(i)) {
if ($dataStates[stateId].meta.good)
//Do nothing
else
target.removeState(i);
}
}
i = 0; //Reset i
</target action>




Hopefully that will fix the error. If that doesn't fix the error, it might be the other braces in this call.
 

Silverskin

Villager
Member
Joined
Jun 21, 2016
Messages
27
Reaction score
12
First Language
English
Primarily Uses
Hi,


I finally got that unexpected token error. Yanfly's Action sequence doesn't even support brackets and the "for var..." loop.


That's why both of my errors occured. I will try to run this with a custom eval code within action sequence or via a common event script call.


Ill post a solution if I find one.
 

Silverskin

Villager
Member
Joined
Jun 21, 2016
Messages
27
Reaction score
12
First Language
English
Primarily Uses
I FOUND A SOLUTION


Yanflys Action sequence has problems processing more complicated codes (or I am just too dumb to figure out how), even when using the eval code.


Instead of putting the code into <target action>, leave it blank and use Yanflys Skill Core plugin. Before the Action sequence stuff, I put:

<After Eval>


for ( var i = 0; i < $dataStates.length; i++) {


if (target.isStateAffected(i)) {


if ($dataStates.meta.good) {


}


else {


target.removeState(i);


break;


}


}


}


</After Eval>

and it worked perfectly!


I hope this helps everyone that has the same problem as I had, and thank @Kino for the help :)


Edit: Put squared brackets with an i inside after $dataStates and before .meta, this forum cant show squared brackets somehow.
 
Last edited by a moderator:

Latest Threads

Latest Posts

Latest Profile Posts

At work.
Co: "This bug drove me insane. I tried a lot of things to debug, it just stuck".
Me: "How did you debug it?"
Co: *shows a complicated debugging method using breakpoints and everything*
Me: "What about ... " *casually prints a stack trace in the try/catch exception
Co: "Wait, you can do that??"
Totally original and unique OC
Harold.png
So after completing the Mass Effect Trilogy the first time as a Vanguard, I decided to replay the trilogy as a Soldier. Thus far, I've just finished the Horizon mission in ME2, and I'm already exhausted from ME2's f**k-awful enemy design.
If you are in these ices, I will give all the fire...
Yeah, now Yes !!!! "boom boom "
"Fire the monsters, guards!!!"

index.php

Forum statistics

Threads
118,659
Messages
1,117,599
Members
155,759
Latest member
papay
Top