=begin
Script Name: Day Night System
Author: Tajiin
Release Date: 12/04/2013 | mm/dd/yyyy
Version: 2.0
Versions Date: 05.26.2015
Description:
This Script is a Day/Night system. It changes the color tone of the
screen when a specific time is over.
Script-Command:
$game_system.daynightsystem.set_tone(t)
- With this Command you can change the color tone.
- t: is the index of the color tone (0-7)
What can i change in the EDIT-Area:
Switch_ID: It's the Id of the switch which can start/stop the script
(True = Started; False = Stopped)
When you set it to "0" it wont be used
Tag_Nacht_Time: This is the time from 0 o'clock to 12 o'clock a.m.
(in minutes)
Change_Time: This is the time the screen needs to change his color tone
(in Sekunden)
Farbton: Here you can change the single color tones
Time_Variable_ID1: In this variable the time will be saved (in frames)
When you set it to "0" it wont be used
Time_Variable_ID2: In this variable the time will be saved (in hours)
When you set it to "0" it wont be used
Time_Variable_ID3: In this variable the time will be saved (in minutes)
When you set it to "0" it wont be used
DayCount_Variable: In this variable the days will count
When you set it to "0" it wont be used
Viel Spaß
=end
module TagNachtSystem
#=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
# EDIT-Area
#=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Switch_ID = 10
Tag_Nacht_Time = 0.2
Change_Time = 5
Farbton = [
[-128, -128, -64, 128], #Midnight Index: 0
[-34, -34, 0, 68], #Midnight > Morning Index: 1
[-16, -64, -64, 32], #Morning Index: 2
[0, 0, 0, 0], #Morning > Midday Index: 3
[34, 34, 0, 0], #Midday Index: 4
[68, -34, -34, 0], #Midday > Afternoon Index: 5
[-68, -68, -68, 0], #Afternoon Index: 6
[-68, -68, 0, 68] #Afternoon > Midnight Index: 7
]
Time_Variable_ID1 = 10
Time_Variable_ID2 = 11
Time_Variable_ID3 = 12
Time_Variable_ID4 = 13
DayCount_Variable = 14
#=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
# END
#=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
end
#==============================================================================
# ** DataManager
#------------------------------------------------------------------------------
# This module manages the database and game objects. Almost all of the
# global variables used by the game are initialized by this module.
#==============================================================================
module DataManager
class << self
alias taj_datamanager_creategameobjects_uzgv21 create_game_objects
#--------------------------------------------------------------------------
# * Create Game Objects
#--------------------------------------------------------------------------
def create_game_objects
taj_datamanager_creategameobjects_uzgv21
$game_system.daynightsystem = Day_Night.new
end
end
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles system data. It saves the disable state of saving and
# menus. Instances of this class are referenced by $game_system.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :daynightsystem
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
alias taj_gamemap_update_jkbdsf9 update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update(main = false)
taj_gamemap_update_jkbdsf9(main)
$game_system.daynightsystem.update if $game_switches[TagNachtSystem::Switch_ID]
end
end
class Day_Night
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
t = Tone.new(TagNachtSystem::Farbton[0][0],TagNachtSystem::Farbton[0][1],TagNachtSystem::Farbton[0][2],TagNachtSystem::Farbton[0][3])
$game_map.screen.start_tone_change(t, 0)
t = nil
@timer_in_value = 0
@timer_in_hours = 0
@timer_in_minutes = 0
@timer_in_hours_temp = 0
@daycount = 0
a = TagNachtSystem::Tag_Nacht_Time*3600
b = TagNachtSystem::Tag_Nacht_Time*3600*0.25
c = TagNachtSystem::Tag_Nacht_Time*3600*0.5
@timersettings = [
0, (b - a*0.02).round, c.round, (b + c + a*0.02).round,
a.round, (a + b - a*0.02).round, (a + c).round,
(a + b + c + a*0.02).round, (a * 2).round
]
p @timersettings
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
testfortime()
@timer_in_value += 1
set_variables()
end
#--------------------------------------------------------------------------
# * Sets the Variables
#--------------------------------------------------------------------------
def set_variables()
$game_variables[TagNachtSystem::Time_Variable_ID1] = @timer_in_value if TagNachtSystem::Time_Variable_ID1 != 0
if TagNachtSystem::Time_Variable_ID2 != 0
max = (TagNachtSystem::Tag_Nacht_Time*3600*2).to_f
mom = @timer_in_value.to_f
x = (max/mom).to_f if mom != 0
@timer_in_hours_temp = 24/x
@timer_in_hours = (24/x).to_i if x != 0
$game_variables[TagNachtSystem::Time_Variable_ID2] = "%02d" % @timer_in_hours
x = 0
end
if TagNachtSystem::Time_Variable_ID3 != 0
h = @timer_in_hours_temp - @timer_in_hours_temp.to_i
h2 = (@timer_in_hours_temp+1).to_i - @timer_in_hours_temp.to_i
x = (60*h/h2).to_i
@timer_in_minutes = x
$game_variables[TagNachtSystem::Time_Variable_ID3] = "%02d" % @timer_in_minutes
x = 0
end
$game_variables[TagNachtSystem::Time_Variable_ID4] = get_time() if TagNachtSystem::Time_Variable_ID4 != 0
end
#--------------------------------------------------------------------------
# * Test for Time
#--------------------------------------------------------------------------
def testfortime()
case @timer_in_value
when @timersettings[0] then set_color(0)
when @timersettings[1] then set_color(1)
when @timersettings[2] then set_color(2)
when @timersettings[3] then set_color(3)
when @timersettings[4] then set_color(4)
when @timersettings[5] then set_color(5)
when @timersettings[6] then set_color(6)
when @timersettings[7] then set_color(7)
end
if @timer_in_value == @timersettings[8] #mitternacht
set_color(0)
@timer_in_value = 0
@daycount += 1
$game_varibales[TagNachtSystem::DayCount_Variable] = @daycount if TagNachtSystem::DayCount_Variable != 0
end
end
#--------------------------------------------------------------------------
# * Set Color
#--------------------------------------------------------------------------
def set_color(n)
t = Tone.new(TagNachtSystem::Farbton[n][0],TagNachtSystem::Farbton[n][1],TagNachtSystem::Farbton[n][2],TagNachtSystem::Farbton[n][3])
$game_map.screen.start_tone_change(t, TagNachtSystem::Change_Time*60)
end
#--------------------------------------------------------------------------
# * Set Tone
#--------------------------------------------------------------------------
def set_tone(t)
case t
when 0 then @timer_in_value = @timersettings[0]
when 1 then @timer_in_value = @timersettings[1]
when 2 then @timer_in_value = @timersettings[2]
when 3 then @timer_in_value = @timersettings[3]
when 4 then @timer_in_value = @timersettings[4]
when 5 then @timer_in_value = @timersettings[5]
when 6 then @timer_in_value = @timersettings[6]
when 7 then @timer_in_value = @timersettings[7]
end
end
#--------------------------------------------------------------------------
# * get Time
#--------------------------------------------------------------------------
def get_time()
@t = false
@timersettings.each_with_index do |x, i|
if @timer_in_value >= @timersettings[i]
@t = true
else
return i
end
end
end
end