Script to record the state number of turns

Hello,

I need two small scripts to better manage state changes in my game, please.

I think it's fairly simple if you're proficient in JavaScript, but I'm not
Does anyone know a script to record the number of turns remaining in a given state for a given actor?

And if possible, another script to reduce the number of turns remaining in a given state for a given actor by 1. I think with these two scripts I could do what I want using common events, conditional branches, etc.
Thanks a lot to anyone who can help! ^^
Yanfly's buffs and states core has functions for manipulating state counters, which you can use for both of your reqeusts:
1770857126984.png

Also note: MV does not use scripts, but plugins.
yanfly's state counters are not state turns. theyre separate mechanics. while you dont need yanfly's buffs and states core for this, it does provides getter and setter functions to manipulate the state turns and state effects to be able to use script calls easily.

without it however...
Does anyone know a script to record the number of turns remaining in a given state for a given actor?
Code:
$gameActors.actor(x)._stateTurns[y];
gets actor x's turn count for state y

And if possible, another script to reduce the number of turns remaining in a given state for a given actor by 1
Code:
$gameActors.actor(x)._stateTurns[y] -= 1;
reduces it by 1.
Thanks Robro33, that's exactly what I was looking for =)

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.

Original thread: https://forums.rpgmakerweb.com/threads/script-to-record-the-state-number-of-turns.182408/