[SOLVED](YEP_BuffStatesCore)Help with Custom State Duration?

Hello(again)!
I ask help, like last time, with the BuffStatesCore Plugin by Yanfly.

This time, i wanted to make so a State's Turn Duration was determined by one of the user's Parameters(in this case i'm using Agility).
So, i used the plugin's tag "Custom State X Turn", that does the exact thing i need, in this way:

Code:
<Custom State 22 Turn> 
turn = 2;
turn += Math.floor((user.agi - 10) / 2);
</Custom State 22 Turn>

If i understood it correctly, this would make it so when i use the Skill the tag is attached to, if State 22 is applied it would endure as many turns as the final value of the variable "turn". That doesn't seem the case though.

To make a test i used a character with an Agility parameter equal to 12, which would mean:

Code:
<Custom State 22 Turn> 
turn = 2;
turn += Math.floor((12 - 10) / 2);
</Custom State 22 Turn>

By this logic, "turns" should return '3' as a value. Instead, when the Character uses the ability in battle and applies the State 22 to itself, the turn counter only gives "2", which is the effective base turn duration of the State in the Database.

Am i doing something wrong? Or the Tag simply doesn't work that way? Thanks in advance!
are you counting the current turn/turn 0?
did you try seeing if without the second line it would give 1 or 2 turns?
try setting turn to a higher number, like 7.
what happens?
try setting turn to a higher number, like 7.
what happens?
are you counting the current turn/turn 0?
did you try seeing if without the second line it would give 1 or 2 turns?
I tried it, it still gives me the value for the State duration in the States Database :/
Also what do you mean Waterguy with the current turn?
Have you checked the console for errors? hit F12 after you apply the state in battle
Have you checked the console for errors? hit F12 after you apply the state in battle
Yup, also nothing 🙁
well, my idea was that the problem may be that it is counting turn 0, so the value shown is one smaller than the value set - that is, if it is two turns it would show 1 then 0 three turns 2, 1, 0... so just checking the turn = 2; line to see the result, since we already know what to expect with only it.
But if a bigger value still shows 2, then that is not the problem.

Hmm... ok, some obvious-looking questions but that even I sometimes make these mistakes:
Did you make sure the plugin is turned on?
And did you check the console (f8 or f12, be sure to be in the "console" tab) when you tried the skill that adds it to see if there was any error message?

I am checking your code and comparing with the one on yanfly's wiki examples, and can't see a problem with the code...
well, my idea was that the problem may be that it is counting turn 0, so the value shown is one smaller than the value set - that is, if it is two turns it would show 1 then 0 three turns 2, 1, 0... so just checking the turn = 2; line to see the result, since we already know what to expect with only it.
But if a bigger value still shows 2, then that is not the problem.

Hmm... ok, some obvious-looking questions but that even I sometimes make these mistakes:
Did you make sure the plugin is turned on?
And did you check the console (f8 or f12, be sure to be in the "console" tab) when you tried the skill that adds it to see if there was any error message?

I am checking your code and comparing with the one on yanfly's wiki examples, and can't see a problem with the code...
- The plugin is ON
- I checked the console

I really don't understand.
sorry, only thing I can think is something else in your notetags may be wrong and messing with that
Write
console.log("I'm working!")

Inside the custom turn tag. If nothing appears on the console, then the plugin isn't reading your notetags
sorry, only thing I can think is something else in your notetags may be wrong and messing with that
Code:
<setup action>
display action
wait: 40
clear battle log
</setup action>
<finish action>
</finish action>

<Instant>
<Skill Tier: 1>
<Cooldown: 4>

<Custom State 22 Turn>
turn = 2;
turn += Math.floor((user.agi - 10) / 2);
</Custom State 22 Turn>
This is the entire notetag, i don't think there's something wrong with it.


Write
console.log("I'm working!")

Inside the custom turn tag. If nothing appears on the console, then the plugin isn't reading your notetags

Tried it, and nothing appears on console. Now we need to find out why the tag isn't read.
Ok, do the rest of the notetags work properly?
cton sequence? Instant skill? Skill cooldown? the tier? is this the only thing not working?
Ok, do the rest of the notetags work properly?
cton sequence? Instant skill? Skill cooldown? the tier? is this the only thing not working?
Yup.
...ok, quick question, how is the state being added?
...ok, quick question, how is the state being added?
With the "effects" on the Skill's page in the Database.
EDIT: Image to clarify
think I found the problem.

you used
JavaScript:
<Custom State 22 Turn>
turn = 2;
turn += Math.floor((user.agi - 10) / 2);
</Custom State 22 Turn>
I think you should have used
JavaScript:
<Custom State 22 Turns>
turn = 2;
turn += Math.floor((user.agi - 10) / 2);
</Custom State 22 Turns>
notice the s in turns in the notetags
think I found the problem.

you used
JavaScript:
<Custom State 22 Turn>
turn = 2;
turn += Math.floor((user.agi - 10) / 2);
</Custom State 22 Turn>
I think you should have used
JavaScript:
<Custom State 22 Turns>
turn = 2;
turn += Math.floor((user.agi - 10) / 2);
</Custom State 22 Turns>
notice the s in turns in the notetags
.... Oh. This is embarrassing XD
Thank you very much! Yet another lesson about double-checking the Code's syntax.
Is it working now then?
Glad I could help.
Is it working now then?
Glad I could help.
Yup! Now the State when applied lasts 3 turns, as it should be.
I also tried by modifying the character parameters, and it works as intended.
Thank you again!

Original thread: https://forums.rpgmakerweb.com/threads/solved-yep_buffstatescore-help-with-custom-state-duration.116460/