Tied states [Help with Lunatic States]

I tried to use Yanfly's Lunatic States to make a state that is tied with another one, and will always be automatically added/removed when "parent" state is added/removed
I.e.:
When State 12 is applied, state 13 is automatically added.
When State 12 is removed, state 13 goes with it.

The "add" part works, but I don't know how to do "remove".
The add-on that I rigged up looks like this:
Ruby:
when /STATE[ ](\d+)/i
self.add_state($1.to_i)
when /NOSTATE[ ](\d+)/i
self.remove_state($1.to_i)

State 12 notetags look like this:
<erase effect: nostate 13>
<leave effect: nostate 13>
<apply effect: state 13>
Put STATE and NOSTATE the other way around. NOSTATE is matching the first regex pattern because it contains STATE.
Excuse me, but I don't understand what do you mean by "putting them around".
Do you mean changing NOSTATE to something that doesn't have STATE, like NOCOND? I tried that and I got same result as with NOSTATE.
I mean do NOSTATE first, and then STATE.

The "when" runs through each case in order until it finds one that meets the condition. NOSTATE and STATE both meet the condition of /STATE[ ](\d+)/i, so the code will never hit your NOSTATE case.
Also tried this before and it didn't work.
As I said, this is an add-on to Lunatic States the WHOLE add-on looks like this.
Ruby:
#==============================================================================
#
# ▼ Yanfly Engine Ace - Lunatic States Package - Custom Effects
#
# -- Requires: YEA - Lunatic States v1.00+
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["LSP-Custom"] = true

#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# Install this script under YEA - Lunatic States.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
# This script requires YEA - Lunatic States v1.00+ to work. It must be placed
# under YEA - Lunatic States v1.00+ in the script listing.
#
#==============================================================================

if $imported["YEA-LunaticStates"]
class Game_BattlerBase

#--------------------------------------------------------------------------
# ● Lunatic States Package Effects - LSP Custom Effects
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#--------------------------------------------------------------------------
alias lunatic_state_extension_lsp11 lunatic_state_extension
def lunatic_state_extension(effect, state, user, state_origin, log_window)
case effect.upcase
=begin
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<erase effect: noco x>
<leave effect: noco x>
<apply effect: state x>
=end
when /NOCO[ ](\d+)/i
self.remove_state($1.to_i)

when /STATE[ ](\d+)/i 
self.add_state($1.to_i)

#----------------------------------------------------------------------
# Stop editting past this point.
#----------------------------------------------------------------------
else
so = state_origin
lw = log_window
lunatic_state_extension_lsp11(effect, state, user, so, lw)
end
end

end # Game_BattlerBase
end # $imported["YEA-LunaticStates"]

#==============================================================================
#
# ▼ End of File
#
#==============================================================================
Only portion that I posted is supposed to be edited, I think.
I don't know if what I'm posting now have sense, I'm kinda confused honestly.

Original thread: https://forums.rpgmakerweb.com/threads/tied-states-help-with-lunatic-states.143474/