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.

Time System

Hey all! Just another demand from your friendly neighborhood flightless bird leader! :lol:

I'm after a good day and night system with a few bells and a couple whistles. I want it to take the system time straight from the player's computer (so if the player is playing the game at 12:30 PM, the in-game time is 12:30 PM as well). Like Animal Crossing, I guess.

Other than that, I just need some pretty standard stuff. There should be four times of day; morning, afternoon, evening, and night. Morning should set the screen tone a bit lighter than usual (about 34,34,34,0 in screen tone terms), Afternoon shoud be normal (0,0,0,0), evening a little darker (-34,-34,-34,0), and night even darker (-136,-136,-136,0). Ideally, they would shift slowly from one to the next, with the tones I posted at about the midpoint of each time block, but that isn't too important.

Each time block needs to set a switch in-game with morning using 0001, afternoon using 0002, etc. This is so events can be places in the morning, for example, but gone by the time evening comes, and things like that.

Here's the timeframes for each time block:
Morning: 6:00 AM - 12:00 PM
Afternoon: 12:00 PM - 6:00 PM
Evening: 6:00 PM - 12:00 AM
Night: 12:00 AM - 6:00 AM

I don't need dates or years stored from the computer's internal clocks, just the time.
If you could make each time block randomly check for weather from ccoa's weather script in the downloads manager, the type of which is determined by variable 0001, it would be utterly fantastic.

Whoever chooses to create this, I am in your debt. Unfortunately, I have little to offer, as I am first and foremost a writer. I am, however, mediocre at graphics, and if you need a large number of simple, tedious edits done, I would happily do them for you. Otherwise, I could write you some bad poetry :D .

Anyway, I thank whoever tries this in advance. If there's any other specific information I may have accidently left out, please don't hesitate to ask.

Edit: One final thing: the screen tinting should be able to be turned off if switch 0005 is set on. Thanks!
 
Okay, I edited Silentdragon's edit of Near's edit of Deke's day and night system, and it suits my needs perfectly.

Here's the edited edit of the edited script:
#=======================================#
# Day-Night System
# Written by Deke
# Rewiten by Near Fantastica
# Changed by Silentdragon
# Tweaked by EmuMaster2002
# To make a map get dark at night, put an asterisk in its name (*)
# Uses Switches 0001-0004 to denote time-blocks based on multiples of six.
# 6:00AM-12:00PM is Morning, 12:00PM-6:00PM is Evening, etc.
#=======================================#
class Game_Time

attr_accessor :minute_length
attr_accessor :hours
attr_accessor :minutess
attr_accessor :timess

def initialize
@minute_length=2.0
@hour_length= 60.0
@day_length=24.0
@month_length=30.0
@year_length=12.0
@minutes=0
@timess=Time.now #Real-Time Tweak
@hours=timess.strftime("%H").to_i #Real Hours
@minutess=timess.strftime("%M").to_i #Real Min
end

def get_time
@timess=Time.now #Real-Time Tweak
@hours=timess.strftime("%H").to_i #Real Hours
@minutess=timess.strftime("%M").to_i #Real Min
end
def get_tone
get_time
hour=hours
minutes=minutess + hour*@hour_length
phase_shift=Math::PI*(minutes/(@hour_length*@day_length))
illumination= -150+ 165*Math.sin(phase_shift)
tone=Tone.new(illumination,illumination,illumination,0)
return tone
end

end # of class Game_Time

#=======================================#
# â–¦nbsp; class Window_Time #
# written by Deke #
#------------------------------------------------------------------------------#
#=======================================#
class Window_Time < Window_Base

#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype # "Time" window font
self.contents.font.size = $defaultfontsize
refresh
end

#--------------------------------------------------------------------------
def refresh
$game_time.get_time
self.contents.clear
@total_sec = Graphics.frame_count / Graphics.frame_rate
@minute=$game_time.minutess
hour = $game_time.hours
pm_flag= hour >=12 ? true : false
hour= hour >= 12 ? hour-12 : hour
if hour.floor==0
text=sprintf("%02d:%02d",12,@minute)
else
text=sprintf("%02d:%02d",hour,@minute)
end
if pm_flag
text += " PM"
else
text += " AM"
end
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120, 32, text, 2)
end

#--------------------------------------------------------------------------
def update
$game_time.get_time
if $game_time.minutess != @minute
refresh
end
end
end # of class

#=======================================
class Game_Temp
#--------------------------------------------------------------------------
# ââ€â€
 

sledz

Member

I HAVE A PROBLEM

WHEN I ADD THIS SCRIPT TO MY PROJECT, WHEN I TEST IT,
THIS ERROR SHOWS ME:
"Script 'Day-Night System' line 41: SyntaxError occured."
Maybr it doesent work with some scipts I have yet.
This is list of those scripts:
Item System Diablo Style By DarkSchneider
AMS - Advanced Message Script - R4 [Update #2] by Dubealex
Anti Event Lag Script by Near Fantastica
Advanced Weather System By Ccoa
Sprite_Shadow (Sprite_Ombre ) <-Dynamic Shadows
MeisMe's Realistic Shop
Game_Actor mod's... -Midge- (its a double swords etc. but not by Guilname 777)
Side View Battle System
Battle System background as map (This class contains the set of sprites used in
the Scene_Battle class, such as the enemies, actors, battle background, and any pictures being displayed)
HUD <= it is a window in down left courner, which contains name of hero, hp, sp and exp bars...

And in this line 41 we have:
41 tone=Tone.new(illumination,illumination,illuminati on,0)
42 return tone
43 end
 
Hey I think this script is pretty cool! I might use it for my game. However, I need it tweeked just a bit.

Is it possible to have the time keep track of the date instead of the time of day? So if christmas rolls around santa might appear and give the hero a present.

This would really help my game a lot and I am thankful to anyone that might attemp at helping me.
 

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