Armor Variable increase

I have multiple common events being called for certain functions in my game. One which checks the player's given dexterity that I want to be able to add to with equip-able armor etc.
The trouble is instead of adding it just once every time it is checked it adds 2, I wanted to know if there is a way to fix this?
Spoiler: Code
Code:
◆If:player has equipped Thief Gloves
  ◆Control Variables:#0043 Dex += 2
  ◆Control Switches:#0013 ThiefGloves = ON
  ◆
:Else
  ◆If:ThiefGloves is OFF
    ◆Jump to Label:Scan
    ◆
  :End
  ◆Control Switches:#0013 ThiefGloves = OFF
  ◆Control Variables:#0043 Dex -= 2
  ◆
:End
◆Label:Scan
Why don't you just add 2dex to the armor's traits in database?
As far as I can tell, you must be calling it more than once. I don't see any way that this could be looping back to the top (unless it's an Auto-run or parallel event). And if it is a parallel event, your character's Dex looks like it'll keep growing ever higher. Would need more context to help you any further.
It is a common event that is often called I will copy in the full event here.
Spoiler: Code
Code:
◆If:player has equipped Thief Gloves
  ◆Control Variables:#0043 Dex += 2
  ◆Control Switches:#0013 ThiefGloves = ON
  ◆
:Else
  ◆If:ThiefGloves is OFF
    ◆Jump to Label:Scan
    ◆
  :End
  ◆Control Switches:#0013 ThiefGloves = OFF
  ◆Control Variables:#0043 Dex -= 2
  ◆
:End
◆Label:Scan
◆If:Dex ≥ 22
  ◆Control Variables:#0051 DEX+- = 6
  ◆Jump to Label:Break
  ◆
:Else
  ◆If:Dex ≥ 20
    ◆Control Variables:#0051 DEX+- = 5
    ◆Jump to Label:Break
    ◆
  :Else
    ◆If:Dex ≥ 18
      ◆Control Variables:#0051 DEX+- = 4
      ◆Jump to Label:Break
      ◆
    :Else
      ◆If:Dex ≥ 16
        ◆Control Variables:#0051 DEX+- = 3
        ◆Jump to Label:Break
        ◆
      :Else
        ◆If:Dex ≥ 14
          ◆Control Variables:#0051 DEX+- = 2
          ◆Jump to Label:Break
          ◆
        :Else
          ◆If:Dex ≥ 12
            ◆Control Variables:#0051 DEX+- = 1
            ◆Jump to Label:Break
            ◆
          :Else
            ◆If:Dex ≥ 10
              ◆Control Variables:#0051 DEX+- = 0
              ◆Jump to Label:Break
              ◆
            :Else
              ◆If:Dex ≥ 5
                ◆Control Variables:#0051 DEX+- = -2
                ◆Jump to Label:Break
                ◆
              :Else
                ◆Control Variables:#0051 DEX+- = -1
                ◆Jump to Label:Break
                ◆
              :End
              ◆
            :End
            ◆
          :End
          ◆
        :End
        ◆
      :End
      ◆
    :End
    ◆
  :End
  ◆
:End
The problem is every time this event is called which is anytime it is checked the Dex keeps getting a two plus boost while the armor is equipped.
Here is a sample of it being called.
Spoiler: Calling Common Event
Code:
  ◆Control Variables:#0001 d20 = Random 1..20
  ◆Common Event:Dex_check
  ◆Control Variables:#0001 d20 += DEX+-
    ◆If:d20 > 16
      ◆Comment://Lock picked
      ◆Control Variables:#0003 True = 1
      ◆Play SE:Open1 (90, 100, 0)
      ◆Control Variables:#0001 d20 -= DEX+-
      ◆If:Level ≥ 4
        ◆Control Variables:#0001 d20 -= 2
        ◆If:d20 = 20
          ◆Control Variables:#0008 Exp = Random 200..300
          ◆Change EXP:Entire Party, + {Exp} (Show Level Up)
          ◆Text:None, Transparent, Bottom
          :    :You gained \V[8]EXP! LUCKY!
          ◆
        :Else
          ◆Text:None, Window, Bottom
          :    :\V[1] +\V[51]
          ◆Change EXP:Entire Party, + 90 (Show Level Up)
          ◆Text:None, Transparent, Bottom
          :    :You gained 90 EXP!
          ◆Exit Event Processing
          ◆
        :End
        ◆
      :Else
        ◆If:d20 = 20
          ◆Control Variables:#0008 Exp = Random 200..300
          ◆Change EXP:Entire Party, + {Exp} (Show Level Up)
          ◆Text:None, Transparent, Bottom
          :    :You gained \V[8]EXP! LUCKY!
          ◆
        :Else
          ◆Text:None, Window, Bottom
          :    :\V[1] +\V[51]
          ◆Change EXP:Entire Party, + 90 (Show Level Up)
          ◆Text:None, Transparent, Bottom
          :    :You gained 90 EXP!
          ◆Exit Event Processing
          ◆
        :End
        ◆
      :End
      ◆
    :Else
      ◆If:d20 = 1
        ◆Comment://Chest won't open
        ◆Control Variables:#0004 False = 0
        ◆Control Variables:#0001 d20 -= DEX+-
        ◆Text:None, Window, Bottom
        :    :\V[1]
        ◆Exit Event Processing
        ◆
      :End
      ◆Comment://Lock pick failed
      ◆Control Variables:#0004 False = 2
      ◆Control Variables:#0001 d20 -= DEX+-
      ◆Text:None, Window, Bottom
      :    :\V[1] +\V[51]
      ◆Exit Event Processing
      ◆
    :End
Edit:
Why don't you just add 2dex to the armor's traits in database?
Is there a way to have an armor add to a variable as a trait?
Is there a way to have an armor add to a variable as a trait?
I wrote a plugin that does this. It should be linked in the spoiler in my signature as "Equipment Variables" - have a look and see if that does what you need 🙂
@Midnight Kitty Is the problem that the DEX+- goes from -2 to 0? Because you have an error in your processing for that, where Dex of 10 or 11 will give 0 DEX+-, Dex of 5 through 9 will give a -2 DEX+-, and Dex of 4 or lower will give a -1 DEX+-.
Thank you so much this plugin did exactly what I wanted it to do.
@Midnight Kitty Is the problem that the DEX+- goes from -2 to 0? Because you have an error in your processing for that, where Dex of 10 or 11 will give 0 DEX+-, Dex of 5 through 9 will give a -2 DEX+-, and Dex of 4 or lower will give a -1 DEX+-.
Where is the error in the code that does that? Also no it was the Dex itself that kept rising by two each time the command was called. I just saw it, thanks for pointing that out.
The first branch that increases the Dex needs a jump to scan label when switch 13 is on. You're doing it in the else to prevent it from decreasing but you're not doing the same in the if to stop it from increasing more than once.
Thank you I guess I overlooked that, the problem has now been fixed through the plugin so I have removed that section of the code anyway.
No problem. Plugin is probably the better way to go. I actually have one in the latter stages of development right now that covers this too so I definitely agree with the switch. It'll make your life easier.

Original thread: https://forums.rpgmakerweb.com/threads/armor-variable-increase.90458/