Trickster's Time System V2.2

Trickster's Time System
Version: 2.0


Introduction

And who said I only create scripts for battle systems, yeah that's right This is a map system. This allows your game to have time. Also includes a simple Day Night System. And Also you can setup events that happen at a certain time (ex. at 0 to 6 minutes past each hour, or on Tuesday March 20, 2007 at 3:00 PM to 4:00 the same day and year), This script wasn't meant to be an exact copy of our calendar (you can only set up a month to be 30 days and not vary by month), but well enjoy.

Features
  • Simple
  • Can Set Time to a certain hour, minute, month, day, year
  • Can Speed up or slow down time
  • Can Disable Tinting
  • Tinting is disabled on inside maps
  • Can Setup Initial time
  • Can redefine the time system
  • A whole lot of other stuff I am probably to sleepy to recall
  • Can Stop Time for certain maps or whenever
  • Can Speed up time on certain maps or whenever
  • Can Pause Time flow when events are running
Screenshots

Look at one of the default maps, make it 11PM think of that as night, there you have your screenshot

Demo

http://www.hbgames.org/forums/downloads.php?do=file&id=719

Script

I shall leave the families trapped in a moment of time since they get no time script posted here and no script means they are stuck Haha

Instructions

Add the Script Above Main There is a setup section which I'll explain again below

Setup Show
  1.  
  2.  #--------------------------------------------------------------------------
  3.   # * Minute Length
  4.   #--------------------------------------------------------------------------
  5.   Minute = 2
  6.   #--------------------------------------------------------------------------
  7.   # * Hour Length
  8.   #--------------------------------------------------------------------------
  9.   Hour = 60
  10.   #--------------------------------------------------------------------------
  11.   # * Day Length
  12.   #--------------------------------------------------------------------------
  13.   Day = 24
  14.   #--------------------------------------------------------------------------
  15.   # * Month Length
  16.   #--------------------------------------------------------------------------
  17.   Month = 30
  18.   #--------------------------------------------------------------------------
  19.   # * Year Length
  20.   #--------------------------------------------------------------------------
  21.   Year = 12
  22.  
Expand to see the code.

These control the lengths of time
2 seconds in a minute
60 minutes in a hour
24 hours in a day
30 days in a month
12 months in a year

The only one you can modify in game is how many seconds in a minute which you can change by using this call script

  1. $game_time.minute_length = <length>
Expand to see the code.
where length is the number of seconds in a minute

  1.  
  2.  #--------------------------------------------------------------------------
  3.   # * Starting Time
  4.   #   - Year, Month, Day, Hour, Minute
  5.   #--------------------------------------------------------------------------
  6.   Time = 1207, 4, 13, 23, 0
  7.  
Expand to see the code.


This is just the starting time and this reads 11:00 PM May 4, 1207

  1.  
  2.   #--------------------------------------------------------------------------
  3.   # * Days of the Week
  4.   #--------------------------------------------------------------------------
  5.   Days = %W( Sunday Monday Tuesday Wednesday Thursday Friday Saturday )
  6.   #--------------------------------------------------------------------------
  7.   # * Months of the Year
  8.   #--------------------------------------------------------------------------
  9.   Months = %W( Janurary Feburary March April May June July August September
  10.   October November December )
  11.  
Expand to see the code.


Days and Months of the year just type the names without '' or "" like I have done here if you need a space in the name replace the space in the name with \s

  1.  #--------------------------------------------------------------------------
  2.   # * Time Format
  3.   #   0 - HHMM 1 - HH:MM 2 - HH:MM AM / PM (Splits Day Rate in Half)
  4.   #--------------------------------------------------------------------------
  5.   Time_Format = 2
  6.  
Expand to see the code.


