Yanfly Lunatic Code Help!

Hello everyone.

I am using yanfly's buff/states core and I'm trying to set up a custom state.
Here is the following as an example of what I'm trying to do:
if agility == 0 then apply state x

that is the logic of it, but I don't know how to write it
then on the state that applies:
if agility != 0 then remove this state

Anyone knows how to do it? thank you and ask for questions if you want some clarity
its not in buff/state core
with the plugin auto passive you can do it

copy this to your custom state
Code:
<Custom Passive Condition>
if (user.agi == 0) {
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>


when any ally or foe reach agility 0, this state will pop up
<Custom Passive Condition>
condition = (user.agi == 0);
</Custom Passive Condition>
Or this, it's shorter.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-lunatic-code-help.94236/