Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Day/Night System not working

Ok, I've tried every Day/Night Script I could find and tried them. None of them will work. I did Put a * after the map name so that's not it. My favorite Day/Night Script is this one:

Code:
#-------------------------------------------
# Day/Night System
# Use "*" to call the Script
# Time is based on Computer Time
#-------------------------------------------
module Realtime
  #-------------------------------------------
  # * Object Initialization
  #-------------------------------------------
  def self.initialize
    # integers
    @time       = Time.now
    @second     = @time.sec
    @minute     = @time.min
    @hour       = @time.hour
    @day        = @time.day
    @week       = @time.strftime("%W").to_i
    @month      = @time.month
    @year       = @time.year
    # strings
    @dayame     = @time.strftime("%A")
    @monthname  = @time.strftime("%B")
    @timezone   = @time.strftime("%Z")
    @meridian   = @time.strftime("%p")
  end
  
  #-------------------------------------------
  # * Second ( 0...59 )
  #-------------------------------------------
  def self.second
    return @second
  end
  #-------------------------------------------
  # * Minute ( 0...59 )
  #-------------------------------------------
  def self.minute
    return @minute
  end
  #-------------------------------------------
  # * Hour ( 0...24 )
  #-------------------------------------------
  def self.hour
    return @hour
  end
  #-------------------------------------------
  # * Day ( 1...366 )
  #------------------------------------------
  def self.day
    return @day
  end
  #-------------------------------------------
  # * Week ( 0...53 )
  #-------------------------------------------
  def self.week
    return @week
  end
  #-------------------------------------------
  # * Month ( 1...12 )
  #-------------------------------------------
  def self.month
    return @month
  end
  #-------------------------------------------
  # * Year ( current year )
  #-------------------------------------------
  def self.year
    return @year 
  end
  
  #-------------------------------------------
  # * Day Name ( Monday...Sunday )
  #------------------------------------------
  def self.dayname
    return @dayname.capitalize!
  end
  #-------------------------------------------
  # * Month Name ( January...December )
  #-------------------------------------------
  def self.monthname
    return @monthname.capitalize!
  end
  #-------------------------------------------
  # * Timezone ( GTM / CST )
  #-------------------------------------------
  def self.timezone
    return @timezone
  end
  #-------------------------------------------
  # * Meridian ( AM / PM )
  #-------------------------------------------
  def self.meridian
    return @meridian
  end
  #-------------------------------------------
  # * Now
  #-------------------------------------------
  def self.now
    return @time
  end
  
  #-------------------------------------------
  # * Time Update
  #-------------------------------------------
  def self.update
    # integers
    @time       = Time.now
    @second     = @time.sec
    @minute     = @time.min
    @hour       = @time.hour
    @day        = @time.day
    @week       = @time.strftime("%W").to_i
    @month      = @time.month
    @year       = @time.year
    # strings
    @dayame     = @time.strftime("%A")
    @monthname  = @time.strftime("%B")
    @timezone   = @time.strftime("%Z")
    @meridian   = @time.strftime("%p")
    
    tint_screen
  end
  
  #-------------------------------------------
  # * Tint screen
  #-------------------------------------------
  def self.tint_screen
    if !$scene.is_a?(Scene_Map)
      @tone = $game_screen.tone
      return
    end
    if $scene.is_a?(Scene_Map)
      # added.
      # tint screen only works if map has '*' in the name
      if !$game_map.name.include?("*")
        @tone = Tone.new(0,0,0,0)
        @duration = 0
        $game_screen.start_tone_change(@tone, @duration)
        return
      end

      # change tone and duration here depending on times
      # tone     : screen tone
      # duration : duration of tone change
      if @hour >= 0
        tone = Tone.new(-187, -119, -17, 68)
        duration = 600
      end
      if @hour >= 5
        tone = Tone.new(17, -51, -102, 0)
        duration = 600
      end
      if @hour >= 10
        tone = Tone.new(0, 0, 0, 0)
        duration = 600
      end
      if @hour >= 15
        tone = Tone.new(-68, -136, -34, 0)
        duration = 600
      end
      if @hour >= 20
        tone = Tone.new(-187, -119, -17, 68)
        duration = 600
      end
      @tone = tone
      $game_screen.start_tone_change(@tone, duration)
    end
  end
end

module Graphics
  class << self
    unless @reboot_fix == 1
      alias realtime_update update
      @reboot_fix = 1
    end
    
    def update
      Realtime.update if $game_screen != nil
      realtime_update
    end
  end
end

class Game_Map
  def name
    $map_infos = load_data("Data/MapInfos.rxdata")
    return $map_infos[@map_id].name
  end
end

If someone could please PM me and try to help me make it work that would help a lot. Thanks. Also, I have an Anti-Lag script but I don't think it's the problem because I removed it and the Day/Night Script still wouldn't work.

PS: I don't want to post my Game here because I don't want tons of people downloading it now:s
 
Grandor;249158 said:
Their is nothing wrong with that script, I tried it in a test project. It's based on step count so the more you walk the darker it becomes.

This is going to sound very odd...but the Day/Night system only works in the Battle System:s On the maps it won't work at all...wtf? Any idea whats going on?
 
It sounds to me like another script may be intefering with Game_Map which causes this error. Can you give me a list of any scripts that overwrite Game_Map? I may be able to remedy a solution if you do.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top