Time Format this is self-explanatory

  1.  
  2.   #--------------------------------------------------------------------------
  3.   # * Morning
  4.   #--------------------------------------------------------------------------
  5.   Morning = proc {|hour| hour >= 5 && hour < 12}
  6.   #--------------------------------------------------------------------------
  7.   # * Afternoon
  8.   #--------------------------------------------------------------------------
  9.   Afternoon = proc {|hour| hour >= 12 && hour < 18}
  10.   #--------------------------------------------------------------------------
  11.   # * Evening
  12.   #--------------------------------------------------------------------------
  13.   Evening = proc {|hour| hour >= 18 && hour < 22}
  14.   #--------------------------------------------------------------------------
  15.   # * Night
  16.   #--------------------------------------------------------------------------
  17.   Night = proc {|hour| hour >= 22 && hour < 5}
  18.  
Expand to see the code.


Ok These effect the Time of Day it is Morning is considered to be from 5am to 12 pm Afternoon is from 12 pm to 6 pm Evening is from 6pm to 10 pm and Night is from 10 pm to 5am. Not really important options but you you'll see what they are for if you read below

  1.  #--------------------------------------------------------------------------
  2.   # * Time Effect
  3.   #   0 - Wait (In Map Only) 1 - Wait2 (In Map in Battle) 2 - Active
  4.   #--------------------------------------------------------------------------
  5.   Time_Effect = 2
  6.  
Expand to see the code.


Time_Effect is how the time updates 0 in map only 1 for map and in battle 2 for all scenes (provided if Scene_Base is used to create the scene)

  1.  
  2.   #--------------------------------------------------------------------------
  3.   # * Tone Enabled (At Start of Game)
  4.   #--------------------------------------------------------------------------
  5.   Tone_Enabled = true
  6.   #--------------------------------------------------------------------------
  7.   # * Time Speed (At Start of Game)
  8.   #--------------------------------------------------------------------------
  9.   Speed = 1
  10.   #--------------------------------------------------------------------------
  11.   # * Time Stopped (At Start of Game)
  12.   #--------------------------------------------------------------------------
  13.   Stopped = false
  14.   #--------------------------------------------------------------------------
  15.   # * Time Stopped During Events
  16.   #--------------------------------------------------------------------------
  17.   Stopped_Events = true
  18.  
Expand to see the code.


These are options for at the start of the game these are self-explanatory

  1.  
  2.    #--------------------------------------------------------------------------
  3.   # * Time Stopped Maps
  4.   #   - syntax map_id => stopped flag true: stopped time false: otherwise
  5.   #--------------------------------------------------------------------------
  6.   Stopped_Maps = {}
  7.   #--------------------------------------------------------------------------
  8.   # * Time Stopped Maps Default
  9.   #--------------------------------------------------------------------------
  10.   Stopped_Maps.default = false
  11.   #--------------------------------------------------------------------------
  12.   # * Increase Speed up Time Maps
  13.   #   - syntax map_id => speed
  14.   #--------------------------------------------------------------------------
  15.   Speed_Maps = {}
  16.   #--------------------------------------------------------------------------
  17.   # * Increase Speed up Time Maps Default
  18.   #--------------------------------------------------------------------------
  19.   Speed_Maps.default = 0
  20.   #--------------------------------------------------------------------------
  21.   # * Tone Disabled Maps
  22.   #   - syntax map_id => disabled flag true: disabled false: enabled
  23.   #--------------------------------------------------------------------------
  24.   Tone_Disabled = {2 => true}
  25.   #--------------------------------------------------------------------------
  26.   # * Tone Disabled Maps Default
  27.   #--------------------------------------------------------------------------
  28.   Tone_Disabled.default = false
  29.  
Expand to see the code.


These are options for maps the [I] in version 1.0 was deprecated for the Tone_Disabled Hash setup. These are also self-explanatory because of the comments telling how to set it up


Setuping up an Event to Happen Depending on Time Show
On the page you want the event to have an extra time condition

Using an Event Comment Write a Comment that says Time_Setup

This activates the script

To Set the minutes the event is supposed to happen two comments that says

  1. start_minute <minute>
  2. end_minute <minute>
