Adding state after other state removed

Hello,

I've been trying to system in which a state will be added as soon as another wears off from walking so many steps outside of battle. I'm trying to use Yanfly's Buffs and States core to do this using the <Custom Leave Effect> script call.

So far, I've been trying to use $gameActors.actor(actorId).addState(n); to add the state, but I have no clue what to enter in the actorId spot that would select the actor that the new state needs to be applied to.. It works if I enter a static number, like 1 or 2, but that's not ideal.
alternatively, simply use this:
http://himeworks.com/2015/11/progressive-states-mv/

(Yanfly isn't the only plugin writer out there ;-))
How does Yanfly's plugin refer to "this actor"? If you knew that, you wouldn't need to use $gameActors.actor(actorId) at all, and could reduce it to thisActor.addState(n). A link to the plugin would help (that would always be a good idea to include when you're asking for help with plugins).
<Custom Leave Effect>
a.addState(x)
</Custom Leave Effect>

EDIT: Actually...I'm not 100% sure if this will work outside of battle.
EDIT#2: Just tested it myself, and it doesn't work outside of battle.
this.addState(x)
The <Custom Leave Effect> uses 'this' as a stand in for the battler afflicted with the state.
My bad, I assumed everybody already knew all about his plugins, but it's this one - http://yanfly.moe/2015/12/25/yep-50-buffs-states-core.

I just tried testing out this.addState(). It's not giving an error anymore, but it still didn't apply the state that I asked it to. I'm starting to think it's only meant for combat.

I'm looking into Hime's plugin. Seems more user friendly for those of us who know next to nothing about scripting.
yeah, everybody knows about them, but not everybody uses them or knows exactly where to look. It's just easier if you always include a link to the plugin when you're asking for plugin help.

Original thread: https://forums.rpgmakerweb.com/threads/adding-state-after-other-state-removed.75179/