[XP] Advanced Time and Environment System

Started by fugibo, March 09, 2008, 11:08:36 pm

Previous topic - Next topic

fugibo

Meh, good point. But I still don't see the point in defining the temperature in Fahrenheit or Celsius when the user can just decide on the ranges and give it a name :/

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Jackolas

more added it this way because of the standard calculations I know.
ofc its probably more easy to calculate K first from F to C and than - 273
but K was more an extra... should not be added because its only really used in the science

F and C are the important 1

Zare

October 31, 2009, 03:01:13 pm #123 Last Edit: November 01, 2009, 06:36:12 am by Zare
Hey i would like to know if someone could make a menu window with the time in it instead of the timedisplay on the map.
i thought of something like this (clock instead of playtime window)

this is the playtime window

Spoiler: ShowHide
class Window_PlayTime < Window_Base
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   super(0, 0, 160, 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   refresh
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   self.contents.font.name = "Calligraph421 BT"
  self.contents.font.size = 18
   self.contents.font.color = system_color
   self.contents.draw_text(4, 0, 120, 32, "")    
   @total_sec = Graphics.frame_count / Graphics.frame_rate
   hour = @total_sec / 60 / 60
   min = @total_sec / 60 % 60
   sec = @total_sec % 60    
   text = sprintf("%02d :%02d :%02d", hour, min, sec)    
   self.contents.font.color = normal_color
   self.contents.draw_text(4, 0, 122, 32, text, 2)
 end


now how do i replace the playtime with the clock??

plz help^^ (sorry if this is necropost...)

EDIT: Ok i found the solution in the help section

http://forum.chaos-project.com/index.php?topic=4626.0


happyman

Would it be possible to script something that stops time while text windows are being displayed, just like how time stops when the player opens the menu?

I really don't want to script command ATES.on and ATES.off before and after every bit of text.

Jackolas

without a lot of edits in the code of RMXP self you need to stick with the ATES.on and ATES.off before and after every bit of text.

happyman

That is sad to hear.  :(

Oh well.  This script is great, btw.  I love it.   :haha:

Aqua

Nah uh... o.o
You'd just have to edit the method that draws the text boxes.

Jackolas

tryed. could not get it to work (probably cause I'm crap at scripting)

ShinyToyGuns

I've encountered a glitch with this script...When I enter the menu, it keeps the time clock on, and when I exit the menu, it has a frozen time behind the current time.
Example:
Spoiler: ShowHide

I've also made a few minor changes to the script, I don't know if that, or one of the other scripts I'm using could be affecting the way it works?

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Advanced Time and Environment System (ATES) by Blizzard
# Version: 0.34
# Type: Autonomous Timeflow and Environment Controller
# Date v0.3: 11.3.2008
# Date v0.31: 8.4.2009
# Date v0.32: 13.4.2009
# Date v0.33: 4.5.2009
# Date v0.34: 5.5.2009
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
#   99% compatible with SDK v1.x. 90% compatible with SDK 2.x. WILL corrupt old
#   savegames. Can cause incompatibilty issues with DNS-es.
#
#
# Features:
#
#   - complete control over and easy manipulating of time
#   - nice day and night tinting
#   - HUD clock optional
#   - easier to control and more powerful than DDNS
#
#
# IMPORTANT NOTES:
#
# - This system has a working preconfiguration, be aware that a custom setup
#   will need you to understand what each option does, so please read the
#   configuration instructions.
# - Why does this system use switches to determine whether it's day or night?
#   Simple: You can use conditions in enemy attacks to determine whether an
#   attack should be used only at night or only at day.
#
#
# Instructions:
#
# - Explanation:
#
#   This Time System will make your game have daytime and nighttime periods.
#   The screen will be tinted accordingly. You can set up the length of the
#   day. Other features are explained below. Please be sure to configure this
#   system appropriately.
#
#
# - Basic manipulation of ATES:
#
#   This system is based upon your eventing. It will work basically if you
#   want, but with a little bit of using the "Call Script" event command you
#   are able to control this system fully. You can call following commands:
#
#     ATES.on
#   Turns ATES on.
#
#     ATES.off
#   Turns ATES off.
#
#     ATES.tint_on
#   Turns ATES's screen tinting on.
#
#     ATES.tint_off
#   Turns ATES's screen tinting off.
#
#     ATES.clock_on
#   Turns ATES's clock display on.
#
#     ATES.clock_off
#   Turns ATES's clock display off.
#
#     ATES.active?
#   Returns true if ATES is turned on, otherwise false.
#
#     ATES.tinting?
#   Returns true if ATES tinting is turned on, otherwise false.
#
#     ATES.day?
#   Returns true if it's day, otherwise false. Alternatively you can check the
#   assigned switch instead.
#
#     ATES.night?
#   Returns true if it's night, otherwise false. Alternatively you can check
#   the assigned switch instead.
#   
#     ATES.advance(M, H)
#   This will make the time advanced by M minutes and H hours. Any negative
#   value used will cancel the execution of this command.
#   
#     ATES.make_it_day
#   This is a feature from DDNS which allows you to quickly jump to the
#   daytime.
#   
#     ATES.make_it_night
#   This is a feature from DDNS which allows you to quickly jump to the
#   nighttime.
#   
#
# - Enhancement hints:
#
#   If you wish to implement the DDNS further into your game and e.g. allow
#   different behavious of monsters during day and night, you only need to
#   check the the state of the appropriate switch. e.g. If NSWITCH is turned
#   on inflict "Sleep" on one enemy.
#
#
# Additional info:
#
#   The daytime and nighttime tintings were tested appropriately and optimal
#   tinting is being used.
#   Keep in mind that ATES is initially turned off, you need to turn it on by
#   using the ATES.on and ATES.tint_on commands together.
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

module ATES
 
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # switch ID of the "day" switch
  DSWITCH = 51
  # switch ID of the "night" switch
  NSWITCH = 52
  # length of a day in seconds in-game, can't be less than 36, is being
  # quantized into intervals of 36 seconds
  LENGTH = 1440
  # how much time is it when the "day" starts
  DAY_START = 8
  # how much time is it when the "night" starts
  NIGHT_START = 20
  # makes the screen brighter during "summer" days
  OVERLIGHTING = true
  # makes the screen darker during the night, not recommended
  OVERDARKENING = false
  # display HUD clock
  SHOW_CLOCK = true
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
  $ates = 0.34
 
  #============================================================================
  # ATES::Time
  #============================================================================
 
  class Time
   
    attr_accessor :min
    attr_accessor :hour
   
    def initialize(m, h)
      @min, @hour = m, h
    end
   
  end
 
  def self.on
    $game_system.ates.active = true
    return true
  end
 
  def self.off
    $game_system.ates.active = false
    return true
  end
 
  def self.tint_on
    $game_system.ates.tinting = true
    return true
  end
 
  def self.tint_off
    $game_system.ates.tinting = false
    return true
  end
 
  def self.clock_on
    $game_system.show_clock = true
    return true
  end
 
  def self.clock_off
    $game_system.show_clock = false
    return true
  end
 
  def self.active?
    return $game_system.ates.active
  end
 
  def self.tinting?
    return $game_system.ates.tinting
  end
 
  def self.day?
    return ($game_system.ates.time.hour.between?(DAY_START, NIGHT_START - 1))
  end
 
  def self.night?
    return ($game_system.ates.time.hour.between?(DAY_START, NIGHT_START - 1))
  end
 
  def self.make_it_day
    $game_system.ates.time.hour = DAY_START
    $game_system.ates.time.min = 0
    return true
  end
 
  def self.make_it_night
    $game_system.ates.time.hour = NIGHT_START
    $game_system.ates.time.min = 0
    return true
  end
 
  def self.day_start
    return DAY_START
  end
 
  def self.night_start
    return NIGHT_START
  end
 
  def self.advance(m, h)
    return false if [m, h].any? {|i| i < 0}
    h += ($game_system.ates.time.min + m) / 60
    $game_system.ates.time.min = ($game_system.ates.time.min + m) % 60
    $game_system.ates.time.hour = ($game_system.ates.time.hour + h) % 24
    return true
  end
 
end

if ATES::DAY_START > ATES::NIGHT_START
  raise 'ATEScfgError: A night can\'t start earlier than a day.'
elsif ATES::LENGTH < 36
  raise 'ATEScfgError: A day\'s length must be equal to or greater than 36 seconds!'
end

#==============================================================================
# Game_System
#==============================================================================

class Game_System
 
  attr_accessor :ates
  attr_accessor :show_clock
 
  alias init_ates_later initialize
  def initialize
    init_ates_later
    @ates = Game_ATES.new
    @show_clock = ATES::SHOW_CLOCK
  end

end

#==============================================================================
# Game_ATES
#==============================================================================

class Game_ATES
 
  attr_accessor :active
  attr_accessor :tinting
  attr_accessor :time
  attr_accessor :frame_count
 
  def initialize
    @time = ATES::Time.new(0, 8)
    @active = true
    @tinting = true
    @frame_count = 0
  end
 
  def get_tint
    red = 0
    green = 0
    blue = 0
    grey = 0
    if ATES.day?
      red = green = 0
      day = ATES.day_start
      night = ATES.night_start
      ratio = ((@time.hour-day)*60+@time.min) * 255 / (60*(night-day))
      if ratio >= 224
        red = (232-ratio)*4
        green = (208-ratio)*2
      elsif ratio >= 192
        red = ratio-192
        green = 192-ratio
      elsif ATES::OVERLIGHTING
        if ratio >= 160
          red = green = blue = 192-ratio
        elsif ratio >= 96
          red = green = blue = 32
        elsif ratio >= 64
          red = green = blue = ratio-64
        end
      end
    else
      red = green = -96
      day = ATES.day_start
      night = ATES.night_start
      hour = (@time.hour >= night ? @time.hour : @time.hour+24)
      ratio = ((hour-night)*60+@time.min) * 255 / (60*(day+24-night))
      if ratio >= 224
        red = (ratio-256)*2
        green = (ratio-256)*2
        blue = 255-ratio
      elsif ratio >= 192
        red = ratio-288
        green = ratio-288
        blue = ratio-192
      elsif ATES::OVERDARKENING
        if ratio >= 160
          red = ratio-288
          green = ratio-288
          blue = ratio-192
        elsif ratio >= 96
          red = -128
          green = -128
          blue = -32
        elsif ratio >= 64
          red = -32-ratio
          green = -32-ratio
          blue = 64-ratio
        end
      end
    end
    return Tone.new(red, green, blue, grey)
  end
 
  def update
    if @active
      @frame_count += 1
      ATES.advance(1, 0) if @frame_count % (ATES::LENGTH / 36) == 0
    end
    if ATES.day?
      $game_map.need_refresh = true if $game_switches[ATES::NSWITCH]
      $game_switches[ATES::DSWITCH] = true
      $game_switches[ATES::NSWITCH] = false
    else
      $game_map.need_refresh = true if $game_switches[ATES::DSWITCH]
      $game_switches[ATES::DSWITCH] = false
      $game_switches[ATES::NSWITCH] = true
    end
    $game_screen.start_tone_change(get_tint, 0) if @tinting
  end
 
end

#==============================================================================
# Bitmap
#==============================================================================

class Bitmap

  if $tons_version == nil || $tons_version < 1.6
    alias draw_text_shaded_later draw_text
  end
  def draw_text_full(x2, y2, w2 = 0, h2 = 0, text2 = '', a2 = 0)
    if x2.is_a?(Rect)
      x, y, w, h, text, a = x2.x, x2.y, x2.width, x2.height, y2, w2
    else
      x, y, w, h, text, a = x2, y2, w2, h2, text2, a2
    end
    save_color = self.font.color.clone
    self.font.color = Color.new(0, 0, 0)
    [x-1, x+1].each {|xx| [y-1, y+1].each {|yy|
            draw_text_shaded_later(xx, yy, w, h, text, a)}}
    self.font.color = save_color
    draw_text_shaded_later(x, y, w, h, text, a)
  end
 
end

#==============================================================================
# Clock_Sprite
#==============================================================================

class Clock_Sprite < Sprite
 
  def initialize
    super
    self.x, self.y, self.z = 480, 8, 5000
    self.bitmap = Bitmap.new(128, 32)
    if $fontface != nil
      self.bitmap.font.name = $fontface
    elsif $defaultfonttype != nil
      self.bitmap.font.name = $defaultfonttype
    end
    self.bitmap.font.size = 26
    @odd = 0
    draw if $game_system.ates.active
  end
 
  def draw
    self.bitmap.clear
    hours = $game_system.ates.time.hour
    minutes = sprintf('%02d', $game_system.ates.time.min)
    if @odd % 2 == 0
      self.bitmap.draw_text_full(0, 0, 128, 32, "#{hours}:#{minutes}", 2)
    else
      self.bitmap.draw_text_full(0, 0, 128, 32, "#{hours}:#{minutes}", 2)
    end
    @odd = (@odd + 1) % 2
  end
   
end

#==============================================================================
# Scene_Map
#==============================================================================

class Scene_Map
 
  alias main_ates_later main
  def main
    @clock = Clock_Sprite.new if $game_system.show_clock
    main_ates_later
    @clock.dispose unless @clock == nil
  end
 
  alias update_ates_later update
  def update
    $game_system.ates.update
    update_ates_later
    if $game_system.show_clock
      @clock = Clock_Sprite.new if @clock == nil
      @clock.draw if $game_system.ates.frame_count % 40 == 0
    elsif @clock != nil
      @clock.dispose
      @clock = nil
    end
  end
 
  alias transfer_player_ates_later transfer_player
  def transfer_player
    $game_system.ates.update
    transfer_player_ates_later
  end
 
end


The other scripts I'm using are:
Auto Font Install by Wachunga
Advanced Message Script by Dubealex
Zeriab's Questbook
Tons of Add-ons
Blizzard ABS
RO Job/Skill System
Blizz-ABS Party HUD by Winkio
Days
I've missed so many days
In a world that has become an unfamiliar place
Now to you, I'm just an unfamiliar face

~Shiny Toy Guns, Blown Away (2008)

Jackolas

looking at the screen it can be that you miss a refresh ore something in the script

ShinyToyGuns

Quote from: Jackolas on November 19, 2009, 02:06:52 am
looking at the screen it can be that you miss a refresh ore something in the script

in English please? :P (I'm not too script-saavy)
Days
I've missed so many days
In a world that has become an unfamiliar place
Now to you, I'm just an unfamiliar face

~Shiny Toy Guns, Blown Away (2008)

Alton Wyte

I may be new to these forums but I'm experienced with XP.
Im having a problem with my game(many actually) but one has to do with this.
I set the screen tinting off and set it to my own color but the normal tinting is still there and at 5:08 or 5:12 it randomly switches from night to day with no transition. Help?

Jackolas

to ShinyToyGuns:

I'm unable to recreate your problem. i would suggest to look into using a different script order. try to put this script under all your other custom scripts. hope that will fix it.

to Alton Wyte:

you probably made some mistake in the editing of the script. if you can post your edit version so we can take a look at it

Alton Wyte

November 20, 2009, 03:16:56 am #134 Last Edit: November 20, 2009, 03:18:24 am by Alton Wyte

All I did was put in the configuration. And also I noticed at 6:30 it changes back to night and begins to fade to daytime.
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Advanced Time and Environment System (ATES) by Blizzard
# Version: 0.34
# Type: Autonomous Timeflow and Environment Controller
# Date v0.3: 11.3.2008
# Date v0.31: 8.4.2009
# Date v0.32: 13.4.2009
# Date v0.33: 4.5.2009
# Date v0.34: 5.5.2009
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# #  
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #  
# #  You are free:
# #  
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# #  
# #  Under the following conditions:
# #  
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# #  
# #  Noncommercial. You may not use this work for commercial purposes.
# #  
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# #  
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# #  
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# #  
# #  - Nothing in this license impairs or restricts the author's moral rights.
# #  
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
#   99% compatible with SDK v1.x. 90% compatible with SDK 2.x. WILL corrupt old
#   savegames. Can cause incompatibilty issues with DNS-es.
#
#
# Features:
#
#   - complete control over and easy manipulating of time
#   - nice day and night tinting
#   - HUD clock optional
#   - easier to control and more powerful than DDNS
#
#
# IMPORTANT NOTES:
#
# - This system has a working preconfiguration, be aware that a custom setup
#   will need you to understand what each option does, so please read the
#   configuration instructions.
# - Why does this system use switches to determine whether it's day or night?
#   Simple: You can use conditions in enemy attacks to determine whether an
#   attack should be used only at night or only at day.
#
#
# Instructions:
#
# - Explanation:
#
#   This Time System will make your game have daytime and nighttime periods.
#   The screen will be tinted accordingly. You can set up the length of the
#   day. Other features are explained below. Please be sure to configure this
#   system appropriately.
#
#
# - Basic manipulation of ATES:
#
#   This system is based upon your eventing. It will work basically if you
#   want, but with a little bit of using the "Call Script" event command you
#   are able to control this system fully. You can call following commands:
#
#     ATES.on
#   Turns ATES on.
#
#     ATES.off
#   Turns ATES off.
#
#     ATES.tint_on
#   Turns ATES's screen tinting on.
#
#     ATES.tint_off
#   Turns ATES's screen tinting off.
#
#     ATES.clock_on
#   Turns ATES's clock display on.
#
#     ATES.clock_off
#   Turns ATES's clock display off.
#
#     ATES.active?
#   Returns true if ATES is turned on, otherwise false.
#
#     ATES.tinting?
#   Returns true if ATES tinting is turned on, otherwise false.
#
#     ATES.day?
#   Returns true if it's day, otherwise false. Alternatively you can check the
#   assigned switch instead.
#
#     ATES.night?
#   Returns true if it's night, otherwise false. Alternatively you can check
#   the assigned switch instead.
#  
#     ATES.advance(M, H)
#   This will make the time advanced by M minutes and H hours. Any negative
#   value used will cancel the execution of this command.
#  
#     ATES.make_it_day
#   This is a feature from DDNS which allows you to quickly jump to the
#   daytime.
#  
#     ATES.make_it_night
#   This is a feature from DDNS which allows you to quickly jump to the
#   nighttime.
#  
#
# - Enhancement hints:
#
#   If you wish to implement the DDNS further into your game and e.g. allow
#   different behavious of monsters during day and night, you only need to
#   check the the state of the appropriate switch. e.g. If NSWITCH is turned
#   on inflict "Sleep" on one enemy.
#
#
# Additional info:
#
#   The daytime and nighttime tintings were tested appropriately and optimal
#   tinting is being used.
#   Keep in mind that ATES is initially turned off, you need to turn it on by
#   using the ATES.on and ATES.tint_on commands together.
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

module ATES
 
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 # switch ID of the "day" switch
 DSWITCH = 26
 # switch ID of the "night" switch
 NSWITCH = 27
 # length of a day in seconds in-game, can't be less than 36, is being
 # quantized into intervals of 36 seconds
 LENGTH = 360
 # how much time is it when the "day" starts
 DAY_START = 8
 # how much time is it when the "night" starts
 NIGHT_START = 20
 # makes the screen brighter during "summer" days
 OVERLIGHTING = true
 # makes the screen darker during the night, not recommended
 OVERDARKENING = false
 # display HUD clock
 SHOW_CLOCK = true
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
 $ates = 0.34
 
 #============================================================================
 # ATES::Time
 #============================================================================
 
 class Time
   
   attr_accessor :min
   attr_accessor :hour
   
   def initialize(m, h)
     @min, @hour = m, h
   end
   
 end
 
 def self.on
   $game_system.ates.active = true
   return true
 end
 
 def self.off
   $game_system.ates.active = false
   return true
 end
 
 def self.tint_on
   $game_system.ates.tinting = true
   return true
 end
 
 def self.tint_off
   $game_system.ates.tinting = false
   return true
 end
 
 def self.clock_on
   $game_system.show_clock = true
   return true
 end
 
 def self.clock_off
   $game_system.show_clock = false
   return true
 end
 
 def self.active?
   return $game_system.ates.active
 end
 
 def self.tinting?
   return $game_system.ates.tinting
 end
 
 def self.day?
   return ($game_system.ates.time.hour.between?(DAY_START, NIGHT_START - 1))
 end
 
 def self.night?
   return (!self.day)
 end
 
 def self.make_it_day
   $game_system.ates.time.hour = DAY_START
   $game_system.ates.time.min = 0
   return true
 end
 
 def self.make_it_night
   $game_system.ates.time.hour = NIGHT_START
   $game_system.ates.time.min = 0
   return true
 end
 
 def self.day_start
   return DAY_START
 end
 
 def self.night_start
   return NIGHT_START
 end
 
 def self.advance(m, h)
   return false if [m, h].any? {|i| i < 0}
   h += ($game_system.ates.time.min + m) / 60
   $game_system.ates.time.min = ($game_system.ates.time.min + m) % 60
   $game_system.ates.time.hour = ($game_system.ates.time.hour + h) % 24
   return true
 end
 
end

if ATES::DAY_START > ATES::NIGHT_START
 raise 'ATEScfgError: A night can\'t start earlier than a day.'
elsif ATES::LENGTH < 36
 raise 'ATEScfgError: A day\'s length must be equal to or greater than 36 seconds!'
end

#==============================================================================
# Game_System
#==============================================================================

class Game_System
 
 attr_accessor :ates
 attr_accessor :show_clock
 
 alias init_ates_later initialize
 def initialize
   init_ates_later
   @ates = Game_ATES.new
   @show_clock = ATES::SHOW_CLOCK
 end

end

#==============================================================================
# Game_ATES
#==============================================================================

class Game_ATES
 
 attr_accessor :active
 attr_accessor :tinting
 attr_accessor :time
 attr_accessor :frame_count
 
 def initialize
   @time = ATES::Time.new(0, 0)
   @active = false
   @tinting = false
   @frame_count = 0
 end
 
 def get_tint
   red = 0
   green = 0
   blue = 0
   grey = 0
   if ATES.day?
     red = green = 0
     day = ATES.day_start
     night = ATES.night_start
     ratio = ((@time.hour-day)*60+@time.min) * 255 / (60*(night-day))
     if ratio >= 224
       red = (232-ratio)*4
       green = (208-ratio)*2
     elsif ratio >= 192
       red = ratio-192
       green = 192-ratio
     elsif ATES::OVERLIGHTING
       if ratio >= 160
         red = green = blue = 192-ratio
       elsif ratio >= 96
         red = green = blue = 32
       elsif ratio >= 64
         red = green = blue = ratio-64
       end
     end
   else
     red = green = -96
     day = ATES.day_start
     night = ATES.night_start
     hour = (@time.hour >= night ? @time.hour : @time.hour+24)
     ratio = ((hour-night)*60+@time.min) * 255 / (60*(day+24-night))
     if ratio >= 224
       red = (ratio-256)*2
       green = (ratio-256)*2
       blue = 255-ratio
     elsif ratio >= 192
       red = ratio-192
       green = ratio-192
       blue = ratio-192
     elsif ATES::OVERDARKENING
       if ratio >= 160
         red = ratio-288
         green = ratio-288
         blue = ratio-192
       elsif ratio >= 96
         red = -128
         green = -128
         blue = -32
       elsif ratio >= 64
         red = -32-ratio
         green = -32-ratio
         blue = 64-ratio
       end
     end
   end
   return Tone.new(red, green, blue, grey)
 end
 
 def update
   if @active
     @frame_count += 1
     ATES.advance(1, 0) if @frame_count % (ATES::LENGTH / 36) == 0
   end
   if ATES.day?
     $game_map.need_refresh = true if $game_switches[ATES::NSWITCH]
     $game_switches[ATES::DSWITCH] = true
     $game_switches[ATES::NSWITCH] = false
   else
     $game_map.need_refresh = true if $game_switches[ATES::DSWITCH]
     $game_switches[ATES::DSWITCH] = false
     $game_switches[ATES::NSWITCH] = true
   end
   $game_screen.start_tone_change(get_tint, 0) if @tinting
 end
 
end

#==============================================================================
# Bitmap
#==============================================================================

class Bitmap

 if $tons_version == nil || $tons_version < 1.6
   alias draw_text_shaded_later draw_text
 end
 def draw_text_full(x2, y2, w2 = 0, h2 = 0, text2 = '', a2 = 0)
   if x2.is_a?(Rect)
     x, y, w, h, text, a = x2.x, x2.y, x2.width, x2.height, y2, w2
   else
     x, y, w, h, text, a = x2, y2, w2, h2, text2, a2
   end
   save_color = self.font.color.clone
   self.font.color = Color.new(0, 0, 0)
   [x-1, x+1].each {|xx| [y-1, y+1].each {|yy|
           draw_text_shaded_later(xx, yy, w, h, text, a)}}
   self.font.color = save_color
   draw_text_shaded_later(x, y, w, h, text, a)
 end
 
end

#==============================================================================
# Clock_Sprite
#==============================================================================

class Clock_Sprite < Sprite
 
 def initialize
   super
   self.x, self.y, self.z = 480, 8, 5000
   self.bitmap = Bitmap.new(128, 32)
   if $fontface != nil
     self.bitmap.font.name = $fontface
   elsif $defaultfonttype != nil
     self.bitmap.font.name = $defaultfonttype
   end
   self.bitmap.font.size = 26
   @odd = 0
   draw if $game_system.ates.active
 end
 
 def draw
   self.bitmap.clear
   hours = $game_system.ates.time.hour
   minutes = sprintf('%02d', $game_system.ates.time.min)
   if @odd % 2 == 0
     self.bitmap.draw_text_full(0, 0, 128, 32, "#{hours} #{minutes}", 2)
   else
     self.bitmap.draw_text_full(0, 0, 128, 32, "#{hours}:#{minutes}", 2)
   end
   @odd = (@odd + 1) % 2
 end
   
end

#==============================================================================
# Scene_Map
#==============================================================================

class Scene_Map
 
 alias main_ates_later main
 def main
   @clock = Clock_Sprite.new if $game_system.show_clock
   main_ates_later
   @clock.dispose unless @clock == nil
 end
 
 alias update_ates_later update
 def update
   $game_system.ates.update
   update_ates_later
   if $game_system.show_clock
     @clock = Clock_Sprite.new if @clock == nil
     @clock.draw if $game_system.ates.frame_count % 40 == 0
   elsif @clock != nil
     @clock.dispose
     @clock = nil
   end
 end
 
 alias transfer_player_ates_later transfer_player
 def transfer_player
   $game_system.ates.update
   transfer_player_ates_later
 end
 
end


ShinyToyGuns

Quote from: Jackolas on November 20, 2009, 02:32:31 am
to ShinyToyGuns:

I'm unable to recreate your problem. i would suggest to look into using a different script order. try to put this script under all your other custom scripts. hope that will fix it.


OMG! you are a GOD!!! Thank you so much :D
Days
I've missed so many days
In a world that has become an unfamiliar place
Now to you, I'm just an unfamiliar face

~Shiny Toy Guns, Blown Away (2008)

Jackolas

to Alton Wyte:
QuoteAll I did was put in the configuration. And also I noticed at 6:30 it changes back to night and begins to fade to daytime.


hearing the problem i think the problem lies in a other script that is causing errors with this 1.
can you write up the scripts you use?

to ShinyToyGuns:
Np m8. Most problems in scripts are always about script oreders

Blizzard

I posted up v0.4 which has a few small changes to the RMX-OS GDNS plugin can be shorter.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

legacyblade

Is there a way to have different lengths of day based on what region you're in? My game takes place where two of the main areas are 3 latitude lines apart, which would cause a different length of day, as well as different tinting (one's tropical, one's more temperate). If that's not possible, it won't hurt the game much, but it'd really add to the immersion.

Jackolas

January 10, 2010, 08:54:41 pm #139 Last Edit: January 10, 2010, 09:00:46 pm by Jackolas
that's easy to do.. just needs some edits

I'm just wondering why you (the awesome guy that got me into scripting thanks to your class change script) can't do it?
I was thinking about adding an ats2 config
putting some "if" switches and it should work

anyway. if you want i can make it.. but not faster than next week (need to finish work rapport)