[Hướng Dẫn] [Help] Cần giúp về script(XP) day and night

in RPG Maker
Tình hình là mới mò mẫm cái script này vì lười làm event quá @_@
script của 2009 nhưng khi mình call script $game_dnc.enable thì lại bị crash ra ngoài 
ai nhìn qua cái script này sau đó giúp mình làm thế nào để enable nó được không?
nếu ko giúp đx cái này thì ai đó có thể hướng dẫn qua cho mình cách làm ngày và đêm bằng event đx ko.. biến số ý.. đang loạn óc nên chưa suy nghĩ đx gì hay ho cả
#|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
# Day Night Climate System (DNC) by Winkio
# Version: 1.00
#|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
#
#
#|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
# This script keeps track of the time of day and tints the screen accordingly.
# The user can define the length of the day and night.
# Also, the user can create climates which determine the chances of different
# types of weather, which are automatically applied to any map through this
# script.
#
# Have three sound files, "Wind.ogg", "Rain.ogg", and "Storm.ogg" in your BGS
# folder to be used as sound effects for those weathers.
#
# Commands:
# $game_dnc.disable - disables the DNC
# $game_dnc.enable - enables the DNC
# $game_dnc.setup_climate(id, phase) - sets up a climate. If phase is true,
# it sets up the climate for the map of the id. If phase it false, it sets
# up the climate with that id
# $game_dnc.pass_time(amount) - time passes for the amount of seconds
# $game_dnc.goto_day - sets the time to daybreak
# $game_dnc.goto_night - sets the time to nightfall
# $game_dnc.set_weather_rates(rate1, rate2, rate3, rate4, rate5) - sets the
# chances of getting different weather. rates are from 0-100
# $game_dnc.set_weather_states(state1, state2, state3, state4, state5) - sets
# what weather is currently happening or not (true/false)
# $game_dnc.set_time(newtime) - sets the time to newtime
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
#===============================================================================
# Climates
#
# Configure your climates here.
#===============================================================================
module Climates
#=============================================================================
# get(id)
#
# returns the climate number for map with ID id.
# when (MAP_ID) then return (CLIMATE_ID)
#=============================================================================
def self.get(id)
case id
when 12 then return 1
end
return 0
end
#=============================================================================
# cycle(id)
#
# returns the length of a day/night cycle for the climate with ID id.
# (in seconds)
# when (CLIMATE_ID) then return (CYCLE_LENGTH)
#=============================================================================
def self.cycle(id)
case id
when 1 then return 60
when 2 then return 300
end
return 0
end
#=============================================================================
# day_night(id)
#
# returns the day start, night start, day transition, and night transition
# times for the climate with ID id.
# (in seconds)
# when (CLIMATE_ID) then return
# [day_start, night_start, day_transition, night_transition]
#=============================================================================
def self.day_night(id)
case id
when 1 then return [0, 30, 5, 5]
when 2 then return [0, 150, 10, 10]
end
return [0, 0, 0, 0]
end
#=============================================================================
# weather(id)
#
# returns the percent chance of wind, clouds, rain, snow, and storm weather
# for the climate with ID id.
# (0-100)
# when (CLIMATE_ID) then return
# [wind_chance, clouds_chance, rain_chance, snow_chance, storm_chance]
#=============================================================================
def self.weather(id)
case id
when 1 then return [20, 20, 20, 20, 20]
when 2 then return [10, 10, 10, 10, 0]
end
return [0, 0, 0, 0, 0]
end
#=============================================================================
# volatility(id)
#
# returns how often the weather changes for the climate with ID id.
# (in seconds) greater than 0 or weather never updates.
# when (CLIMATE_ID) then return (VOLATILITY)
#=============================================================================
def self.volatility(id)
case id
when 1 then return 15
when 2 then return 30
end
return 0
end
end
#==============================================================================
# DNC
#==============================================================================
class DNC
attr_accessor :cid
attr_accessor :time
attr_accessor :day
attr_accessor :weather
attr_accessor :cycle
attr_accessor :day_start
attr_accessor :night_start
attr_accessor :day_tran
attr_accessor :night_tran
attr_accessor :wind
attr_accessor :clouds
attr_accessor :rain
attr_accessor :snow
attr_accessor :storm
attr_accessor :current_weather
attr_accessor :volatility
def initialize
@time = 0
@day = true
@weather = [false, false, false, false, false]
setup_climate(0)
end
def setup_climate(id, phase=true)
if phase
@cid = Climates.get(id)
else
@cid = id
end
@cycle = Climates.cycle(cid)
@day_start = Climates.day_night(cid)[0]
@night_start = Climates.day_night(cid)[1]
@day_tran = Climates.day_night(cid)[2]
@night_tran = Climates.day_night(cid)[3]
@wind = Climates.weather(cid)[0]
@clouds = Climates.weather(cid)[1]
@rain = Climates.weather(cid)[2]
@snow = Climates.weather(cid)[3]
@storm = Climates.weather(cid)[4]
@volatility = Climates.volatility(cid)
if @cycle != 0
@time %= @cycle
end
end
def self.disable
setup_climate(0)
end
def self.enable
setup_climate($game_map.map_id)
end
def pass_time(amount=1)
if @cycle != 0
@time = (@time + amount)%@cycle
end
end
def goto_day
@time = @day_start
apply_day_night
end
def goto_night
@time = @night_start
apply_day_night
end
def set_weather_rates(rate1, rate2, rate3, rate4, rate5)
@wind = rate1
@clouds = rate2
@rain = rate3
@snow = rate4
@storm = rate5
end
def set_weather_states(state1, state2, state3, state4, state5)
@weather = [state1, state2, state3, state4, state5]
end
def set_time(newtime)
@time = newtime % @cycle
apply_day_night
end
def apply_day_night
# determine if it is day or night
if @time < @night_start and @time > @day_start
newday = true
else
newday = false
end
# transition if not the same as current state of day
if @cid != 0 and newday != @day
if newday
$game_screen.start_tone_change(Tone.new(0, 0, 0, 0), 40*@day_tran)
else
$game_screen.start_tone_change(Tone.new(-40, -40, 0, 0), 40*@night_tran)
end
@day = newday
end
end
def apply_climate
# determine weather
if @cid != 0
chance = rand(100)
if chance < @wind
@weather[0] = true
else
@weather[0] = false
end
chance = rand(100)
if chance < @clouds
@weather[1] = true
else
@weather[1] = false
end
chance = rand(100)
if chance < @rain
@weather[2] = true
else
@weather[2] = false
end
chance = rand(100)
if chance < @snow
@weather[3] = true
else
@weather[3] = false
end
chance = rand(100)
if chance < @storm
@weather[4] = true
else
@weather[4] = false
end
end
# apply weather
if @weather[3]
# apply snow
$game_system.bgs_fade(2)
$game_screen.weather(3, 5, 200)
if @day
$game_screen.start_tone_change(Tone.new(0, 0, 0, 64), 160)
else
$game_screen.start_tone_change(Tone.new(-40, -40, 0, 128), 160)
end
elsif @weather[4]
#apply storm
Audio.bgs_play("Audio/BGS/Storm.ogg", 80, 100)
$game_screen.weather(2, 5, 200)
if @day
$game_screen.start_tone_change(Tone.new(-28, -28, -28, 28), 160)
else
$game_screen.start_tone_change(Tone.new(-58, -58, -58, 54), 160)
end
elsif @weather[2]
#apply rain
Audio.bgs_play("Audio/BGS/Rain.ogg", 80, 100)
$game_screen.weather(1, 5, 200)
if @day
$game_screen.start_tone_change(Tone.new(-15, -15, -15, 64), 160)
else
$game_screen.start_tone_change(Tone.new(-50, -50, -50, 128), 160)
end
elsif @weather[1]
#apply clouds
$game_screen.weather(0, 5, 200)
$game_system.bgs_fade(2)
if @day
$game_screen.start_tone_change(Tone.new(-10, -10, -10, 32), 160)
else
$game_screen.start_tone_change(Tone.new(-45, -45, -45, 64), 160)
end
else
if @day
$game_screen.start_tone_change(Tone.new(0, 0, 0, 0), 160)
else
$game_screen.start_tone_change(Tone.new(-40, -40, 0, 0), 160)
end
end
if @weather[0]
#apply wind
$game_screen.weather(0, 5, 200)
Audio.bgs_play("Audio/BGS/Wind.ogg", 80, 100)
end
#if no weather
if @weather == [false, false, false, false, false, false]
$game_screen.weather(0, 5, 200)
$game_system.bgs_fade(2)
end
end
end
$game_dnc = DNC.new
#==============================================================================
# Scene_Map
#==============================================================================
class Scene_Map
attr_accessor :updatetimer
attr_accessor :weathertimer
alias main_dnc_later main
def main
@weathertimer = 0
@updatetimer = Graphics.frame_count / Graphics.frame_rate * 2
$game_dnc.setup_climate($game_map.map_id)
main_dnc_later
end
alias update_dnc_later update
def update
if @updatetimer != Graphics.frame_count / Graphics.frame_rate * 2
update_dnc
@updatetimer = Graphics.frame_count / Graphics.frame_rate * 2
end
update_dnc_later
end
def update_dnc
if $game_dnc.volatility != 0
$game_dnc.pass_time
$game_dnc.apply_day_night
if @weathertimer >= $game_dnc.volatility
$game_dnc.apply_climate
@weathertimer %= $game_dnc.volatility
end
@weathertimer += 1
end
end
alias transfer_player_dnc_later transfer_player
def transfer_player
if $game_map.map_id != $game_temp.player_new_map_id
$game_dnc.setup_climate($game_temp.player_new_map_id)
end
transfer_player_dnc_later
end
end

ai nhìn qua cái script này sau đó giúp mình làm thế nào để enable nó được không?
nếu ko giúp đx cái này thì ai đó có thể hướng dẫn qua cho mình cách làm ngày và đêm bằng event đx ko.. biến số ý.. đang loạn óc nên chưa suy nghĩ đx gì hay ho cả

Comments
google nó ra thế này !!
http://www.gdunlimited.net/scripts/rpg-maker-xp/environment-and-field-scripts/moonpearl-s-daily-life-1-time-and-lighting