(Yanfly Plugins) Set a state to certain turns?

Is there a way to use a skill to set an already applied state to a certain amount of turns?


Example: Bard class.


Bard uses song1 (State Lasts 5 turns)


Bard uses song2 (State Lasts 5 turns)


Bard uses song3 (State Lasts 5 turns)


-At this point the state from song1 only has 2 turns left


Bard uses Harmony to boost the turns of all applied song-states back to 5.


Bard uses song4 (State Lasts 5 turns)


Etc. Etc.


I notice that in the buffs and states core help file you can add or remove turns, <State x Turns: +y> or <State x Turns: -y> respectively, but there doesn't seem to be a way to set or reset turns.
Put this code in the skill that you want to reset the states with.  Replace X with state ID:


<Custom State X Turn>


if (target.isStateAffected(X)){


     turn = 5;


}
</Custom State X Turn>


Make that tag for each state you want to reset in the skill.
I still seem to be having issues. I made a short video demonstrating this. Not sure if I've overlooked something.


Skill applies state 160, but the other skill doesn't bring state 160 back up to 5 turns.

Plugin documentation for v1.1 has a mistake in this part, since the actual tag is <Custom State X Turns></Custom State X Turns> (notice the s at the end)


Hope this helps somebody searching through Google since this thread is one of the first hits.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-plugins-set-a-state-to-certain-turns.64561/