- Joined
- Mar 17, 2012
- Messages
- 681
- Reaction score
- 446
- First Language
- English
- Primarily Uses
- RMVXA
So, I've been learning a bit of Ruby and I decided to try my hand at making a simple script that turns some switches off during screen fadeout and then turns them back on again during fadein. The reason I wanted to do this is because the lighting script I'm using (Casper Gaming's Light Effects script) doesn't turn the lights off when you fade the screen out and I always thought this was a bit annoying and clunky. I went through the code and tried to find some methods to use, but I'm not quite at that level yet. However, all of the lighting effects I am using in my game are bound to switches, so I thought I would use those.
It does work fine (from what I can tell), which is super exciting, because it's the first script I've ever made, but I thought I'd post it here to see if anyone had any suggestions for making it tidier or coding it better. I originally didn't have the editable region, but I made it just to practice.
This is for RPG Maker VX Ace, by the way.
It does work fine (from what I can tell), which is super exciting, because it's the first script I've ever made, but I thought I'd post it here to see if anyone had any suggestions for making it tidier or coding it better. I originally didn't have the editable region, but I made it just to practice.
This is for RPG Maker VX Ace, by the way.
Code:
module AMN_CSCAswitches
#=====================================================================#
# EDITABLE REGION:
#=====================================================================#
AMN_CSCAswitch_one = [6]
AMN_CSCAswitch_two = [7]
AMN_CSCAswitch_three = [8]
AMN_CSCAswitch_four = [9]
#=====================================================================#
# Do not edit below this point.
#=====================================================================#
end
#==============================================================================
# ** Game_Screen
#------------------------------------------------------------------------------
# This class handles screen maintenance data, such as changes in color tone,
# flashes, etc. It's used within the Game_Map and Game_Troop classes.
#==============================================================================
class Game_Screen
#--------------------------------------------------------------------------
# * Update Fadeout
#--------------------------------------------------------------------------
alias amn_cscalights_updatefadeout update_fadeout
def update_fadeout
if @fadeout_duration > 0
if $game_switches[*AMN_CSCAswitches::AMN_CSCAswitch_one]
@amn_cscalights6on = true
end
if $game_switches[*AMN_CSCAswitches::AMN_CSCAswitch_two]
@amn_cscalights7on = true
end
if $game_switches[*AMN_CSCAswitches::AMN_CSCAswitch_three]
@amn_cscalights8on = true
end
if $game_switches[*AMN_CSCAswitches::AMN_CSCAswitch_four]
@amn_cscalights9on = true
end
$game_switches[*AMN_CSCAswitches::AMN_CSCAswitch_one] = false
$game_switches[*AMN_CSCAswitches::AMN_CSCAswitch_two] = false
$game_switches[*AMN_CSCAswitches::AMN_CSCAswitch_three] = false
$game_switches[*AMN_CSCAswitches::AMN_CSCAswitch_four] = false
end
amn_cscalights_updatefadeout
end
#--------------------------------------------------------------------------
# * Update Fadein
#--------------------------------------------------------------------------
alias amn_cscalights_updatefadein update_fadein
def update_fadein
if @fadein_duration != 0
$game_switches[*AMN_CSCAswitches::AMN_CSCAswitch_one] = @amn_cscalights6on
$game_switches[*AMN_CSCAswitches::AMN_CSCAswitch_two] = @amn_cscalights7on
$game_switches[*AMN_CSCAswitches::AMN_CSCAswitch_three] = @amn_cscalights8on
$game_switches[*AMN_CSCAswitches::AMN_CSCAswitch_four] = @amn_cscalights9on
end
amn_cscalights_updatefadein
end
end
