HOW DO I TOGGLE SWITCHES VIA SCRIPT? (FOR LINE OF SIGHT SCRIPT)

Posts

Pages: 1
I'm trying to figure out how to flip my switches via script calls and not Events.

The reason for this is that I'm trying to alter THIS line of sight script so that if the event sees the player, it will toggle a switch instead of giving chase.

I started with just learning to flip switches via script calls, but I keep getting syntax errors when trying, and after about 2 hours of poring through the system scripts and trying things out I'm beginning to get a bit fed up...

Can someone give me an assist?
Giving it a glance I'd flip the switch on line 220 in see_player? so it looks like:

def see_player?
    return false if @see_player != true
    sx = distance_x_from($game_player.x)
    sy = distance_y_from($game_player.y)
    if sx.abs > sy.abs
      direction = sx > 0 ? 4 : 6
    else
      direction = sy > 0 ? 8 : 2
    end
    if direction == @direction
      if @sight_lock == nil || @sight_lock <= 0
        @sight_lock = YEA::EVENT_CHASE::SIGHT_LOCK
      end
      @alert_lock = @sight_lock
      $game_switches[x] = true # new line of code
      return true
    end
    return false
  end


Replace x with the # of your switch.
...For serious?
 $game_switches[x] = true
is all I had to do to flip a switch?! *bangs head on wall*

Thanks.

I'm gonna keep trying to poke around with it until I can make it only trigger a switch on certain enemies, instead of making ALL line of sight guys trigger the switch...
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
For a variable, use $game_variables[x] = 30

For event self-switches, use $game_self_switches[[map_id, event_id, 'A']] = true

You can run these lines by themselves in the Call Script event command, too. I change self-switches of other events like this all the time.
Pages: 1