Advertisement
LiTTleDRAgo

[RGSS/2/3] Simple Event Sensor

Oct 21st, 2011
1,009
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.19 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # Simple Event Sensor
  3. # Version: 1.10
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  6. #
  7. # Instruction :
  8. #  
  9. # Set the event name to : <Sensor(RANGE)>
  10. # example :
  11. #            <Sensor4>
  12. #
  13. # If player is in event sensor range, Self switch D (default) will turned ON
  14. #
  15. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  16.  
  17. class Game_Event < Game_Character
  18.  #-----------------------------------------------------------------------
  19.   SENSOR_SELF_SWITCH = 'D'
  20.  #-----------------------------------------------------------------------
  21.   alias drago64c_update update
  22.   def update
  23.     sensor_updating unless @unsensor
  24.     drago64c_update  
  25.   end
  26.  
  27.   def sensor_updating
  28.     @event.name =~ /<Sensor(\d+)>/i
  29.     s = [$1.to_i,[$game_map.map_id,@id,SENSOR_SELF_SWITCH],[]]
  30.     s[2] = [(($game_player.x-self.x).abs + ($game_player.y-self.y).abs <=
  31.           s[0]), $game_self_switches[s[1]]] if s[0] > 0
  32.     return unless s[0] > 0 && s[2][0] != s[2][1]
  33.     $game_self_switches[s[1]], $game_map.need_refresh = s[2][0], true
  34.   end
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement