Yanfly State Categories - Single State from Category

Plugin link: http://yanfly.moe/2016/04/03/yep-89-state-categories/


I feel like this is possible but I can't figure out a way to make it work.


Essentially what I'd like is to have multiple states with the "Food" category, but make it so only 1 state from Food can be applied. If a second one is applied, it will instead overwrite the old state. Any way to make this happen? I've tried using <Remove State Category: Food> and <Remove 1 State Category: Food>, but these won't do what I want, they are removing the state as it's added.


I'm pretty darn sure I'm just overlooking something simple, but just can't get it to work.
 


Thanks for any assistance!
Plugin link: http://yanfly.moe/2016/04/03/yep-89-state-categories/


I feel like this is possible but I can't figure out a way to make it work.


Essentially what I'd like is to have multiple states with the "Food" category, but make it so only 1 state from Food can be applied. If a second one is applied, it will instead overwrite the old state. Any way to make this happen? I've tried using <Remove State Category: Food> and <Remove 1 State Category: Food>, but these won't do what I want, they are removing the state as it's added.


I'm pretty darn sure I'm just overlooking something simple, but just can't get it to work.
 


Thanks for any assistance!



Utilizing functionality from the parent Plug-In (Buffs & States Core) you can do this pretty easily.


Simply make a notetag in the new state (and all states that need this functionality) like this:

Code:
<Custom Apply Effect>
battler.removeStateCategoryAll(‘CAT HERE’);
</Custom Apply Effect>

(I may be wrong, as I am at work, I can't test this myself)


This should remove all "Food" states before applying the new one.


EDIT: Should have been battler.removeStateCategoryAll
You lead me on the correct path, thanks!
For some reason <Custom Apply Effect> was causing the same issue, where the state would be removed after being added. But:
 


<Custom Select Effect>
user.removeStateCategoryAll('Food');
</Custom Select Effect>




Works like a charm. Thanks for the help!

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-state-categories-single-state-from-category.63950/