Expand to see the code.
where is the minute as a number for example

  1. start_minute 0
  2. end_minute 6
Expand to see the code.
The event will run from x:00 to x:06 every hour every day every year

If you leave one of these off then it will not be used for example

  1. end_minute 6
Expand to see the code.
will do the exact same thing as the above
Except it means from any time where the minute is less than x:06

repeat for hours, days, months, and years their conditions are

  1. start_hour, end_hour, start_day, end_day, start_month, end_month, start_year, end_year
Expand to see the code.
There are two more conditions are that

  1. on_day, on_month
Expand to see the code.
The First, on_day, makes an event happen on a certain day and on_month makes an event happen on a certain month.

  1. morning, afternoon, evening, night
Expand to see the code.

These are new as of V2.0 these check if the time is morning, afternoon, evening or night respectively (or not if you set them to false)
That is all


Random Stuff Show
To Disabled the Tinting just call this
  1. $game_time.tone_enabled = false
Expand to see the code.
and to enable tinting just call
  1. $game_time.tone_enabled = true
Expand to see the code.
To change the time just call
  1. $game_time.(value) = time
Expand to see the code.
replace (value) with minute hour day month or year
and replace time with the new time

To advance the time just call
  1. $game_time.(value) += time
Expand to see the code.
replace (value) with minutes hours days months or years
and replace time with the amount of time to move forward

To stop time just call
$game_time.stopped = true
and no unstop time just call
$game_time.stopped = false

To Speed up time (How many seconds passes) just call
$game_time.speed =
where speed is the speed of increasing

To check if its morning afternoon evening or night just call
  1.  
  2.   $game_time.is_morning?
  3.   $game_time.is_afternoon?
  4.   $game_time.is_evening?
  5.   $game_time.is_night?
  6.  
Expand to see the code.
the respective method call to check it


FAQ

Awaiting FAQ

Compatibility

SDK 2.2 Compliant (Get it from this demo)
Requires Map Info Script

Credits and Thanks

This script is based on Deke's Time System

Author's Notes

Also this was coded in less than a few hours :)

This script's setup is not compatible with version 1.0 of this script
Sleepy trickster?
I love your screenshot more and more XD
I'll give it a try tough i already use a KTS identical to yours... (but withouth years ya)
Awesome, this was truly a surprise to see when I logged on today :3. I will put it to good use
That was really funny the way you introduce your script, Trickster :P. But it's neat ^_^.
I'm going to download the demo.
And Edited First Post with better directions :)

There is a bug with the day calculation will fix it later
Pretty awesome script. ^_^
I'll check it out >:P
better if you spoiler the instructions... too long like this
Script has been updated to Version 1.1

Fixes the Day Calculation (Each First day in the month was Monday...)
very nice indeed.
Can this be better than Near's!?
Yay for Trickster!
Yay for Day and Night!
Yay for Cake!
this is cool, does it go from day to night instantly? or can you make it so that it gets slightly darker over time?
Good work buddy. :)
Is it possible to stop time on certain maps and then have time keep going again on others?
[QUOTE=uzumakishade;178973]this is cool, does it go from day to night instantly? or can you make it so that it gets slightly darker over time?[/QUOTE]
Its a smooth effect that updates each frame, you can edit it though by looking at method tone of class Game_Time

[QUOTE=Denko;179040]Is it possible to stop time on certain maps and then have time keep going again on others?[/QUOTE]

Hmm, well you could set the minute length to a very high value for now

I will add this into a future update
[QUOTE=Trickster;178415](you can only set up a month to be 30 days and not vary by month)[/QUOTE]

Might you do that in a future version? Could be implemented through hashes, i.e.
'month' => 'days'
Expand to see the code.


Just a suggestion. And great work. Glad to know you're on the verge of releasing that RTAB replacement too.
Nice sweet and simple. Nice to see you are not limited to battle system addons :D
Thanks for you saying you're going to add that Seph! I do believe it is essential to a day/night script.
And I think yours is pretty good.
[QUOTE=MasterMind5823;179058]Might you do that in a future version? Could be implemented through hashes, i.e.
'month' => 'days'
Expand to see the code.


