Modifying the same script still, need help

Hi. As the title states, I'm still trying to modify GaryCXJK's Free Movement script so that there is a pause when the player turns, unless they're only turning 45 degrees. When turning from an orthogonal to a diagonal there is no wait, however, when doing the opposite, there is, for some reason. I'm focusing on one diagonal for the moment, but I can never get it to print "Working!". This code should leave only a tiny gap- as in when the player is turning- so that $oldturncheck is equal to the diagonal, and $turncheck is equal to the orthaganal. However, this is never the case instead, and the code never gets inside the 2 || 6 if statement.

Any idea what I'm doing wrong? I would provide the entire script, but the link is down still.

Edit: Got the link. Here it is.
Code:
  def interpret_move(step_left = distance_per_frame)
    @move_poll = [] if @move_poll.nil?
    if @move_poll.size > 0
      current_move = @move_poll.shift()
      d = current_move[0]
      horz = (d - 1) % 3 - 1
      vert = 1 - ((d - 1) / 3)
      turn_ok = current_move[1]
      if $wait_time != nil
        if $wait_time <= 30
          if turn_ok
            set_direction(d)
            end
          end
        end
        $oldturncheck = $turncheck
        if horz != 0 && vert != 0
         $turncheck = [horz, vert] # -1 = left; 1 = down; 1 = right; -1 = up
       if horz == 0 && vert == 1
         $turncheck = 2
         end
       if horz == -1 && vert == 0
         $turncheck = 4
         end
       if horz == 1 && vert == 0
         $turncheck = 6
         end
       if horz == 0 && vert == -1
         $turncheck = 8
         end
       if horz == -1 && vert == 1
         $turncheck = 1
         end
       if horz == 1 && vert == 1
         $turncheck = 3
         end
       if horz == -1 && vert == -1
         $turncheck = 7
         end
       if horz == 1 && vert == -1
         $turncheck = 9
         end
       end
       case $oldturncheck
       when 3;
         puts $turncheck
         puts horz
         puts vert
        if $turncheck != 3
          puts "!!!!!"
          if $turncheck == 2 || $turncheck == 6
             if horz == 0 || vert == 0
               degrees = 45
               puts "Working!"
              end
             if $turncheck == 4 or $turncheck == 8
               degrees = 135
              end
             if $turncheck == 7
               puts "opposite!"
               degrees = 180
              end
             end
            end
Where do you make that edit, in which class?
If you are doing this in Game_CharacterBase, it won't work because you use global variables. That method runs for all characters on the map, the player, followers and events will all use it, and that means the global variable will get overwritten after each execution of the method on each character object.

Get rid of global variables, use instance variables. I did not check the code thoroughly, so no idea if that is the only issue with it or not.
The format is hurtful to the eyes, fix the indentation please. >.>
That particular edit is in Game_CharacterBase, yes. I wanted it to work that way for all events, I just don't know how to code it properly. Replacing the global variables with instance variables broke everything, and the player can no longer walk at all, since the code to make it work is in three different classes. Hence the global variables. I didn't know any other way to do it.

...That IS the fixed formatting. You should have seen it before. I'm no programmer, but I can't see anything wrong with the indents?

Original thread: https://forums.rpgmakerweb.com/threads/modifying-the-same-script-still-need-help.105043/