SHARE
TWEET

DJ Lighting Effects for Carf

Drykul Mar 23rd, 2020 (edited) 317 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =begin
  2. Version 1.0 - 03/24/2020
  3.  
  4. You can add as many controllable lights to whatever maps you want.
  5. Keys 1, 2, 3, 4 and 9 will all revert back to their starting positions when
  6. toggled off. Keys 0, F5, and F8 are now more easy to turn off and on when
  7. needed.
  8.  
  9. === Setup ===
  10. In each map that you want to have controllable lights, in the notes section
  11. of the map put <djLighting> and case DOES matter so enter it exactly as shown
  12. here.
  13.  
  14. In each light event, anywhere on page 1 put a comment that reads <keyxLight>
  15. where x is the key you want to control that particular light.
  16.  
  17. Example - You want a particular light event to be controlled by pressed the
  18. 4 key. In that event's page 1, add a comment that reads <key4Light> and that's
  19. it.
  20.  
  21. =end
  22.  
  23. $updateDJLighting = false
  24.  
  25. class Scene_Base
  26.  
  27.   @@keyLights = Hash.new
  28.  
  29.   alias drykul_lighting_start start
  30.   def start
  31.     drykul_lighting_start
  32.     if $updateDJLighting
  33.       drykul_get_light_events
  34.     end
  35.   end
  36.  
  37.   alias drykul_lighting_update update
  38.   def update
  39.     drykul_lighting_update
  40.     if $updateDJLighting
  41.       drykul_positional_update
  42.     end
  43.   end
  44.  
  45.   def drykul_get_light_events
  46.     @key1Lights = []
  47.     #@keyXLightsInfo = [event id, [event x, event y]]
  48.     @key1LightsInfo = []
  49.    
  50.     @key2Lights = []
  51.     @key2LightsInfo = []
  52.    
  53.     @key3Lights = []
  54.     @key3LightsInfo = []
  55.    
  56.     @key4Lights = []
  57.     @key4LightsInfo = []
  58.    
  59.     @key9Lights = []
  60.     @key9LightsInfo = []
  61.    
  62.     # Lights mapped to key 1
  63.     $game_map.events.each_value {|event| @key1Lights << event}
  64.     @key1Lights.select! {|x| x.list[0].code == 108 &&
  65.       x.list[0].parameters == ["<key1Light>"] if x.list}
  66.     @key1Lights.uniq!
  67.     for i in @key1Lights do
  68.       @key1LightsInfo.push([i.id, [i.x, i.y]])
  69.     end
  70.    
  71.     # Lights mapped to key 2
  72.     $game_map.events.each_value {|event| @key2Lights << event}
  73.     @key2Lights.select! {|x| x.list[0].code == 108 &&
  74.       x.list[0].parameters == ["<key2Light>"] if x.list}
  75.     @key2Lights.uniq!
  76.     for i in @key2Lights do
  77.       @key2LightsInfo.push([i.id, [i.x, i.y]])
  78.     end
  79.    
  80.     # Lights mapped to key 3
  81.     $game_map.events.each_value {|event| @key3Lights << event}
  82.     @key3Lights.select! {|x| x.list[0].code == 108 &&
  83.       x.list[0].parameters == ["<key3Light>"] if x.list}
  84.     @key3Lights.uniq!
  85.     for i in @key3Lights do
  86.       @key3LightsInfo.push([i.id, [i.x, i.y]])
  87.     end
  88.    
  89.     # Lights mapped to key 4
  90.     $game_map.events.each_value {|event| @key4Lights << event}
  91.     @key4Lights.select! {|x| x.list[0].code == 108 &&
  92.       x.list[0].parameters == ["<key4Light>"] if x.list}
  93.     @key4Lights.uniq!
  94.     for i in @key4Lights do
  95.       @key4LightsInfo.push([i.id, [i.x, i.y]])
  96.     end
  97.    
  98.     # Lights mapped to key 9
  99.     $game_map.events.each_value {|event| @key9Lights << event}
  100.     @key9Lights.select! {|x| x.list[0].code == 108 &&
  101.       x.list[0].parameters == ["<key9Light>"] if x.list}
  102.     @key9Lights.uniq!
  103.     for i in @key9Lights do
  104.       @key9LightsInfo.push([i.id, [i.x, i.y]])
  105.     end
  106.    
  107.     # Add all keys to class variable
  108.     @@keyLights["key1"] = @key1LightsInfo
  109.     @@keyLights["key2"] = @key2LightsInfo
  110.     @@keyLights["key3"] = @key3LightsInfo
  111.     @@keyLights["key4"] = @key4LightsInfo
  112.     @@keyLights["key9"] = @key9LightsInfo
  113.   end
  114.  
  115.   def drykul_positional_update    
  116.     # If the corresponding switch is off, reset each event to its starting coord.
  117.     if $game_switches[100] == false
  118.       tempNum = 0
  119.       for i in @@keyLights["key1"] do
  120.         $game_map.events[@@keyLights["key1"][tempNum][0]].moveto(@@keyLights["key1"][tempNum][1][0], @@keyLights["key1"][tempNum][1][1])
  121.         tempNum += 1
  122.       end
  123.     end
  124.    
  125.     if $game_switches[63] == false
  126.       tempNum = 0
  127.       for i in @@keyLights["key2"] do
  128.         $game_map.events[@@keyLights["key2"][tempNum][0]].moveto(@@keyLights["key2"][tempNum][1][0], @@keyLights["key2"][tempNum][1][1])
  129.         tempNum += 1
  130.       end
  131.     end
  132.    
  133.     if $game_switches[89] == false
  134.       tempNum = 0
  135.       for i in @@keyLights["key3"] do
  136.         $game_map.events[@@keyLights["key3"][tempNum][0]].moveto(@@keyLights["key3"][tempNum][1][0], @@keyLights["key3"][tempNum][1][1])
  137.         tempNum += 1
  138.       end
  139.     end
  140.    
  141.     if $game_switches[17] == false
  142.       tempNum = 0
  143.       for i in @@keyLights["key4"] do
  144.         $game_map.events[@@keyLights["key4"][tempNum][0]].moveto(@@keyLights["key4"][tempNum][1][0], @@keyLights["key4"][tempNum][1][1])
  145.         tempNum += 1
  146.       end
  147.     end
  148.    
  149.     if $game_switches[93] == false
  150.       tempNum = 0
  151.       for i in @@keyLights["key9"] do
  152.         $game_map.events[@@keyLights["key9"][tempNum][0]].moveto(@@keyLights["key9"][tempNum][1][0], @@keyLights["key9"][tempNum][1][1])
  153.         tempNum += 1
  154.       end
  155.     end
  156.   end
  157. end
  158.  
  159. ##### Find map notes to see if the tag string is in them.
  160. ##### If found, update global variable $updateDJLighting.
  161. class Game_Map
  162.  
  163.   @@mapNotes = ""
  164.  
  165.   alias drykul_lighting_setup setup
  166.   def setup(map_id)
  167.     drykul_lighting_setup(map_id)
  168.     @@mapNotes = @map.note
  169.     if @@mapNotes.include? "<djLighting>"
  170.       $updateDJLighting = true
  171.     else
  172.       $updateDJLighting = false
  173.     end
  174.   end
  175. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top