Just a suggestion. And great work. Glad to know you're on the verge of releasing that RTAB replacement too.[/QUOTE]

Well the thing with that is that I have to change some calculations and it is a bit harder to do it that way, but well I'll think of something and if I implement leap years then this script will be a pretty accurate (if not 100% accurate) time script

[QUOTE=Neonyo;179064]Nice sweet and simple. Nice to see you are not limited to battle system addons :D[/QUOTE]

I have more non-battle scripts to name a few

Event-Tile Indicator (Unreleased)
View-Range (Unreleased)
Animation Display
Damage Display

and get it right CBSes CBS addons and minigames :p

[QUOTE=Denko;179067]Thanks for you saying you're going to add that Seph! I do believe it is essential to a day/night script.
And I think yours is pretty good.[/QUOTE]

Yes check back in a couple of days if not today I will have updated the script by then with the stop time feature
But how i can know how much clock is?
Create a window that displays it

I did create a method for returning then time just do $game_time.time

Also I was too sleepy at the time to create one for this myself, so there

EDIT: I will be doing one for the update though

Also Please only post if you have actual comments/bug reports/support on the script that's why you would be making a post here
I can do any Ruby, cause i am noob.. So can someone do this?
You should spoiler the instructions...
Updated to Version 2.0 (note the setup for 1.0 and 1.0 syntax isn't compatible with this version)
I have one quick question. If I remove the beginning and ending little SDK tag things, will it be compatible with normal RMXP scripting?
[QUOTE=Leknaat;183476]I have one quick question. If I remove the beginning and ending little SDK tag things, will it be compatible with normal RMXP scripting?[/QUOTE]

I don't think so. You'll need to do more than that.
Updated the script to Version 2.1

Splits the script up into two parts
the time system and the day/night system (optional)

Also adds a Time in Menu Addon
Is it possible to just have one screentone for day, one for night, one for evening and one for morning, and specify what screentones you want?
I dislike the screentones that are now, and i just want 4. ;)
uhm... you forgot to implement leap seconds, and don't forget that leap years don't happen if year is devidable to 400
This gives me an urge to make some sort of Animal Crossing game. Go Trixi!
[QUOTE=Tempus;223931]Is it possible to just have one screentone for day, one for night, one for evening and one for morning, and specify what screentones you want?
I dislike the screentones that are now, and i just want 4. ;)[/QUOTE]
  def tone
    period_length = Math::PI * (hours.to_f / Day)
    red_shift = -100 + 115 * Math.sin(period_length)
    green_shift = -140 + 155 * Math.sin(period_length)
    blue_shift = -150 + 165 * Math.sin(period_length)
    return Tone.new(red_shift, green_shift, blue_shift, 0)
  end
Expand to see the code.


modify this method it would be best to modify it like so

def tone
  case hours
  when 0...somenumber
    r, g, b, gy = RED, GREEN, BLUE, GRAY
  when somenumber...anothernumber
    r, g, b, gy = RED, GREEN, BLUE, GRAY
  end
  return Tone.new(r, g, b, gy)
end
Expand to see the code.


[QUOTE=alexanderpas;224323]uhm... you forgot to implement leap seconds, and don't forget that leap years don't happen if year is devidable to 400[/QUOTE]

Introduction:
-------------
This script allows your game to have time. Also includes a simple Day Night
System. And Also you can setup events that happen at a certain time
(ex. at 0 to 6 minutes past each hour, or on Tuesday March 20, 2007 at
3:00 PM to 4:00 the same day and year), [B]This script wasn't meant to be an exact
copy of our calendar as it is not accurate[/B]
Expand to see the code.


[QUOTE=Draken;224379]This gives me an urge to make some sort of Animal Crossing game. Go Trixi![/QUOTE]

thanks

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=17788