Chaos Project

RPG Maker => RPG Maker Scripts => Topic started by: fugibo on March 09, 2008, 11:08:36 pm

Title: [XP] Advanced Time and Environment System
Post by: fugibo on March 09, 2008, 11:08:36 pm
This script has been finished and rereleased! Please click here (http://forum.chaos-project.com/index.php/topic,12869.0) for the new version!


Advanced Time and Environment System (ATES)
Authors: Blizzard
Version: 0.4
Type: Autonomous Timeflow and Environment Controller
Key Term: Environment Add-on



Introduction

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.

This work is protected by the following license:
Quote
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.



Features




Screenshots

N/A for this sort of script


Demo

N/A


Script

Just make a new script above main and paste this code into it.
Script Download (http://downloads.chaos-project.com/scripts/Advanced Time and Environment System.txt)


Instructions

Inside the script in the first comment.


Compatibility

99% compatible with SDK v1.x. 90% compatible with SDK 2.x. WILL corrupt old savegames. Can cause incompatibilty issues with DNS-es.


Credits and Thanks




Author's Notes

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

That's it! Enjoy! =D

EDIT:

Nice, Blizz  ;D
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on March 11, 2008, 05:39:20 am
Merge successful. :3
Title: Re: [XP] Advanced Time and Environment System
Post by: Nortos on March 11, 2008, 05:57:53 am
ohhhhh is this your new time system? I been waiting for this for ages I have to go in a sec though so cnt comment about it but looking now :)
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on March 11, 2008, 06:04:34 am
It's a completely new code. But so far it only tints the screen. The full system will support stuff like calender, seasons bad weather probability, temperature... =X
Title: Re: [XP] Advanced Time and Environment System
Post by: Nortos on March 11, 2008, 06:10:01 am
wow i just looked through it and it looks good the code so small more than half of it alone is instructions :P gj on this when get time I'll get round to swapping to this instead DDNS
Title: Re: [XP] Advanced Time and Environment System
Post by: Flermza on March 11, 2008, 07:38:37 am
New time system, awesome work!
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on March 11, 2008, 07:49:30 am
:P And I was gonna start working on my own full-blown Environmental Effects scripts, with water reflections, time, tints, weather, and everything, but you already beat me to it...
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on March 11, 2008, 09:54:30 am
I can give you the code I have so far. I took out the planned options for this release. You can finish it instead. I barely have time to do it myself.
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on March 11, 2008, 10:05:27 am
0_o

Okay, then, I'll do that. Thank you, Blizz!
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on March 11, 2008, 10:15:35 am
I just sent you a download via PM. Alright, I'll make something happen that this turns into YOUR topic... ;)

EDIT: I MADE IT HAPPEN!!!111oneonetwothreeeight
Title: Re: [XP] Advanced Time and Environment System
Post by: Nortos on March 11, 2008, 04:37:18 pm
lol anyway looking forward to it WcW
Title: Re: [XP] Advanced Time and Environment System
Post by: Gilmerrambo on July 18, 2008, 01:04:56 pm
I cannot figure out how to make the time of day stay the same from one room to another. The clock still works but the tinting stops. Will someone help? :plz:
Title: Re: [XP] Advanced Time and Environment System
Post by: Starrodkirby86 on July 18, 2008, 01:11:38 pm
Did you enable tinting? I'll quote from the Instructions within the script:
Call Script: ShowHide
# - 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.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.
Turn it on through a Call script command and insert ATES.tint_on

Make sure the time system is already on, but I'm sure it is considering time is moving. xD
Title: Re: [XP] Advanced Time and Environment System
Post by: TheHackMan on August 15, 2008, 04:52:59 pm
I just tried out the script and whenever I have it turn on with
Call Script: ATES.on
I end up with ArgumentError on line 353
"wrong number of arguments(5 for 2)"

It would seem line 353 is:
      ATES.advance(1, 0, 0, 0, 0) if @frame_count % (ATES::LENGTH / 36) == 0

When I change it to:
      ATES.advance(1, 0) if @frame_count % (ATES::LENGTH / 36) == 0
Then it works without any problems


Now I have run into a second problem, whenever I set the clock display to false(so it wont show) I get an error that says:
NoMethodError on line 445
undefined method ` draw' for nil:NilClass

Line 445 is:
   @clock.draw if $game_system.ates.frame_count % 40 == 0
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on August 15, 2008, 07:30:39 pm
I put up a fixed version.
Title: Re: [XP] Advanced Time and Environment System
Post by: TheHackMan on August 15, 2008, 09:09:08 pm
Awesome, clock is now not displaying as it should when its set to false with no errors :D
Title: Re: [XP] Advanced Time and Environment System
Post by: happyman on September 03, 2008, 04:33:18 pm
Hello.  I know nothing of RGSS, but I like this script a lot.
I have a question though.  How do I make it so things happen at certain times of the day.
All I really need is some sort of "Condition Branch" for my eventing.

I ask because I'm making a Harvest Moon kind of game, and it would be cool if I could have townsfolk be in one place at 4:00 and a different place at 6:00.

Thanks, and this script is pretty cool :)
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on September 03, 2008, 04:36:47 pm
Look in the script. Day and Night trigger switches which you can use to determine the daytime. You can obtain the hour by using "$game_system.ates.time.hour" (without the double quotes).
Your best idea would be to assign the value to a variables (using "$game_variables[ID_NUMBER] = $game_system.ates.time.hour") and adding that to the event's precondition.
Title: Re: [XP] Advanced Time and Environment System
Post by: happyman on September 03, 2008, 04:50:40 pm
Quote from: Blizzard on September 03, 2008, 04:36:47 pm
Look in the script. Day and Night trigger switches which you can use to determine the daytime. You can obtain the hour by using "$game_system.ates.time.hour" (without the double quotes).
Your best idea would be to assign the value to a variables (using "$game_variables[ID_NUMBER] = $game_system.ates.time.hour") and adding that to the event's precondition.


Thanks!  That sounds like a good idea, and it actually makes sense to me.
This helps a lot :)
Title: Re: [XP] Advanced Time and Environment System
Post by: Mightylink on October 12, 2008, 09:52:23 am
Sounds good, I been struggling with DDNS so I'm looking for something new to try, this one should be sweet.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on October 13, 2008, 04:49:58 am
Yeah. Just too bad WcW left and didn't have time to improve my basic version. =/
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on October 17, 2008, 07:57:35 am
...I'm probably gonna replace this with a system called "Hyperion" soon.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on October 17, 2008, 08:56:23 am
Hyperion is the name of the second spaceship of the main villain in CP. :P
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on October 17, 2008, 11:12:02 am
Hyperion is also a Greek god, father of the Sun and Moon. The "sun" and "moon" effects are created by this script. Seemed an apt name to me.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on October 17, 2008, 11:47:50 am
Hm, interesting. I knew that Hyperion was a god or something, but I didn't know he was the god of "sun and moon". Good idea for the system.
Title: Re: [XP] Advanced Time and Environment System
Post by: ali madan on October 18, 2008, 03:22:19 am
sorry but I can't figure out where's the downlaod link
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on October 18, 2008, 07:34:24 am
Good you noticed. This post seems to have been damaged during the move. =/ I restored it.
Title: Re: [XP] Advanced Time and Environment System
Post by: Vein Pyroclasm on October 27, 2008, 03:23:19 pm
Quote from: Blizzard on September 03, 2008, 04:36:47 pm
Look in the script. Day and Night trigger switches which you can use to determine the daytime. You can obtain the hour by using "$game_system.ates.time.hour" (without the double quotes).
Your best idea would be to assign the value to a variables (using "$game_variables[ID_NUMBER] = $game_system.ates.time.hour") and adding that to the event's precondition.


I really don't understand this statement lol...I want to make it so that i.e. a certain person may be in a certain place in a certain time frame.  Or they may say different things at different times in the day.  Can you tell me how to do that?
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on October 27, 2008, 03:54:03 pm
(http://img135.imageshack.us/img135/3055/snap281db4.png) (http://img259.imageshack.us/img259/1010/snap282rz4.png) (http://img368.imageshack.us/img368/7196/snap283es3.png)

This will make the girl be there only between 8:00 and 20:00. I'm sure that you know how to use the conditional branch event command. Just do it the same way there.
Title: Re: [XP] Advanced Time and Environment System
Post by: Vein Pyroclasm on October 27, 2008, 04:18:10 pm
Quote from: Blizzard on October 27, 2008, 03:54:03 pm
(http://img135.imageshack.us/img135/3055/snap281db4.png) (http://img259.imageshack.us/img259/1010/snap282rz4.png) (http://img368.imageshack.us/img368/7196/snap283es3.png)

This will make the girl be there only between 8:00 and 20:00. I'm sure that you know how to use the conditional branch event command. Just do it the same way there.


Ok i followed your directions but I get a Syntax error now when i press new game

EDIT

Ok let me tell you what i did....My game hour variable is set on number 0500 so i set my parallel process to run the script as...

$game_variables[0500] =
$game_system.ates.time.hour

Then i set a bat on the map to only show up when variable 0500 = 12, but then the second page it makes him invisible when the var = 20

So i created an event that advances time 12hrs when i step on it (this was to test the system) but when my time is advanced to 12:00 the bat still doesn't show up
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on October 27, 2008, 04:30:35 pm
No, NOT with leading zeroes. Leading zeroes convert your number into the octal system making it 320 in the decimal system. -_-
Title: Re: [XP] Advanced Time and Environment System
Post by: Vein Pyroclasm on October 27, 2008, 04:52:06 pm
Yea, see i set the bat to show up at like, let's say 1 and vanish at 6....even if I switch those two numbers of when he shows/vanishes, he repeatedly keeps showing up at 8.  Why is that?
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on October 27, 2008, 05:30:22 pm
I'm not sure as I haven't tested it myself.
Keep in mind that if the condition of a higher page is valid, then the higher page will be displayed as it has priority. Maybe it's that?
Title: Re: [XP] Advanced Time and Environment System
Post by: Vein Pyroclasm on October 27, 2008, 09:19:54 pm
Quote from: Blizzard on October 27, 2008, 05:30:22 pm
I'm not sure as I haven't tested it myself.
Keep in mind that if the condition of a higher page is valid, then the higher page will be displayed as it has priority. Maybe it's that?


Hmm, well i don't think that is it, but I made you some screens so you can see what's going on

Spoiler: ShowHide


Spoiler: ShowHide


Spoiler: ShowHide


Spoiler: ShowHide


Spoiler: ShowHide


Spoiler: ShowHide
Title: Re: [XP] Advanced Time and Environment System
Post by: Aqua on October 27, 2008, 09:30:47 pm
Just to let you know, the way you named your event, the monster id 1 will ALWAYS be on the map when the event is present, it just might not be visible.

To fix it, you should get rid of \e[1] from the name, then on page 1 with the bat graphic, set it to parallel process and have:

$game_map.rename_event(EVENT_ID, '\\e[1]')


Note that the 2 backslashes are important.
Title: Re: [XP] Advanced Time and Environment System
Post by: Vein Pyroclasm on October 27, 2008, 11:10:20 pm
Quote from: Aqua on October 27, 2008, 09:30:47 pm
Just to let you know, the way you named your event, the monster id 1 will ALWAYS be on the map when the event is present, it just might not be visible.

To fix it, you should get rid of \e[1] from the name, then on page 1 with the bat graphic, set it to parallel process and have:

$game_map.rename_event(EVENT_ID, '\\e[1]')


Note that the 2 backslashes are important.


Ok thanks for the heads up, but will this fix my time problem?

and do I need to replace EVENT_ID with something?

I really think this may some sort of bug in the script.  I don't see why in the hell it won't do what i'm trying to get it to do  :???: lol.  I mean sometimes if i set the variable on the first page to 6, the sprite set to show up doesn't show up until 8, almost like 2 hours late.  I had thought that to be some kind of bug and tested it seeing if it would vanish at 20 if set at 18 and it did, then when i tested with new numbers it wouldn't work....actually it either didn't appear at all, or wouldn't vanish.  It's really aggravating.  And i can't set an event on parallel process all the time especially if i need that event to be triggered by the players button....like talking to a character. 

Also Blizz i tried the variable numbers you showed me in your screenshots.  Well Shot one shows the sprite appearing at Var. 8 and vanishing at 20, well when i tested that, the sprite didn't appear till 20 and then vanished at 8.  Could i be doing something wrong? or is there a bug in this script?

I also tired eraseing the second page and putting the sprite to show up at 1 and guess what? It showed up at 20!!! I mean like wtf?!? it didn't even have anything to do with the number 20 lol.  So no matter what number i set the page to make the sprite vanish, it always vanishes at 20.  So i've gone into the script and found that night begins at 20, so i changed that to 22 to test if that had something to do with it and my sprites began vanishing at the number 22 instead of 20.

And Blizz if you read this, I put some screenshots on the post before this one

I'm sorry for the constant edits and long post, but IF it's a bug then I wanted to make sure I get across all the facts I found towards it.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on October 28, 2008, 07:02:24 am
Weel, first off, your third screenshot's event uses variable number 1 instead of 500 and secondly, the "Through" option is not activated.
Title: Re: [XP] Advanced Time and Environment System
Post by: Vein Pyroclasm on October 28, 2008, 09:47:54 am
Yea i know, i realized that.  You see I had made 2 variables for game hour by accident, but even so i corrected that and had the same issues.  I even used the through option.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on October 28, 2008, 10:09:43 am
Alright, I can't see any mistakes on your side anymore so there might be a problem. I'll look into it as soon as I can.
Title: Re: [XP] Advanced Time and Environment System
Post by: Vein Pyroclasm on October 28, 2008, 02:27:07 pm
Quote from: Blizzard on October 28, 2008, 10:09:43 am
Alright, I can't see any mistakes on your side anymore so there might be a problem. I'll look into it as soon as I can.


There's no hurry lol.  I just wanted to give my game a cool system where i can havfe certain times made for certain events, but it's really not a big deal, I can just make them start 20 = Night and 12/8 = Day and have the events set to work at day OR night.  But i just thought you guys should know about the problem
Title: Re: [XP] Advanced Time and Environment System
Post by: Vein Pyroclasm on October 29, 2008, 06:52:19 pm
Ok, so is there a call script i can use to hide the clock in the upper right corner?
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on October 29, 2008, 07:39:17 pm
$game_system.show_clock =
false
Title: Re: [XP] Advanced Time and Environment System
Post by: Vein Pyroclasm on October 29, 2008, 08:28:33 pm
Quote from: Blizzard on October 29, 2008, 07:39:17 pm
$game_system.show_clock =
false



Thanks Blizz
Title: Re: [XP] Advanced Time and Environment System
Post by: Shadonking on December 30, 2008, 09:28:17 am
i have a little prob, when i enter a new map and disable the tint at night it works fine but when i leave that map and turn the tint back on there is a small delay from when you enter that map to the tint taken place. is there a way to make it look more fluid when you enter a new map.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on December 30, 2008, 09:56:46 am
It's probably a bug.
Title: Re: [XP] Advanced Time and Environment System
Post by: Shadonking on December 30, 2008, 02:20:21 pm
can it be fixed
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on December 31, 2008, 06:36:29 am
Of course. Every bug can be fixed. :P I just have to find some time to do so.
Title: Re: [XP] Advanced Time and Environment System
Post by: Shadonking on December 31, 2008, 09:25:58 am
ok, thanks blizz
Title: Re: [XP] Advanced Time and Environment System
Post by: Exiled_by_choise on January 08, 2009, 08:53:14 pm
Hi i added this script into my game but it wont work. At the start of the game it turns on and the clock shows up but the clock doesn't have the time and there is no change in the environment and no day and night.

Can you help??
Title: Re: [XP] Advanced Time and Environment System
Post by: Aqua on January 08, 2009, 08:56:01 pm
Read the instructions...
It is off by default; gotta turn it on.
Title: Re: [XP] Advanced Time and Environment System
Post by: Shadonking on January 09, 2009, 06:19:03 am
has that bug i get been fixed yet
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on January 09, 2009, 06:19:55 am
No. I didn't have time to look into it yet.
Title: Re: [XP] Advanced Time and Environment System
Post by: Shadonking on January 10, 2009, 04:29:54 pm
thats fine, i was just wondering.
Title: Re: [XP] Advanced Time and Environment System
Post by: Jackolas on January 11, 2009, 08:44:58 am
just wondering..what bug?

the turn tint on when you change lvl?
fixed it.

use this in the event you wane use for changing lvl

Spoiler: ShowHide


i think u can change this yourself to the stuff that works for you :P
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on January 11, 2009, 09:26:21 am
Quote from: Shadonking on December 30, 2008, 09:28:17 am
i have a little prob, when i enter a new map and disable the tint at night it works fine but when i leave that map and turn the tint back on there is a small delay from when you enter that map to the tint taken place. is there a way to make it look more fluid when you enter a new map.
Title: Re: [XP] Advanced Time and Environment System
Post by: Jackolas on January 11, 2009, 09:40:17 am
in that case use:
Spoiler: ShowHide
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on January 11, 2009, 11:23:11 am
Then it's not a bug. :D BTW, is the waiting command necessary?
Title: Re: [XP] Advanced Time and Environment System
Post by: Jackolas on January 11, 2009, 01:04:32 pm
Strange enough yes.

the tint will get applied to the next frame... so you need to wait 1 frame before its get applied... strange thing
but you won't see it that he is waiting 1 frame.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on January 11, 2009, 01:38:16 pm
I think I know why this bug is happening. I'll fix it anyway.

EDIT: Fixed.
Title: Re: [XP] Advanced Time and Environment System
Post by: Shadonking on April 11, 2009, 02:30:22 pm
i get this error

Spoiler: ShowHide


bump
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on April 13, 2009, 03:44:44 pm
New game or saved game? What did you do to cause it? Are your scripts in the right order? (Lol, who am I asking?! xD) Do you have the clock turned on or off?
Title: Re: [XP] Advanced Time and Environment System
Post by: Shadonking on April 13, 2009, 04:32:59 pm
the clock is turned off when i get the error (i havent tried is with in on yet)

its a new game and i have no save files any way

and yep my scripts are in the right order ( i check all the time)
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on April 13, 2009, 04:56:22 pm
The order question was rhethorical. xD I'll look into it in a couple of minutes. Expect v0.32 in a few minutes then.

EDIT: Done.

@WcW: Are you gonna continue working on this?
Title: Re: [XP] Advanced Time and Environment System
Post by: Shadonking on April 13, 2009, 05:21:34 pm
new error, 
Spoiler: ShowHide


Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on April 13, 2009, 05:28:18 pm
I think that you didn't copy the script properly or that you got a cached version. Press F5 in the window where you usually copy the script to paste it into your window editor. It clearly takes 2 arguments in the version I uploaded. Only my dev version has a 5 argument constructor.
Title: Re: [XP] Advanced Time and Environment System
Post by: Shadonking on April 13, 2009, 05:42:11 pm
nope i copied it correctly, and i pressed F5 but all it does is it goes to the next script.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on April 13, 2009, 05:46:53 pm
Can you post the ATES you are using? Something's wrong here.
Title: Re: [XP] Advanced Time and Environment System
Post by: nathmatt on April 14, 2009, 02:18:27 pm
Quote from: TheHackMan on August 15, 2008, 04:52:59 pm
I just tried out the script and whenever I have it turn on with
Call Script: ATES.on
I end up with ArgumentError on line 353
"wrong number of arguments(5 for 2)"

It would seem line 353 is:
      ATES.advance(1, 0, 0, 0, 0) if @frame_count % (ATES::LENGTH / 36) == 0

When I change it to:
      ATES.advance(1, 0) if @frame_count % (ATES::LENGTH / 36) == 0
Then it works without any problems
Title: Re: [XP] Advanced Time and Environment System
Post by: Shadonking on April 14, 2009, 02:25:03 pm
im using the one in the download link

here

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Advanced Time and Environment System (ATES) by Blizzard
# Version: 0.32
# Type: Autonomous Timeflow and Environment Controller
# Date v0.3: 11.3.2008
# Date v0.31: 8.4.2008
# Date v0.32: 13.4.2008
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  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.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 = 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 = true
  # display HUD clock
  SHOW_CLOCK = false
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
  $ates = 0.32
 
  #============================================================================
  # 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.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-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, 0, 0, 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
    @clock.draw if @clock != nil && $game_system.ates.frame_count % 40 == 0
  end
 
  alias transfer_player_ates_later transfer_player
  def transfer_player
    $game_system.ates.update
    transfer_player_ates_later
  end
 
end

Title: Re: [XP] Advanced Time and Environment System
Post by: nathmatt on April 14, 2009, 02:38:20 pm
do what i said in my last post will fix it
Title: Re: [XP] Advanced Time and Environment System
Post by: Shadonking on April 14, 2009, 04:30:03 pm
okay i'll try, i didnt see your email (which is wierd becuase i should have)

edit

it works thanks, also where do i change it so it counts in 1 sec at a time becuase it does 2 (i know it can be done its just its late and my brain is turned off)
Title: Re: [XP] Advanced Time and Environment System
Post by: Mightylink on May 04, 2009, 06:24:48 am
Quote from: Shadonking on April 13, 2009, 05:21:34 pm
new error, 
Spoiler: ShowHide



Well you locked the other thread and told me to come here, but I tried this new script and its giving me errors :S

Same one as above, I copied it properly, ordered it the way you said in your script order thread, started a new game and made an event to call script: ATES.on

Error points to this block of code:

      @frame_count += 1
      ATES.advance(1, 0, 0, 0, 0) if @frame_count % (ATES::LENGTH / 36) == 0
    end


Other then changing the day switch to 1 and night switch to 2, i didnt change anything else <_<

Please help, so far I prefered your DDNS, it actually worked :P
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 04, 2009, 07:23:50 am
1.

Quote# Compatibility:
#
#   99% compatible with SDK v1.x. 90% compatible with SDK 2.x. WILL corrupt old
#   savegames.
Can cause incompatibilty issues with DNS-es.


2. If you don't post the error message, I can't do shit.

3. If you give me a block of code, I can't do shit either because there could be half a million reasons in just 5 lines of code. The error ALWAYS points to 1 line. Not more, not less.
Title: Re: [XP] Advanced Time and Environment System
Post by: Mightylink on May 04, 2009, 07:45:47 am
The error was in the spoiler, and i did start a new game 0.0 Are you ok, I havent posted any problems in a wile and you act like I bug you all the time, im sorry...

I linked the other guys screenshot cause it was the same as mine:

Spoiler: ShowHide


And I used the newest version of it, I removed the old ddns, I dont know what other info I can provide you, im really sorry if I bothered you.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 04, 2009, 08:20:45 am
I'm sorry. My day practically just started and it's already been a rough one. -_- And a few minutes ago I found out that I have 2 weeks to make an application that will consume at least 20 working hours while I have a blitz-exam at friday, I have to finish my hands-on seminar till monday and next week are exams. Plus I have to finish the demo of "Shaman" for the publishers and I need to learn for the exams actually. And I bet I forgot something on this list. All of that would have been fine if I didn't have to make that f*cked up application for the course "Development of Information Systems". >:/ Man, I hate that professor.

The solution is basically what nathmatt said a few posts before. Or you can redownload the script, I put up v0.33.
Again, sorry for being rude. -_-
Title: Re: [XP] Advanced Time and Environment System
Post by: Mightylink on May 04, 2009, 08:52:28 am
Sorry to hear about your day, I tried the new script and it seems to work now but all your other scripts are going funny on me now...

The lagless hud from tons is showing up even when I set it to hide and stormtronics now crashes, ughh i'll try to solve this on my own, I guess I have to redownload every scripts newest version again <_<

I hope you have a better day and im sorry to bug you, some things are just more important then games :P
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 04, 2009, 09:32:26 am
Thanks. And yeah, updating the versions of my scripts would be a good idea. xD
Title: Re: [XP] Advanced Time and Environment System
Post by: Mightylink on May 04, 2009, 07:13:52 pm
Well everything works now cept for 1 thing, I cant get the clock to show and hide, I am using the command mentioned a few posts ago and it is also the same one I used in the older version:

$game_system.show_clock = true


$game_system.show_clock =
false


Am I sappose to use something else now, what is it?

Oh and I love the new tinting, best ddns system out there ^_^
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 05, 2009, 03:45:05 am
I forgot to make that work properly. I uploaded v0.34. You can do it either this way or with the new commands ATES.clock_on and ATES.clock_off.
Title: Re: [XP] Advanced Time and Environment System
Post by: Mightylink on May 05, 2009, 03:55:27 am
I like the new commands better :)

Oh no :(

Syntax Error:

  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
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 05, 2009, 04:33:21 am
Lol, I think you messed up. It should be "def draw" there.

EDIT: Or I did. #_# Fixed.
Title: Re: [XP] Advanced Time and Environment System
Post by: Mightylink on May 05, 2009, 04:49:59 am
Thanks for puttin in the extra work, its perfect now, I only got 1 question, is there a way to turn overlighting on and off through an event? I got my own season system and i dont want overlighting to happen during winter.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 05, 2009, 07:59:32 am
Actually ATES was supposed to be a system that can handle seasons so they would be season controlled. No, there is no way to turn it off now.
Title: Re: [XP] Advanced Time and Environment System
Post by: Mightylink on May 05, 2009, 05:51:06 pm
still working on it then :P sounds awesome
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 06, 2009, 09:23:53 am
Actually WcW was supposed to finish it. ._.;
Title: Re: [XP] Advanced Time and Environment System
Post by: Mightylink on May 06, 2009, 11:09:21 pm
Oh well, I got a pretty good evented system going, I just need a way to run a common event every day.
Title: Re: [XP] Advanced Time and Environment System
Post by: Valcos on May 11, 2009, 11:13:53 pm
Well... think someone should finish it :^_^':. Its a good system, just want those cool features :naughty:

Edit: Just realized... theres no weather in this. I thought that was updated already -_-"
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 14, 2009, 06:21:47 am
It says v0.3x. :P
Title: Re: [XP] Advanced Time and Environment System
Post by: Darok on May 15, 2009, 08:09:17 pm
Does it works with your StormTronics CMS - Hybrid Edition? Becouse with my ex-CMS does not. (Im talking about showing the date in menu)
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 16, 2009, 04:08:06 am
This system does not have a calender subsystem added yet.
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on May 16, 2009, 05:31:47 pm
...I really, really need to get something done for this.

But note that my version will be named Hyperion, not ATES (too close to something you'd find in FF).
Title: Re: [XP] Advanced Time and Environment System
Post by: Valcos on May 16, 2009, 11:41:43 pm
Hyperion ATES? And looking for to a update  :<_<:
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on May 17, 2009, 09:32:46 am
Hyperion = Greek father of the Sun and Moon, IIRC. Seems fitting for a system dedicated totally to Day/Night/Time effects.
Title: Re: [XP] Advanced Time and Environment System
Post by: Valcos on May 17, 2009, 10:46:53 am
So, im guessing you are going to put in any weather effects? :huh:
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 18, 2009, 04:59:00 am
Even though Chronos would suit better because it's supposed to be a complete time system with calender and stuff. :/
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on May 18, 2009, 01:30:38 pm
Quote from: Blizzard on May 18, 2009, 04:59:00 am
Even though Chronos would suit better because it's supposed to be a complete time system with calender and stuff. :/


I'm not entirely sure his role dealt that much with time.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 19, 2009, 04:41:32 am
Tempus/Tempos maybe? I still like ATES better because most people don't know Greek or Roman mythology. "Name a system after what's it doing." I always hated bullshit names like "Blitz". I mean WTF. WTF is an "Blitz"?! Sure, it sounds nice, but you have absolutely no idea what it does. Or "Advanced Files". What files? There are many files in RMXP. Maybe character graphics? What's advanced about them? Or what about "Map Auto-Setup"? WTF does one need that for? Is it supposed to substitute a parallel process at the beginning of the map (which is dumb)? Or is it supposed to do something else. (Ok this last example is more an example of dumb scripts than dumb names, but my point remains valid.)
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on May 19, 2009, 08:51:37 am
What WOULD Blitz do? How would lightning involve RMXP? 0_O
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 19, 2009, 03:00:59 pm
I have no idea. And I honestly don't wanna know.
Title: Re: [XP] Advanced Time and Environment System
Post by: legacyblade on May 19, 2009, 03:21:51 pm
I agree with the script name thing. Like Blitz? WTF...

Though I did think the same thing when I saw the script name "DREAM" (until I looked at what the abbreviation meant). I think if you're going to use a greek god for the title, you should use Cronos (or whatever the real spelling of that name is). Most people are familiar with that name, but the other name? I had never heard of him.
Title: Re: [XP] Advanced Time and Environment System
Post by: Valcos on May 20, 2009, 12:22:53 am
How bout we name it after its finished :roll:
Title: Re: [XP] Advanced Time and Environment System
Post by: King Munkey on May 20, 2009, 12:44:14 am
With a finished product you know what it can do and what it cannot do then that way you can name it accordingly.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on May 20, 2009, 10:16:16 am
Well, it has the specs so I chose a name according to it even though the "Environment" and the "Advanced" part isn't supported in 0.3x. ._.
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on June 01, 2009, 02:38:05 pm
Oh, yeah. I've got a lot of work done on this now, guys, btw. Calendar is implemented through months (as in, it has days, weeks, and named months with differing days), and clock is fully implemented (configurable number of seconds in a minute, minutes in an hour, and hours in a day, as well as configurable names). I'm working on optimizing and getting actually useful stuff (ie the effects) ready, then I'll release it.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on June 01, 2009, 02:46:52 pm
Nice work. What about generated temperatures, seasons and bad weather probability?
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on June 01, 2009, 02:57:32 pm
That will be added in when I implement the Weather module (right now I only have Clock and Calendar, both of which are working perfectly)

Right now, I'm planning on implementing Weather by having the user be able to set different periods -- for example, have Summer generally be hotter and Winter generally be colder by setting which day of which month each season starts and what kind of season it is, then blending season together (ie summer cools back down to the upper 70s nearing Fall), then having El Nina/El Nino like situations, etc. On top of all that I'll have randomly-generated weather. Of course, I'll also have to add stuff like beginning and ending temperatures for the day and ways to make that change based on location (ie deserts have much higher temperatures than everywhere else during the day, as well as much colder nights). This'll be a LOT of work.
Title: Re: [XP] Advanced Time and Environment System
Post by: Aqua on June 01, 2009, 05:03:01 pm
Quote from: WcW on June 01, 2009, 02:38:05 pm
Oh, yeah. I've got a lot of work done on this now, guys, btw. Calendar is implemented through months (as in, it has days, weeks, and named months with differing days), and clock is fully implemented (configurable number of seconds in a minute, minutes in an hour, and hours in a day, as well as configurable names). I'm working on optimizing and getting actually useful stuff (ie the effects) ready, then I'll release it.

Quote from: WcW on June 01, 2009, 02:57:32 pm
That will be added in when I implement the Weather module (right now I only have Clock and Calendar, both of which are working perfectly)

Right now, I'm planning on implementing Weather by having the user be able to set different periods -- for example, have Summer generally be hotter and Winter generally be colder by setting which day of which month each season starts and what kind of season it is, then blending season together (ie summer cools back down to the upper 70s nearing Fall), then having El Nina/El Nino like situations, etc. On top of all that I'll have randomly-generated weather. Of course, I'll also have to add stuff like beginning and ending temperatures for the day and ways to make that change based on location (ie deserts have much higher temperatures than everywhere else during the day, as well as much colder nights). This'll be a LOT of work.


*drools*
It'll be soooo fun to make up holidays and seasons...

Can't wait :D
Title: Re: [XP] Advanced Time and Environment System
Post by: Calintz on June 01, 2009, 05:27:35 pm
It really sounds like this script has come a long way.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on June 01, 2009, 05:59:53 pm
Very nice. Just be sure to have Celsius temperature as well if you use Fahrenheit as default.
Title: Re: [XP] Advanced Time and Environment System
Post by: Calintz on June 01, 2009, 10:29:13 pm
You really think when you create scripts, don't you Blizzard?
Title: Re: [XP] Advanced Time and Environment System
Post by: Valcos on June 02, 2009, 12:15:34 am
Quote from: WcW on June 01, 2009, 02:57:32 pm(ie summer cools back down to the upper 70s nearing Fall)


:o WHAT THE EFF!!! 70!! WE ARE ALL GONNA DIE!!!

Quote from: Aqua on June 01, 2009, 05:03:01 pm
*drools*
It'll be soooo fun to make up holidays and seasons...

Can't wait :D


I second that  8)
Title: Re: [XP] Advanced Time and Environment System
Post by: Calintz on June 02, 2009, 12:31:49 am
Before you get too excited ...
Remember that you will need to make seasonal adjustments to each tileset that you actively use before you can design fully functional season changes for your game ... This would be hard considering you would be adding snow to them, and leaves all over and what not.

I don't know how the script works, but I would assume that a common event or two would probably need to be made to help the efficiency ... (could be wrong)

And not to mention setting the 4separate teleport locations to make sure you are arriving in the proper location, Lol.

**OR ... Have you considered adding a tileset updater WCW??
Like, when the script updates the current season, it will also automatically update each tileset accordingly.

You could do it like so ...
Create your custom tilesets and name them accordingly.
Example - [013-PostTown01_Summer, 013-PostTown01_Fall, 013-PostTown01_Winter, 013-PostTown01_Spring].

Allow the script to update the tileset along with the season.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on June 02, 2009, 03:46:21 am
Quote from: Calintz16438 on June 01, 2009, 10:29:13 pm
You really think when you create scripts, don't you Blizzard?


I generally think when I program. Very often I type down some code and go through it a few times checking if it's conceptually ok. When I make 5-10 pieces of code at different positions and in different classes that are properly thought through and checked properly, it often happens that I don't only have no syntax errors but the code works fully from the first try.
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on June 02, 2009, 03:14:52 pm
Lol, exact opposite of me.

And didn't I respond to the celsius comment above...? Oh well. And 70F is only around 20C, sheesh.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on June 02, 2009, 03:54:17 pm
Yeah, but 0°F isn't -50°C. :/

I used to prefer "hack-testing" earlier as well. Today I only use it to quickly identify small mistakes as mistyped variable/class names and small syntax errors but never for conceptual mistakes.
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on June 03, 2009, 12:03:42 pm
You're right. 0F is between -15C and -20C. (5/9)(F - 32), anyone?
Title: Re: [XP] Advanced Time and Environment System
Post by: Jackolas on June 04, 2009, 03:16:22 am
Fahrenheit is not really a great way to display a temperature (am a chemist.. i know it)
because its really strange how Gabriel Fahrenheit thought it up.
(the freezing point of water is 32 °F and the boiling point 212 °F ) I don't see the logic
its also hard to calculate to a easy understandable notation

be ready for some math:

to kelvin:
[K] = ([°F] + 459.67) × 5⁄9
[°F] = [K] × 9⁄5 − 459.67

to Celsius:
[°C] = ([°F] − 32) × 5⁄9
[°F] = [°C] × 9⁄5 + 32
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on June 04, 2009, 03:59:22 am
It's just important that WcW decides how he will store it and that he adds an interface so it can get and set the temperature in °C properly. An option for which scale to use would be useful.
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on June 04, 2009, 09:07:20 am
Quote from: Jackolas on June 04, 2009, 03:16:22 am
Fahrenheit is not really a great way to display a temperature (am a chemist.. i know it)
because its really strange how Gabriel Fahrenheit thought it up.
(the freezing point of water is 32 °F and the boiling point 212 °F ) I don't see the logic
its also hard to calculate to a easy understandable notation

be ready for some math:

to kelvin:
[K] = ([°F] + 459.67) × 5⁄9
[°F] = [K] × 9⁄5 − 459.67

to Celsius:
[°C] = ([°F] − 32) × 5⁄9
[°F] = [°C] × 9⁄5 + 32


Err... Kelvins from Fahrenheit is (5/9)(F - 32) + 273, if I'm not mistaken... Just convert to Celsius then add 273. 0_o
Therefore, to get there from Kelvins, it's (9/5)(K - 273) + 32. It's not that hard, just one extra step. If you find adding/subtracting 273 hard, I have to question your merits as a chemist.

Note that I am not defending customary units, I'd much rather use metric. Sadly 'nuff, I live in the states :/

And Celsius is just as inferior to Kelvins as Fahrenheit are. I mean, -273 degress C is really stupid for an "absolute zero" measure as opposed to an actual 0K.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on June 04, 2009, 10:20:40 am
But it's more practical. How often do you have something at 0°K? And how often do you have something on 0°C? Kelvin are mostly used in physics and not so much in normal life.
Title: Re: [XP] Advanced Time and Environment System
Post by: fugibo on June 04, 2009, 11:22:16 am
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 :/
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on June 04, 2009, 12:20:40 pm
Translation AND scaling, please. :P
Title: Re: [XP] Advanced Time and Environment System
Post by: Jackolas on June 04, 2009, 03:16:52 pm
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
Title: Re: [XP] Advanced Time and Environment System
Post by: Zare on October 31, 2009, 03:01:13 pm
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

Title: Re: [XP] Advanced Time and Environment System
Post by: happyman on November 17, 2009, 06:32:27 pm
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.
Title: Re: [XP] Advanced Time and Environment System
Post by: Jackolas on November 17, 2009, 08:17:17 pm
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.
Title: Re: [XP] Advanced Time and Environment System
Post by: happyman on November 18, 2009, 12:55:13 am
That is sad to hear.  :(

Oh well.  This script is great, btw.  I love it.   :haha:
Title: Re: [XP] Advanced Time and Environment System
Post by: Aqua on November 18, 2009, 04:58:55 pm
Nah uh... o.o
You'd just have to edit the method that draws the text boxes.
Title: Re: [XP] Advanced Time and Environment System
Post by: Jackolas on November 18, 2009, 06:54:00 pm
tryed. could not get it to work (probably cause I'm crap at scripting)
Title: Re: [XP] Advanced Time and Environment System
Post by: ShinyToyGuns on November 18, 2009, 08:06:49 pm
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
Title: Re: [XP] Advanced Time and Environment System
Post by: 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
Title: Re: [XP] Advanced Time and Environment System
Post by: ShinyToyGuns on November 19, 2009, 07:31:00 pm
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)
Title: Re: [XP] Advanced Time and Environment System
Post by: Alton Wyte on November 19, 2009, 11:23:31 pm
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?
Title: Re: [XP] Advanced Time and Environment System
Post by: 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.

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
Title: Re: [XP] Advanced Time and Environment System
Post by: Alton Wyte on November 20, 2009, 03:16:56 am

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

Title: Re: [XP] Advanced Time and Environment System
Post by: ShinyToyGuns on November 20, 2009, 07:38:04 pm
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
Title: Re: [XP] Advanced Time and Environment System
Post by: Jackolas on November 21, 2009, 08:11:57 am
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
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on December 28, 2009, 12:47:42 pm
I posted up v0.4 which has a few small changes to the RMX-OS GDNS plugin can be shorter.
Title: Re: [XP] Advanced Time and Environment System
Post by: legacyblade on January 10, 2010, 05:56:29 pm
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.
Title: Re: [XP] Advanced Time and Environment System
Post by: Jackolas on January 10, 2010, 08:54:41 pm
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)
Title: Re: [XP] Advanced Time and Environment System
Post by: legacyblade on January 10, 2010, 10:00:06 pm
Well I could make it, it's just blizz knows the way through his script better than I do (his scripts are really complex), and it'd be easier if he knew how to do it off the top of his head. It's just when I try editing scripts, it usually appears to work, but then causes a bunch of bugs that I didn't notice at first (simply because I don't understand fully how the script works together).

And I guess I could make it myself, but if you wanted to, you could make it :D (I'm not being lazy, it's just I've got lots of homework now).

BTW, thanks for the comment about the class change script. Glad it helped you get you into scripting :)
Title: Re: [XP] Advanced Time and Environment System
Post by: Jackolas on January 10, 2010, 10:02:58 pm
to be fair.. that script is also the reason for me joining here.
so your the reason me doing scripts and joining this forum :P

Atm I can't do the script until next week.
will do it than if nobody else did it than already
Title: Re: [XP] Advanced Time and Environment System
Post by: legacyblade on January 10, 2010, 10:14:18 pm
sweet o.o I created a scripter!!! MWAHAHHAHAHAHAH

Well that's really nice of you to be willing to do that script addon for me. I'll try and do it myself, but I don't know if I'll have time. But if I don't do it, I (and I'm sure all sorts of other people) would be very grateful to you for doing it.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on January 11, 2010, 06:08:40 am
Maybe I'll add that later. Or LF will if he finally decides to work on the script a bit. ;>_>
Title: Re: [XP] Advanced Time and Environment System
Post by: Ilitsa on January 16, 2010, 02:13:23 am
Hi everyone, me again =x

I was wondering if someone could help me out with this script. I got it working just fine for the most part, just wanted a few things changed

length of day/night (I wanted it to last maybe 5 minutes? The way its set up default is something like 32 seconds for a full cycle) another issue I had was when I enter a building, I want to turn it off, so I call script and write ATES.off and thought that was it, but it kept scrolling through the tints, so I added ATES.tint_off, but now when I leave a building, the tint jumps to what it would be had I stayed outside.

I'm not sure if it would be easier to explain it to me here, or on msn, I'm a complete Scripting nubcake, so I might take a while before FULLY understanding(though I have made some good steps forward today, just by playing around)

Thanks in advance
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on January 16, 2010, 05:18:04 am
The default is 36 seconds, not 32. The value has to be a divider of 36, so 300 is not possible. You can use 288 or 324. I did that limitation for a reason, but I can't remember what it was. >.<

If you turn off the tinting, there should be no change in screen tinting controlled by ATES at all.

There's also a demo.
Title: Re: [XP] Advanced Time and Environment System
Post by: Ilitsa on January 16, 2010, 05:39:57 am
Thank you Blizzard, I fully understand now actually :) I'll try not to ask any more dumb questions for a while lol.
Title: Re: [XP] Advanced Time and Environment System
Post by: G_G on January 18, 2010, 02:43:00 pm
How do we make it not tint on certain maps?
Title: Re: [XP] Advanced Time and Environment System
Post by: Tazero on January 18, 2010, 03:56:57 pm
ATES.tint_off...

RTS(Read the script man =P  )
Title: Re: [XP] Advanced Time and Environment System
Post by: raijaku on January 27, 2010, 05:16:30 pm
I keep getting an error.

in the call script function i put "$ATES.on" and several of the other commands but i always get

NoMethodError occured while running script.

undefined method 'on' for nilNilClass

and any and all variations of what is between ' ' tint_on and the other commands are the same. i do not know if i am doing something wrong

or what but if i could get some help with this it would be greatly appreciated
Title: Re: [XP] Advanced Time and Environment System
Post by: Aqua on January 27, 2010, 05:26:47 pm
Did you insert the ATES script in a new script slot below RTP scripts but above Main in the right order?
Title: Re: [XP] Advanced Time and Environment System
Post by: raijaku on January 27, 2010, 07:10:39 pm
Yes here is the order of my scripts

SDK
Mog_Animated_Title
Pixelmovement script v1.3
ATES
Weather Effects
Average Level

also am i even using the right commands? i know very little about scripting and even less about the script call command. my other scripts that use it work fine but this one just does not like me for some reason

Edit: i changed the ATES script location to the bottom of the above list same effect. im gonna try to place directly above main and see what happens

Edit #2: nope no change. please help!
Title: Re: [XP] Advanced Time and Environment System
Post by: Jackolas on January 28, 2010, 03:30:05 am
if i'm correct this script has mayor issues with SDK.
Title: Re: [XP] Advanced Time and Environment System
Post by: raijaku on January 28, 2010, 05:20:17 am
well in the script there is

class Game_ATES
 
  attr_accessor :time
  attr_accessor :frame_count
  attr_accessor :active
  attr_accessor :tinting
 
  def initialize
    @time = ATES::Time.new(0, 0)
    @frame_count = 0
    @active = false
    @tinting = false
  end
now thos falses after active control wheather ATES runs when you start the game or not. i can use the ATES system when i set those to true and i have no issues the clock works and all else. however the problem comes from the fact that i cannot not use the call script function to control the system meaning that it is always on. for the time being i have it set to off, seeing as this is one of the few day-night systems i have seen for xp i would really like to have this working. if someone has any idea how it can be fixed please help me

Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on January 28, 2010, 05:48:00 am
Not "$ATES.on" but "ATES.on".
Title: Re: [XP] Advanced Time and Environment System
Post by: raijaku on January 28, 2010, 12:56:34 pm
... ... ... I am a complete idiot. lol. I don't know much about the script call commands like i said before and i thought that all commands had to have $ in front of it. this makes me look like a complete noob despite the fact ive been using rpgmaker for going on about 3 years now. thank you for fixing my error and sorry to bother everyone with such a noob mistake
Title: Re: [XP] Advanced Time and Environment System
Post by: Lost King on January 28, 2010, 01:27:52 pm
Nothing to feel nooby about, I've been using XP for 3 years now too and still find new stuff, and that's only with default event stuff, scripting's a whole nother story.

If this script gets any more new and exciting features I may consider using it in a project of mine.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on January 29, 2010, 05:27:37 am
Happens to everybody. xD
Title: Re: [XP] Advanced Time and Environment System
Post by: Jragyn on February 02, 2010, 05:54:01 am
Could this script be modified in some way to project REAL time into the game, versus implanted 5 minute days, 5 minute nights (or whatever they are set to)?

I currently use a script I butchered and modified for use from VX...for XP!
Spoiler: ShowHide
#==============================================================================
# � Kylock's Time System VX 1.5 MOD V.1.1
#     6.3.2008                 30.5.2009
#------------------------------------------------------------------------------
#  Script by: Kylock
#  MOD by reijubv
#===============================================================================
# Credit mainly goes to Kylock
# and then.  reijubv
# (Cuz I think I deserve something better than just a "thanks"..)
# Have a nice day!
#===============================================================================
# ? Auto-tone Instructions
#------------------------------------------------------------------------------
#    Maps designated as outdoors are the only maps to be affected by this
#  scripts use of auto-toning.  To signify a map to be "outdoors", you must
#  include [KTS] In the name of the map.  For example, you world map could be
#  named "World Map [KTS]" or "[KTS] World Map".  Provisions are made later in
#  the script to remove [KTS] from the map name when it's read by another
#  script.  This means that "[KTS]" won't show up in your Map Name Popup
#  windows.
#==============================================================================
# ? Game Database Setup
#------------------------------------------------------------------------------
#    This script, by defult, uses the following game variables and switches:
#  Database Variables:
#    [1] The Current Time
#    [2] The Current Second
#    [3] The Current Minute
#    [4] The Current Hour
#    [5] The Current Day
#    [6] Name of the Current Day (abbreviated)
#    [7] The Current Day index in one week (0-6) a week starts from sunday
#    [8] The Current Month
#    [9] The Current Month's name (abbreviated)
#    [10]The Current Day Id in this Month (1-32,or 1-30,or 1-29)
#    [11]The Current Year
#    [12]Season's name
#    [13]Weather's Name
#    [14]Weather Id, 0 is clear weather..
#  Database Switches
#    [1] ON during night hours   (2200-0400)(10pm-4am)
#    [2] ON during dawn hours    (0500-0800)( 5am-8am)
#    [3] ON during daytime hours (0900-1800)( 9am-6pm)
#    [4] ON during sunset hours  (1900-2100)( 7pm-9pm)
#    [5] ON during spring season
#    [6] ON during summer season
#    [7] ON during fall season
#    [8] ON during winter season
#==============================================================================

$kylockTIME = true


#==============================================================================
# Stores variables and user defined settings for the time system.
#==============================================================================
module KTS
  #-----------------------------------------------------------------------
  # Settings for Time Periods
  #-----------------------------------------------------------------------
  T1 = [ 0,4 ] # Night         # Sets time periods for tinting effects
  T2 = [ 5,8 ] # Dawn          # [Start Hour, End Hour] for time period
  T3 = [ 9,17] # Day           # Use 24-hour values for time periods
  T4 = [18,21] # Sunset
  T5 = [22,24] # Night         # <- Ex: Night is between 23:00 and 24:00
  #-----------------------------------------------------------------------
  # Settings for Output to Game Variables option.
  #-----------------------------------------------------------------------
  # Set this to true to output the current time to game variables.
  DATABASE_OUTPUT = true 
    # Game Variable to be used for time output.
    TIME    = 12 #(Time in string format. Ex: "2:48 AM" or "02:48")
    SECONDS = 13 # 1 to 59
    MINUTES = 14 # 1 to 59
    HOURS   = 15 # 1 to 24
    DAYS    = 16 # 1 to 366
    DAYNAME = 17 # Sun, Mon, etc..
    WEEKDAY = 18 # 0 to 6 (Day index in one week)
    MONTH   = 20 # 1 to 12
    MONTHNAM= 19 # Jan, Feb, May, etc..
    MONTHDAY= 21# 1 to 31
    YEAR    = 22# 1994, 2009, etc
    SEASON  = 23# Season Name (Spring, Summer, Fall, Winter)
    WEATHERN= 24# Weather's name
    WEATHER = 25# Weather Id, 0 is clear weather
   
    # Game Switches to be used for time output.
    NIGHT   = 55 # This switch is on during night hours   (2200-0400)(10pm-4am)
    DAWN    = 56 # This switch is on during dawn hours    (0500-0800)( 5am-8am)
    DAY     = 57 # This switch is on during daytime hours (0900-1800)( 9am-6pm)
    SUNSET  = 58 # This switch is on during sunset hours  (1900-2100)( 7pm-9pm)

    # Season Switches.
    SPRING  = 59 # This switch is on during spring season
    SUMMER  = 60 # This switch is on during summer season
    FALL    = 61 # This switch is on during fall season
    WINTER  = 62 # This switch is on during winter season
  #-----------------------------------------------------------------------
  # Settings for time controlled screen toning
  #-----------------------------------------------------------------------
  # True will enable screen toning to be used by the script.
  USE_TONE = true
  # Sets the duration of tone changes (in frames)
  FADE_LENGTH = 240
  # Defines tones to be used in the corresponding time periods defined above.
  #              RED, GREEN, BLUE, GREY
  C1 = Tone.new(-187,  -119,  -17,  68)
  C2 = Tone.new(  17,   -51, -102,   0)
  C3 = Tone.new(   0,     0,    0,   0)
  C4 = Tone.new( -68,  -136,  -34,   0)
  C5 = Tone.new(-187,  -119,  -17,  68)
  # Defines anti-tones
  A1 = Tone.new( 187,   119,   17, -68)
  A2 = Tone.new( -17,    51,  102,   0)
  A3 = Tone.new(   0,     0,    0,   0)
  A4 = Tone.new(  68,   136,   34,   0)
  A5 = Tone.new( 187,   119,   17, -68)
  #-----------------------------------------------------------------------
  # MOD
  #-----------------------------------------------------------------------
  #-----------------------------------------------------------------------
  # Settings for season periods
  #-----------------------------------------------------------------------
  S1 = [1,3]  # Spring        # Sets month periods for season system
  S2 = [4,6]  # Summer        # [Start Month, End Month] for time period
  S3 = [7,9] # Fall          #
  S4 = [10,12] # Winter        # <- Ex: Winter is between 10th - 12th (Oct - Dec)
  # Use automatic weather?
  WEATHER_SYSTEM = true
  # Sets the duration of weather changes (in frames)
  WEATHER_LENGTH = 240
  # Time before changing weather (in hours)
  WEATHER_COOLDOWN = 3
  # Weather names (Must be the same order as weather's Id) adds as many as required
  #                   0       1        2         3
  WEATHER_NAME = ["Clear", "Rain" , "Storm" , "Snowy"] # VX default only have these 3
  #-----------------------------------------------------------------------
  # Settings for possible weather
  # To add more weathers, just add more weather ids there
  # ex = W[#] = [ WeatherId, .....]
  # S[#] means, season number #
  # Weathers only occurs when entering map with [KTS] on it's name.
  # Those weathers will be randomly occurs, but snowy weather only spawns
  # during Winter.
  #-----------------------------------------------------------------------
  W = {}
  W[1] = [0, 1, 2 ] # [ WeatherId, .....]
  W[2] = [0, 1, 2 ] # [ WeatherId, .....]
  W[3] = [0, 1, 2 ] # [ WeatherId, .....]
  W[4] = [0, 1, 3 ] # [ WeatherId, .....]
  #-----------------------------------------------------------------------
  # Settings for weather bgs
  # WeatherId => "filename", file must be in Audio/BGS/ folder
  #-----------------------------------------------------------------------
  WEATHERSOUND_OK = true
  # If true, setup the BGS on line 385
  # Remember. BGS only changes when you enter/exit a map, but weather can change
  # even if you stay inside a map for a long time....
end

#==============================================================================
# Core Time System Engine (MODDED)
#==============================================================================
class Kylock_Time_System
  if $kylockTIME = true
  # sets instance variables
  def initialize
    $kts_map_data = load_data("Data/MapInfos.rxdata")
    @event_offset = (Time.now.strftime("%H").to_i * 3600) + (Time.now.strftime("%w").to_i * 86400)
    $kts_event_tone = false
    $kts_event_weather = false
    $kts_battle_tone = true
    $kts_anti_tone = Tone.new(0,0,0,0)
    @startingweatherdelay = 0
    @curweather = 0
    @played = false
  end
  # Computes current time and updates variables if used
  def update
    if !@kts_stop
      # for scripters
      @total_seconds = Graphics.frame_count + @event_offset
      @total_minutes = @total_seconds / 60
      @total_hours = @total_minutes / 60
      @total_days = @total_hours / 24
      @total_weeks = @total_days / 7
      @total_months = @total_weeks / 4
      @total_years = @total_months/12
      #
      @seconds = Time.now.sec
      @minutes = Time.now.min
      @hours   = Time.now.hour
      @days    = Time.now.strftime("%j").to_i
      @weekday = Time.now.strftime("%w").to_i
      @month = Time.now.strftime("%m").to_i
      @monthname = Time.now.strftime("%b")
      @monthday = Time.now.strftime("%d")
      @year = Time.now.strftime("%Y").to_i
      update_tint
      update_weather
      if KTS::DATABASE_OUTPUT
        $game_variables[KTS::TIME]    = getTime
      end
    end
  end
  #
  def update_variables
    $game_variables[KTS::SECONDS] = @seconds
    $game_variables[KTS::MINUTES] = @minutes
    $game_variables[KTS::HOURS]   = @hours
    $game_variables[KTS::DAYS]    = @days
    $game_variables[KTS::DAYNAME] = getDayName
    $game_variables[KTS::WEEKDAY] = @weekday
    $game_variables[KTS::MONTH] = @month
    $game_variables[KTS::MONTHNAM] = @monthname
    $game_variables[KTS::YEAR] = @year
    if KTS::WEATHER_SYSTEM == true
      $game_variables[KTS::WEATHER] = $game_screen.weather_type #@weather
    if $game_variables[25] == 0
      $game_variables[KTS::WEATHERN] = "Clear" #getWeatherName
    elsif $game_variables[25] == 1
      $game_variables[KTS::WEATHERN] = "Raining" #getWeatherName
    elsif $game_variables[25] == 2
      $game_variables[KTS::WEATHERN] = "Deluge" #getWeatherName
    elsif $game_variables[25] == 3
      $game_variables[KTS::WEATHERN] = "Snowy" #getWeatherName
    end
    end
    $game_variables[KTS::SEASON] = getSeasonName
    $game_variables[KTS::MONTHDAY] = @monthday
  end
  #
  def update_switches
    if @period == 1 || @period == 5
      $game_switches[KTS::NIGHT] = true
    else
      $game_switches[KTS::NIGHT] = false
    end
    if @period == 2
      $game_switches[KTS::DAWN] = true
    else
      $game_switches[KTS::DAWN] = false
    end
    if @period == 3
      $game_switches[KTS::DAY] = true
    else
      $game_switches[KTS::DAY] = false
    end
    if @period == 4
      $game_switches[KTS::SUNSET] = true
    else
      $game_switches[KTS::SUNSET] = false
    end
  end
  #
  def update_season_swithces
    if @month >= KTS::S1[0] and @month <= KTS::S1[1]
      @speriod = 1
      $game_switches[KTS::SPRING] = true
    else
      $game_switches[KTS::SPRING] = false
    end
    if @month >= KTS::S2[0] and @month <= KTS::S2[1]
      @speriod = 2
      $game_switches[KTS::SUMMER] = true
    else
      $game_switches[KTS::SUMMER] = false
    end
    if @month >= KTS::S3[0] and @month <= KTS::S3[1]
      @speriod = 3
      $game_switches[KTS::FALL] = true
    else
      $game_switches[KTS::FALL] = false
    end
    if @month >= KTS::S4[0] and @month <= KTS::S4[1]
      @speriod = 4
      $game_switches[KTS::WINTER] = true
    else
      $game_switches[KTS::WINTER] = false
    end
  end
  #-----------------------------------------------------------------------
  # Script Support/Misc Functions (MODDED)
  #-----------------------------------------------------------------------
  def getTime
    time = Time.now.strftime("%H:%M %p")
    return time
  end
  def getSeasonName
    sname = "Spring" if @speriod == 1
    sname = "Summer" if @speriod == 2
    sname = "Fall"   if @speriod == 3
    sname = "Winter" if @speriod == 4
    return sname
  end
  def getMonthName
    monthname = Time.now.strftime('%b')
    return monthname
  end
  def getDayName
    weekday = Time.now.strftime('%a')
    return weekday
  end
  def getWeatherName
#    weathername = KTS::WEATHER_NAME[@weather]
#    return weathername
  end
 
  #-----------------------------------------------------------------------
  # Screen Tone Functions
  #-----------------------------------------------------------------------
  def update_tint(duration = KTS::FADE_LENGTH)
    return if $BTEST
    if KTS::USE_TONE && !$kts_event_tone && $kts_map_data[$game_map.map_id].outside_tint?
      if @hours >= KTS::T1[0] and @hours <= KTS::T1[1]
        @period = 1   
        $game_screen.start_tone_change(KTS::C1,duration)
        $kts_anti_tone = KTS::A1
      elsif @hours >= KTS::T2[0] and @hours <= KTS::T2[1]
        @period = 2
        $game_screen.start_tone_change(KTS::C2,duration)
        $kts_anti_tone = KTS::A2
      elsif @hours >= KTS::T3[0] and @hours <= KTS::T3[1]
        @period = 3
        $game_screen.start_tone_change(KTS::C3,duration)
        $kts_anti_tone = KTS::A3
      elsif @hours >= KTS::T4[0] and @hours <= KTS::T4[1]
        @period = 4
        $game_screen.start_tone_change(KTS::C4,duration)
        $kts_anti_tone = KTS::A4
      elsif @hours >= KTS::T5[0] and @hours <= KTS::T5[1]
        @period = 5
        $game_screen.start_tone_change(KTS::C5,duration)
        $kts_anti_tone = KTS::A5
      end
    else
      # no tone if indoors
        if !$kts_map_data[$game_map.map_id].outside_tint?
          $game_screen.start_tone_change(Tone.new(0,0,0,0),duration)
        end
    end
  end
  # Set weather
  def setweather(duration)
    if ((@startingweatherdelay - @hours) >= KTS::WEATHER_COOLDOWN) or
       ((@startingweatherdelay - @hours) <= -KTS::WEATHER_COOLDOWN)
      @startingweatherdelay = Time.now.hour
      the_weatherset = KTS::W[@speriod]
      @curweather = the_weatherset[rand(KTS::W[@speriod].length)]
      @weather = @curweather
    else
      @weather = @curweather
    end
    $game_screen.weather(@weather, 9 , duration)
  end
   
  #-----------------------------------------------------------------------
  # Season/weather update
  #-----------------------------------------------------------------------
  def update_weather(duration = KTS::WEATHER_LENGTH)
    return if $BTEST
    if KTS::WEATHER_SYSTEM && !$kts_event_weather && $kts_map_data[$game_map.map_id].outside_tint?
      if @month >= KTS::S1[0] and @month <= KTS::S1[1]
        @speriod = 1
      elsif @month >= KTS::S2[0] and @month <= KTS::S2[1]
        @speriod = 2
      elsif @month >= KTS::S3[0] and @month <= KTS::S3[1]
        @speriod = 3
      elsif @month >= KTS::S4[0] and @month <= KTS::S4[1]
        @speriod = 4
      end
      setweather(duration)
    else
      # no weather if indoors
        if !$kts_map_data[$game_map.map_id].outside_tint?
          Audio.bgs_stop #Stop BGS
          $game_screen.weather(0, 0, 0)
        end
    end
  end
=begin
  def screen
    if $game_temp.in_battle
      return $game_troop.screen
    else
      return $game_map.screen
    end
  end
=end
  # Extra Feature; Change BGS
  def start_bgs
    return if !$kts_map_data[$game_map.map_id].outside_tint?
     if $kts_map_data[$game_map.map_id].outside_tint?
      if  KTS::WEATHER_SYSTEM == true
        if KTS::WEATHERSOUND_OK == true
          if @weather == 1
            Audio.bgs_play("Audio/BGS/Rain", 70, 100)
          elsif @weather == 2
            Audio.bgs_play("Audio/BGS/Storm", 70, 100)
            # ADD MORE IF YOU WANT to play BGS when weather with Id @weather occurs!
            # Like this :
            # elsif @weather == Id
            #  Audio.bgs_play("Audio/BGS/SomeBGS", 70, 100)
          else
            Audio.bgs_stop
          end
        end
      end
    end
  end
end
end

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias kts_initialize initialize
  def initialize
    $kts.update_switches if KTS::DATABASE_OUTPUT
    $kts.update_variables if KTS::DATABASE_OUTPUT
    $kts.update_season_swithces if KTS::DATABASE_OUTPUT
    kts_initialize
  end
end

#==============================================================================
# Instantly updates screen tone when a new map is loaded.
#==============================================================================
class Game_Map
  alias kts_setup setup
  def setup(map_id)
    kts_setup(map_id)
    $kts_event_tone = false
    $kts.update
    $kts.update_tint(0)
    $kts.update_weather(0) if KTS::WEATHER_SYSTEM
    $kts.start_bgs
  end
end
=begin
#==============================================================================
# Instantly updates screen tone when a battle starts.
#==============================================================================
class Spriteset_Battle
  alias kts_create_battleback create_battleback
  def create_battleback
    $kts.update_tint(0)
    kts_create_battleback
  end
end

#==============================================================================
# Temporarily disables auto-toning if an event tints the screen.
#==============================================================================
class Game_Interpreter
  alias kts_Interpreter_command_223 command_223
  def command_223
    $kts_event_tone = true
    kts_Interpreter_command_223
  end
  alias kts_Interpreter_command_236 command_236
  def command_236
    $kts_event_weather = true
    kts_Interpreter_command_226
  end
end
=end
#==============================================================================
# Integrates the Time System into the Game System.
#==============================================================================
class Game_System
  # inits a KTS object
  alias kts_initialize initialize
  def initialize
    $kts=Kylock_Time_System.new
    kts_initialize
  end
  # Updates kts every game frame
  alias kts_update update
  def update
    $kts.update
    kts_update
  end
end

#==============================================================================
# Scans Map Names for Toning
#==============================================================================
class RPG::MapInfo
  def name # Definition prevents location scripts from reading anything within
    return @name.gsub(/\[.*\]/) {""} # brackets, including the brackets
  end
  def original_name
    return @name
  end
  def outside_tint?
    return @name.scan(/\[KTS\]/).size > 0
    # old regexp: return @name.scan(/[\KTS]/).size > 0
  end
end
=begin
#==============================================================================
# Sets up the time window for the menu. (MODDED)
#==============================================================================
class Window_KTS < Window_Base
  def initialize(x, y)
    super(x, y, 160, WLH+32)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.draw_text(0, -6, 120, 32,$kts.getDayName+" "+$kts.getTime, 2)
  end
  def update
    super
    $kts.update
    self.contents.clear
    self.contents.draw_text(0, -6, 120, 32, $kts.getDayName+" "+$kts.getTime, 2)
  end
end

#==============================================================================
# Adds the time window to the menu.
#==============================================================================
class Scene_Menu < Scene_Base
  alias kts_start start
  def start
    kts_start
    @kts_window = Window_KTS.new(0,304)
  end
  alias kts_terminate terminate
  def terminate
    kts_terminate
    @kts_window.dispose
  end
  alias kts_update update
  def update
    kts_update
    @kts_window.update
  end
end
=end
#==============================================================================
# Saves and Loads game time to/from save game file.
#==============================================================================
class Scene_Save
  alias kts_write_save_data write_save_data
  def write_save_data(file)
    kts_write_save_data(file)
    Marshal.dump($kts, file)
  end
end

class Scene_Load
  alias kts_read_save_data read_save_data
  def read_save_data(file)
    kts_read_save_data(file)
    $kts = Marshal.load(file)
  end
end


And well, honestly, I just feel like if it was made FOR XP, and not just me hacking up the script until it functions as I need it, mayhaps the world could utilize this script as well as me :D

Just a thought.
Title: Re: [XP] Advanced Time and Environment System
Post by: Lost King on February 05, 2010, 05:30:34 pm
Not sure if I should be asking here or in the RMX-OS plugin thread, but I decided to try using ATES today in my RMX-OS game. I believe I managed to input the scripts properly, I'm not getting errors, I'm just getting a very Yellow screen. It comes up regardless of whether ATES is on or tinting is on. From what I've read, people here don't seem to be experiencing it so I think it's something with the RMX-OS extension. I tried to go into the script and fiddle with the tinting colors...but there's a lot of different little tinting sections and I'm not sure which to mess with. Oh, and the clock displays in a weird format. Like I'm getting the time: 300:40

Any help?

EDIT: Alright, I think I fixed it by making the ATES turn on with a parallel process event that also changes the screen color tone back to normal colors. Not sure if this will change when entering another map or when the tinting happens, I should probably have posed this question in the plugin thread though as it seems to be the cause.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on February 06, 2010, 05:05:12 am
There actually is a RMX-OS plugin. *points to Global DNS for RMX-OS topic*
Title: Re: [XP] Advanced Time and Environment System
Post by: element on February 06, 2010, 12:01:52 pm
Quote from: jragyn00 on February 02, 2010, 05:54:01 am
Could this script be modified in some way to project REAL time into the game, versus implanted 5 minute days, 5 minute nights (or whatever they are set to)?

I currently use a script I butchered and modified for use from VX...for XP!
Spoiler: ShowHide
#==============================================================================
# � Kylock's Time System VX 1.5 MOD V.1.1
#     6.3.2008                 30.5.2009
#------------------------------------------------------------------------------
#  Script by: Kylock
#  MOD by reijubv
#===============================================================================
# Credit mainly goes to Kylock
# and then.  reijubv
# (Cuz I think I deserve something better than just a "thanks"..)
# Have a nice day!
#===============================================================================
# ? Auto-tone Instructions
#------------------------------------------------------------------------------
#    Maps designated as outdoors are the only maps to be affected by this
#  scripts use of auto-toning.  To signify a map to be "outdoors", you must
#  include [KTS] In the name of the map.  For example, you world map could be
#  named "World Map [KTS]" or "[KTS] World Map".  Provisions are made later in
#  the script to remove [KTS] from the map name when it's read by another
#  script.  This means that "[KTS]" won't show up in your Map Name Popup
#  windows.
#==============================================================================
# ? Game Database Setup
#------------------------------------------------------------------------------
#    This script, by defult, uses the following game variables and switches:
#  Database Variables:
#    [1] The Current Time
#    [2] The Current Second
#    [3] The Current Minute
#    [4] The Current Hour
#    [5] The Current Day
#    [6] Name of the Current Day (abbreviated)
#    [7] The Current Day index in one week (0-6) a week starts from sunday
#    [8] The Current Month
#    [9] The Current Month's name (abbreviated)
#    [10]The Current Day Id in this Month (1-32,or 1-30,or 1-29)
#    [11]The Current Year
#    [12]Season's name
#    [13]Weather's Name
#    [14]Weather Id, 0 is clear weather..
#  Database Switches
#    [1] ON during night hours   (2200-0400)(10pm-4am)
#    [2] ON during dawn hours    (0500-0800)( 5am-8am)
#    [3] ON during daytime hours (0900-1800)( 9am-6pm)
#    [4] ON during sunset hours  (1900-2100)( 7pm-9pm)
#    [5] ON during spring season
#    [6] ON during summer season
#    [7] ON during fall season
#    [8] ON during winter season
#==============================================================================

$kylockTIME = true


#==============================================================================
# Stores variables and user defined settings for the time system.
#==============================================================================
module KTS
  #-----------------------------------------------------------------------
  # Settings for Time Periods
  #-----------------------------------------------------------------------
  T1 = [ 0,4 ] # Night         # Sets time periods for tinting effects
  T2 = [ 5,8 ] # Dawn          # [Start Hour, End Hour] for time period
  T3 = [ 9,17] # Day           # Use 24-hour values for time periods
  T4 = [18,21] # Sunset
  T5 = [22,24] # Night         # <- Ex: Night is between 23:00 and 24:00
  #-----------------------------------------------------------------------
  # Settings for Output to Game Variables option.
  #-----------------------------------------------------------------------
  # Set this to true to output the current time to game variables.
  DATABASE_OUTPUT = true 
    # Game Variable to be used for time output.
    TIME    = 12 #(Time in string format. Ex: "2:48 AM" or "02:48")
    SECONDS = 13 # 1 to 59
    MINUTES = 14 # 1 to 59
    HOURS   = 15 # 1 to 24
    DAYS    = 16 # 1 to 366
    DAYNAME = 17 # Sun, Mon, etc..
    WEEKDAY = 18 # 0 to 6 (Day index in one week)
    MONTH   = 20 # 1 to 12
    MONTHNAM= 19 # Jan, Feb, May, etc..
    MONTHDAY= 21# 1 to 31
    YEAR    = 22# 1994, 2009, etc
    SEASON  = 23# Season Name (Spring, Summer, Fall, Winter)
    WEATHERN= 24# Weather's name
    WEATHER = 25# Weather Id, 0 is clear weather
   
    # Game Switches to be used for time output.
    NIGHT   = 55 # This switch is on during night hours   (2200-0400)(10pm-4am)
    DAWN    = 56 # This switch is on during dawn hours    (0500-0800)( 5am-8am)
    DAY     = 57 # This switch is on during daytime hours (0900-1800)( 9am-6pm)
    SUNSET  = 58 # This switch is on during sunset hours  (1900-2100)( 7pm-9pm)

    # Season Switches.
    SPRING  = 59 # This switch is on during spring season
    SUMMER  = 60 # This switch is on during summer season
    FALL    = 61 # This switch is on during fall season
    WINTER  = 62 # This switch is on during winter season
  #-----------------------------------------------------------------------
  # Settings for time controlled screen toning
  #-----------------------------------------------------------------------
  # True will enable screen toning to be used by the script.
  USE_TONE = true
  # Sets the duration of tone changes (in frames)
  FADE_LENGTH = 240
  # Defines tones to be used in the corresponding time periods defined above.
  #              RED, GREEN, BLUE, GREY
  C1 = Tone.new(-187,  -119,  -17,  68)
  C2 = Tone.new(  17,   -51, -102,   0)
  C3 = Tone.new(   0,     0,    0,   0)
  C4 = Tone.new( -68,  -136,  -34,   0)
  C5 = Tone.new(-187,  -119,  -17,  68)
  # Defines anti-tones
  A1 = Tone.new( 187,   119,   17, -68)
  A2 = Tone.new( -17,    51,  102,   0)
  A3 = Tone.new(   0,     0,    0,   0)
  A4 = Tone.new(  68,   136,   34,   0)
  A5 = Tone.new( 187,   119,   17, -68)
  #-----------------------------------------------------------------------
  # MOD
  #-----------------------------------------------------------------------
  #-----------------------------------------------------------------------
  # Settings for season periods
  #-----------------------------------------------------------------------
  S1 = [1,3]  # Spring        # Sets month periods for season system
  S2 = [4,6]  # Summer        # [Start Month, End Month] for time period
  S3 = [7,9] # Fall          #
  S4 = [10,12] # Winter        # <- Ex: Winter is between 10th - 12th (Oct - Dec)
  # Use automatic weather?
  WEATHER_SYSTEM = true
  # Sets the duration of weather changes (in frames)
  WEATHER_LENGTH = 240
  # Time before changing weather (in hours)
  WEATHER_COOLDOWN = 3
  # Weather names (Must be the same order as weather's Id) adds as many as required
  #                   0       1        2         3
  WEATHER_NAME = ["Clear", "Rain" , "Storm" , "Snowy"] # VX default only have these 3
  #-----------------------------------------------------------------------
  # Settings for possible weather
  # To add more weathers, just add more weather ids there
  # ex = W[#] = [ WeatherId, .....]
  # S[#] means, season number #
  # Weathers only occurs when entering map with [KTS] on it's name.
  # Those weathers will be randomly occurs, but snowy weather only spawns
  # during Winter.
  #-----------------------------------------------------------------------
  W = {}
  W[1] = [0, 1, 2 ] # [ WeatherId, .....]
  W[2] = [0, 1, 2 ] # [ WeatherId, .....]
  W[3] = [0, 1, 2 ] # [ WeatherId, .....]
  W[4] = [0, 1, 3 ] # [ WeatherId, .....]
  #-----------------------------------------------------------------------
  # Settings for weather bgs
  # WeatherId => "filename", file must be in Audio/BGS/ folder
  #-----------------------------------------------------------------------
  WEATHERSOUND_OK = true
  # If true, setup the BGS on line 385
  # Remember. BGS only changes when you enter/exit a map, but weather can change
  # even if you stay inside a map for a long time....
end

#==============================================================================
# Core Time System Engine (MODDED)
#==============================================================================
class Kylock_Time_System
  if $kylockTIME = true
  # sets instance variables
  def initialize
    $kts_map_data = load_data("Data/MapInfos.rxdata")
    @event_offset = (Time.now.strftime("%H").to_i * 3600) + (Time.now.strftime("%w").to_i * 86400)
    $kts_event_tone = false
    $kts_event_weather = false
    $kts_battle_tone = true
    $kts_anti_tone = Tone.new(0,0,0,0)
    @startingweatherdelay = 0
    @curweather = 0
    @played = false
  end
  # Computes current time and updates variables if used
  def update
    if !@kts_stop
      # for scripters
      @total_seconds = Graphics.frame_count + @event_offset
      @total_minutes = @total_seconds / 60
      @total_hours = @total_minutes / 60
      @total_days = @total_hours / 24
      @total_weeks = @total_days / 7
      @total_months = @total_weeks / 4
      @total_years = @total_months/12
      #
      @seconds = Time.now.sec
      @minutes = Time.now.min
      @hours   = Time.now.hour
      @days    = Time.now.strftime("%j").to_i
      @weekday = Time.now.strftime("%w").to_i
      @month = Time.now.strftime("%m").to_i
      @monthname = Time.now.strftime("%b")
      @monthday = Time.now.strftime("%d")
      @year = Time.now.strftime("%Y").to_i
      update_tint
      update_weather
      if KTS::DATABASE_OUTPUT
        $game_variables[KTS::TIME]    = getTime
      end
    end
  end
  #
  def update_variables
    $game_variables[KTS::SECONDS] = @seconds
    $game_variables[KTS::MINUTES] = @minutes
    $game_variables[KTS::HOURS]   = @hours
    $game_variables[KTS::DAYS]    = @days
    $game_variables[KTS::DAYNAME] = getDayName
    $game_variables[KTS::WEEKDAY] = @weekday
    $game_variables[KTS::MONTH] = @month
    $game_variables[KTS::MONTHNAM] = @monthname
    $game_variables[KTS::YEAR] = @year
    if KTS::WEATHER_SYSTEM == true
      $game_variables[KTS::WEATHER] = $game_screen.weather_type #@weather
    if $game_variables[25] == 0
      $game_variables[KTS::WEATHERN] = "Clear" #getWeatherName
    elsif $game_variables[25] == 1
      $game_variables[KTS::WEATHERN] = "Raining" #getWeatherName
    elsif $game_variables[25] == 2
      $game_variables[KTS::WEATHERN] = "Deluge" #getWeatherName
    elsif $game_variables[25] == 3
      $game_variables[KTS::WEATHERN] = "Snowy" #getWeatherName
    end
    end
    $game_variables[KTS::SEASON] = getSeasonName
    $game_variables[KTS::MONTHDAY] = @monthday
  end
  #
  def update_switches
    if @period == 1 || @period == 5
      $game_switches[KTS::NIGHT] = true
    else
      $game_switches[KTS::NIGHT] = false
    end
    if @period == 2
      $game_switches[KTS::DAWN] = true
    else
      $game_switches[KTS::DAWN] = false
    end
    if @period == 3
      $game_switches[KTS::DAY] = true
    else
      $game_switches[KTS::DAY] = false
    end
    if @period == 4
      $game_switches[KTS::SUNSET] = true
    else
      $game_switches[KTS::SUNSET] = false
    end
  end
  #
  def update_season_swithces
    if @month >= KTS::S1[0] and @month <= KTS::S1[1]
      @speriod = 1
      $game_switches[KTS::SPRING] = true
    else
      $game_switches[KTS::SPRING] = false
    end
    if @month >= KTS::S2[0] and @month <= KTS::S2[1]
      @speriod = 2
      $game_switches[KTS::SUMMER] = true
    else
      $game_switches[KTS::SUMMER] = false
    end
    if @month >= KTS::S3[0] and @month <= KTS::S3[1]
      @speriod = 3
      $game_switches[KTS::FALL] = true
    else
      $game_switches[KTS::FALL] = false
    end
    if @month >= KTS::S4[0] and @month <= KTS::S4[1]
      @speriod = 4
      $game_switches[KTS::WINTER] = true
    else
      $game_switches[KTS::WINTER] = false
    end
  end
  #-----------------------------------------------------------------------
  # Script Support/Misc Functions (MODDED)
  #-----------------------------------------------------------------------
  def getTime
    time = Time.now.strftime("%H:%M %p")
    return time
  end
  def getSeasonName
    sname = "Spring" if @speriod == 1
    sname = "Summer" if @speriod == 2
    sname = "Fall"   if @speriod == 3
    sname = "Winter" if @speriod == 4
    return sname
  end
  def getMonthName
    monthname = Time.now.strftime('%b')
    return monthname
  end
  def getDayName
    weekday = Time.now.strftime('%a')
    return weekday
  end
  def getWeatherName
#    weathername = KTS::WEATHER_NAME[@weather]
#    return weathername
  end
 
  #-----------------------------------------------------------------------
  # Screen Tone Functions
  #-----------------------------------------------------------------------
  def update_tint(duration = KTS::FADE_LENGTH)
    return if $BTEST
    if KTS::USE_TONE && !$kts_event_tone && $kts_map_data[$game_map.map_id].outside_tint?
      if @hours >= KTS::T1[0] and @hours <= KTS::T1[1]
        @period = 1   
        $game_screen.start_tone_change(KTS::C1,duration)
        $kts_anti_tone = KTS::A1
      elsif @hours >= KTS::T2[0] and @hours <= KTS::T2[1]
        @period = 2
        $game_screen.start_tone_change(KTS::C2,duration)
        $kts_anti_tone = KTS::A2
      elsif @hours >= KTS::T3[0] and @hours <= KTS::T3[1]
        @period = 3
        $game_screen.start_tone_change(KTS::C3,duration)
        $kts_anti_tone = KTS::A3
      elsif @hours >= KTS::T4[0] and @hours <= KTS::T4[1]
        @period = 4
        $game_screen.start_tone_change(KTS::C4,duration)
        $kts_anti_tone = KTS::A4
      elsif @hours >= KTS::T5[0] and @hours <= KTS::T5[1]
        @period = 5
        $game_screen.start_tone_change(KTS::C5,duration)
        $kts_anti_tone = KTS::A5
      end
    else
      # no tone if indoors
        if !$kts_map_data[$game_map.map_id].outside_tint?
          $game_screen.start_tone_change(Tone.new(0,0,0,0),duration)
        end
    end
  end
  # Set weather
  def setweather(duration)
    if ((@startingweatherdelay - @hours) >= KTS::WEATHER_COOLDOWN) or
       ((@startingweatherdelay - @hours) <= -KTS::WEATHER_COOLDOWN)
      @startingweatherdelay = Time.now.hour
      the_weatherset = KTS::W[@speriod]
      @curweather = the_weatherset[rand(KTS::W[@speriod].length)]
      @weather = @curweather
    else
      @weather = @curweather
    end
    $game_screen.weather(@weather, 9 , duration)
  end
   
  #-----------------------------------------------------------------------
  # Season/weather update
  #-----------------------------------------------------------------------
  def update_weather(duration = KTS::WEATHER_LENGTH)
    return if $BTEST
    if KTS::WEATHER_SYSTEM && !$kts_event_weather && $kts_map_data[$game_map.map_id].outside_tint?
      if @month >= KTS::S1[0] and @month <= KTS::S1[1]
        @speriod = 1
      elsif @month >= KTS::S2[0] and @month <= KTS::S2[1]
        @speriod = 2
      elsif @month >= KTS::S3[0] and @month <= KTS::S3[1]
        @speriod = 3
      elsif @month >= KTS::S4[0] and @month <= KTS::S4[1]
        @speriod = 4
      end
      setweather(duration)
    else
      # no weather if indoors
        if !$kts_map_data[$game_map.map_id].outside_tint?
          Audio.bgs_stop #Stop BGS
          $game_screen.weather(0, 0, 0)
        end
    end
  end
=begin
  def screen
    if $game_temp.in_battle
      return $game_troop.screen
    else
      return $game_map.screen
    end
  end
=end
  # Extra Feature; Change BGS
  def start_bgs
    return if !$kts_map_data[$game_map.map_id].outside_tint?
     if $kts_map_data[$game_map.map_id].outside_tint?
      if  KTS::WEATHER_SYSTEM == true
        if KTS::WEATHERSOUND_OK == true
          if @weather == 1
            Audio.bgs_play("Audio/BGS/Rain", 70, 100)
          elsif @weather == 2
            Audio.bgs_play("Audio/BGS/Storm", 70, 100)
            # ADD MORE IF YOU WANT to play BGS when weather with Id @weather occurs!
            # Like this :
            # elsif @weather == Id
            #  Audio.bgs_play("Audio/BGS/SomeBGS", 70, 100)
          else
            Audio.bgs_stop
          end
        end
      end
    end
  end
end
end

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias kts_initialize initialize
  def initialize
    $kts.update_switches if KTS::DATABASE_OUTPUT
    $kts.update_variables if KTS::DATABASE_OUTPUT
    $kts.update_season_swithces if KTS::DATABASE_OUTPUT
    kts_initialize
  end
end

#==============================================================================
# Instantly updates screen tone when a new map is loaded.
#==============================================================================
class Game_Map
  alias kts_setup setup
  def setup(map_id)
    kts_setup(map_id)
    $kts_event_tone = false
    $kts.update
    $kts.update_tint(0)
    $kts.update_weather(0) if KTS::WEATHER_SYSTEM
    $kts.start_bgs
  end
end
=begin
#==============================================================================
# Instantly updates screen tone when a battle starts.
#==============================================================================
class Spriteset_Battle
  alias kts_create_battleback create_battleback
  def create_battleback
    $kts.update_tint(0)
    kts_create_battleback
  end
end

#==============================================================================
# Temporarily disables auto-toning if an event tints the screen.
#==============================================================================
class Game_Interpreter
  alias kts_Interpreter_command_223 command_223
  def command_223
    $kts_event_tone = true
    kts_Interpreter_command_223
  end
  alias kts_Interpreter_command_236 command_236
  def command_236
    $kts_event_weather = true
    kts_Interpreter_command_226
  end
end
=end
#==============================================================================
# Integrates the Time System into the Game System.
#==============================================================================
class Game_System
  # inits a KTS object
  alias kts_initialize initialize
  def initialize
    $kts=Kylock_Time_System.new
    kts_initialize
  end
  # Updates kts every game frame
  alias kts_update update
  def update
    $kts.update
    kts_update
  end
end

#==============================================================================
# Scans Map Names for Toning
#==============================================================================
class RPG::MapInfo
  def name # Definition prevents location scripts from reading anything within
    return @name.gsub(/\[.*\]/) {""} # brackets, including the brackets
  end
  def original_name
    return @name
  end
  def outside_tint?
    return @name.scan(/\[KTS\]/).size > 0
    # old regexp: return @name.scan(/[\KTS]/).size > 0
  end
end
=begin
#==============================================================================
# Sets up the time window for the menu. (MODDED)
#==============================================================================
class Window_KTS < Window_Base
  def initialize(x, y)
    super(x, y, 160, WLH+32)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.draw_text(0, -6, 120, 32,$kts.getDayName+" "+$kts.getTime, 2)
  end
  def update
    super
    $kts.update
    self.contents.clear
    self.contents.draw_text(0, -6, 120, 32, $kts.getDayName+" "+$kts.getTime, 2)
  end
end

#==============================================================================
# Adds the time window to the menu.
#==============================================================================
class Scene_Menu < Scene_Base
  alias kts_start start
  def start
    kts_start
    @kts_window = Window_KTS.new(0,304)
  end
  alias kts_terminate terminate
  def terminate
    kts_terminate
    @kts_window.dispose
  end
  alias kts_update update
  def update
    kts_update
    @kts_window.update
  end
end
=end
#==============================================================================
# Saves and Loads game time to/from save game file.
#==============================================================================
class Scene_Save
  alias kts_write_save_data write_save_data
  def write_save_data(file)
    kts_write_save_data(file)
    Marshal.dump($kts, file)
  end
end

class Scene_Load
  alias kts_read_save_data read_save_data
  def read_save_data(file)
    kts_read_save_data(file)
    $kts = Marshal.load(file)
  end
end


And well, honestly, I just feel like if it was made FOR XP, and not just me hacking up the script until it functions as I need it, mayhaps the world could utilize this script as well as me :D

Just a thought.



I have 2 questions about this :

Does it reads the actual Time setted up on the PC or just you configuring the scrip ?
Is this 100% compatible with XP ?
Title: Re: [XP] Advanced Time and Environment System
Post by: lilbrudder917 on February 07, 2010, 01:37:28 am
Quote from: elementisland on February 06, 2010, 12:01:52 pm
Quote from: jragyn00 on February 02, 2010, 05:54:01 am
Could this script be modified in some way to project REAL time into the game, versus implanted 5 minute days, 5 minute nights (or whatever they are set to)?

I currently use a script I butchered and modified for use from VX...for XP!
Spoiler: ShowHide
#==============================================================================
# � Kylock's Time System VX 1.5 MOD V.1.1
#     6.3.2008                 30.5.2009
#------------------------------------------------------------------------------
#  Script by: Kylock
#  MOD by reijubv
#===============================================================================
# Credit mainly goes to Kylock
# and then.  reijubv
# (Cuz I think I deserve something better than just a "thanks"..)
# Have a nice day!
#===============================================================================
# ? Auto-tone Instructions
#------------------------------------------------------------------------------
#    Maps designated as outdoors are the only maps to be affected by this
#  scripts use of auto-toning.  To signify a map to be "outdoors", you must
#  include [KTS] In the name of the map.  For example, you world map could be
#  named "World Map [KTS]" or "[KTS] World Map".  Provisions are made later in
#  the script to remove [KTS] from the map name when it's read by another
#  script.  This means that "[KTS]" won't show up in your Map Name Popup
#  windows.
#==============================================================================
# ? Game Database Setup
#------------------------------------------------------------------------------
#    This script, by defult, uses the following game variables and switches:
#  Database Variables:
#    [1] The Current Time
#    [2] The Current Second
#    [3] The Current Minute
#    [4] The Current Hour
#    [5] The Current Day
#    [6] Name of the Current Day (abbreviated)
#    [7] The Current Day index in one week (0-6) a week starts from sunday
#    [8] The Current Month
#    [9] The Current Month's name (abbreviated)
#    [10]The Current Day Id in this Month (1-32,or 1-30,or 1-29)
#    [11]The Current Year
#    [12]Season's name
#    [13]Weather's Name
#    [14]Weather Id, 0 is clear weather..
#  Database Switches
#    [1] ON during night hours   (2200-0400)(10pm-4am)
#    [2] ON during dawn hours    (0500-0800)( 5am-8am)
#    [3] ON during daytime hours (0900-1800)( 9am-6pm)
#    [4] ON during sunset hours  (1900-2100)( 7pm-9pm)
#    [5] ON during spring season
#    [6] ON during summer season
#    [7] ON during fall season
#    [8] ON during winter season
#==============================================================================

$kylockTIME = true


#==============================================================================
# Stores variables and user defined settings for the time system.
#==============================================================================
module KTS
  #-----------------------------------------------------------------------
  # Settings for Time Periods
  #-----------------------------------------------------------------------
  T1 = [ 0,4 ] # Night         # Sets time periods for tinting effects
  T2 = [ 5,8 ] # Dawn          # [Start Hour, End Hour] for time period
  T3 = [ 9,17] # Day           # Use 24-hour values for time periods
  T4 = [18,21] # Sunset
  T5 = [22,24] # Night         # <- Ex: Night is between 23:00 and 24:00
  #-----------------------------------------------------------------------
  # Settings for Output to Game Variables option.
  #-----------------------------------------------------------------------
  # Set this to true to output the current time to game variables.
  DATABASE_OUTPUT = true 
    # Game Variable to be used for time output.
    TIME    = 12 #(Time in string format. Ex: "2:48 AM" or "02:48")
    SECONDS = 13 # 1 to 59
    MINUTES = 14 # 1 to 59
    HOURS   = 15 # 1 to 24
    DAYS    = 16 # 1 to 366
    DAYNAME = 17 # Sun, Mon, etc..
    WEEKDAY = 18 # 0 to 6 (Day index in one week)
    MONTH   = 20 # 1 to 12
    MONTHNAM= 19 # Jan, Feb, May, etc..
    MONTHDAY= 21# 1 to 31
    YEAR    = 22# 1994, 2009, etc
    SEASON  = 23# Season Name (Spring, Summer, Fall, Winter)
    WEATHERN= 24# Weather's name
    WEATHER = 25# Weather Id, 0 is clear weather
   
    # Game Switches to be used for time output.
    NIGHT   = 55 # This switch is on during night hours   (2200-0400)(10pm-4am)
    DAWN    = 56 # This switch is on during dawn hours    (0500-0800)( 5am-8am)
    DAY     = 57 # This switch is on during daytime hours (0900-1800)( 9am-6pm)
    SUNSET  = 58 # This switch is on during sunset hours  (1900-2100)( 7pm-9pm)

    # Season Switches.
    SPRING  = 59 # This switch is on during spring season
    SUMMER  = 60 # This switch is on during summer season
    FALL    = 61 # This switch is on during fall season
    WINTER  = 62 # This switch is on during winter season
  #-----------------------------------------------------------------------
  # Settings for time controlled screen toning
  #-----------------------------------------------------------------------
  # True will enable screen toning to be used by the script.
  USE_TONE = true
  # Sets the duration of tone changes (in frames)
  FADE_LENGTH = 240
  # Defines tones to be used in the corresponding time periods defined above.
  #              RED, GREEN, BLUE, GREY
  C1 = Tone.new(-187,  -119,  -17,  68)
  C2 = Tone.new(  17,   -51, -102,   0)
  C3 = Tone.new(   0,     0,    0,   0)
  C4 = Tone.new( -68,  -136,  -34,   0)
  C5 = Tone.new(-187,  -119,  -17,  68)
  # Defines anti-tones
  A1 = Tone.new( 187,   119,   17, -68)
  A2 = Tone.new( -17,    51,  102,   0)
  A3 = Tone.new(   0,     0,    0,   0)
  A4 = Tone.new(  68,   136,   34,   0)
  A5 = Tone.new( 187,   119,   17, -68)
  #-----------------------------------------------------------------------
  # MOD
  #-----------------------------------------------------------------------
  #-----------------------------------------------------------------------
  # Settings for season periods
  #-----------------------------------------------------------------------
  S1 = [1,3]  # Spring        # Sets month periods for season system
  S2 = [4,6]  # Summer        # [Start Month, End Month] for time period
  S3 = [7,9] # Fall          #
  S4 = [10,12] # Winter        # <- Ex: Winter is between 10th - 12th (Oct - Dec)
  # Use automatic weather?
  WEATHER_SYSTEM = true
  # Sets the duration of weather changes (in frames)
  WEATHER_LENGTH = 240
  # Time before changing weather (in hours)
  WEATHER_COOLDOWN = 3
  # Weather names (Must be the same order as weather's Id) adds as many as required
  #                   0       1        2         3
  WEATHER_NAME = ["Clear", "Rain" , "Storm" , "Snowy"] # VX default only have these 3
  #-----------------------------------------------------------------------
  # Settings for possible weather
  # To add more weathers, just add more weather ids there
  # ex = W[#] = [ WeatherId, .....]
  # S[#] means, season number #
  # Weathers only occurs when entering map with [KTS] on it's name.
  # Those weathers will be randomly occurs, but snowy weather only spawns
  # during Winter.
  #-----------------------------------------------------------------------
  W = {}
  W[1] = [0, 1, 2 ] # [ WeatherId, .....]
  W[2] = [0, 1, 2 ] # [ WeatherId, .....]
  W[3] = [0, 1, 2 ] # [ WeatherId, .....]
  W[4] = [0, 1, 3 ] # [ WeatherId, .....]
  #-----------------------------------------------------------------------
  # Settings for weather bgs
  # WeatherId => "filename", file must be in Audio/BGS/ folder
  #-----------------------------------------------------------------------
  WEATHERSOUND_OK = true
  # If true, setup the BGS on line 385
  # Remember. BGS only changes when you enter/exit a map, but weather can change
  # even if you stay inside a map for a long time....
end

#==============================================================================
# Core Time System Engine (MODDED)
#==============================================================================
class Kylock_Time_System
  if $kylockTIME = true
  # sets instance variables
  def initialize
    $kts_map_data = load_data("Data/MapInfos.rxdata")
    @event_offset = (Time.now.strftime("%H").to_i * 3600) + (Time.now.strftime("%w").to_i * 86400)
    $kts_event_tone = false
    $kts_event_weather = false
    $kts_battle_tone = true
    $kts_anti_tone = Tone.new(0,0,0,0)
    @startingweatherdelay = 0
    @curweather = 0
    @played = false
  end
  # Computes current time and updates variables if used
  def update
    if !@kts_stop
      # for scripters
      @total_seconds = Graphics.frame_count + @event_offset
      @total_minutes = @total_seconds / 60
      @total_hours = @total_minutes / 60
      @total_days = @total_hours / 24
      @total_weeks = @total_days / 7
      @total_months = @total_weeks / 4
      @total_years = @total_months/12
      #
      @seconds = Time.now.sec
      @minutes = Time.now.min
      @hours   = Time.now.hour
      @days    = Time.now.strftime("%j").to_i
      @weekday = Time.now.strftime("%w").to_i
      @month = Time.now.strftime("%m").to_i
      @monthname = Time.now.strftime("%b")
      @monthday = Time.now.strftime("%d")
      @year = Time.now.strftime("%Y").to_i
      update_tint
      update_weather
      if KTS::DATABASE_OUTPUT
        $game_variables[KTS::TIME]    = getTime
      end
    end
  end
  #
  def update_variables
    $game_variables[KTS::SECONDS] = @seconds
    $game_variables[KTS::MINUTES] = @minutes
    $game_variables[KTS::HOURS]   = @hours
    $game_variables[KTS::DAYS]    = @days
    $game_variables[KTS::DAYNAME] = getDayName
    $game_variables[KTS::WEEKDAY] = @weekday
    $game_variables[KTS::MONTH] = @month
    $game_variables[KTS::MONTHNAM] = @monthname
    $game_variables[KTS::YEAR] = @year
    if KTS::WEATHER_SYSTEM == true
      $game_variables[KTS::WEATHER] = $game_screen.weather_type #@weather
    if $game_variables[25] == 0
      $game_variables[KTS::WEATHERN] = "Clear" #getWeatherName
    elsif $game_variables[25] == 1
      $game_variables[KTS::WEATHERN] = "Raining" #getWeatherName
    elsif $game_variables[25] == 2
      $game_variables[KTS::WEATHERN] = "Deluge" #getWeatherName
    elsif $game_variables[25] == 3
      $game_variables[KTS::WEATHERN] = "Snowy" #getWeatherName
    end
    end
    $game_variables[KTS::SEASON] = getSeasonName
    $game_variables[KTS::MONTHDAY] = @monthday
  end
  #
  def update_switches
    if @period == 1 || @period == 5
      $game_switches[KTS::NIGHT] = true
    else
      $game_switches[KTS::NIGHT] = false
    end
    if @period == 2
      $game_switches[KTS::DAWN] = true
    else
      $game_switches[KTS::DAWN] = false
    end
    if @period == 3
      $game_switches[KTS::DAY] = true
    else
      $game_switches[KTS::DAY] = false
    end
    if @period == 4
      $game_switches[KTS::SUNSET] = true
    else
      $game_switches[KTS::SUNSET] = false
    end
  end
  #
  def update_season_swithces
    if @month >= KTS::S1[0] and @month <= KTS::S1[1]
      @speriod = 1
      $game_switches[KTS::SPRING] = true
    else
      $game_switches[KTS::SPRING] = false
    end
    if @month >= KTS::S2[0] and @month <= KTS::S2[1]
      @speriod = 2
      $game_switches[KTS::SUMMER] = true
    else
      $game_switches[KTS::SUMMER] = false
    end
    if @month >= KTS::S3[0] and @month <= KTS::S3[1]
      @speriod = 3
      $game_switches[KTS::FALL] = true
    else
      $game_switches[KTS::FALL] = false
    end
    if @month >= KTS::S4[0] and @month <= KTS::S4[1]
      @speriod = 4
      $game_switches[KTS::WINTER] = true
    else
      $game_switches[KTS::WINTER] = false
    end
  end
  #-----------------------------------------------------------------------
  # Script Support/Misc Functions (MODDED)
  #-----------------------------------------------------------------------
  def getTime
    time = Time.now.strftime("%H:%M %p")
    return time
  end
  def getSeasonName
    sname = "Spring" if @speriod == 1
    sname = "Summer" if @speriod == 2
    sname = "Fall"   if @speriod == 3
    sname = "Winter" if @speriod == 4
    return sname
  end
  def getMonthName
    monthname = Time.now.strftime('%b')
    return monthname
  end
  def getDayName
    weekday = Time.now.strftime('%a')
    return weekday
  end
  def getWeatherName
#    weathername = KTS::WEATHER_NAME[@weather]
#    return weathername
  end
 
  #-----------------------------------------------------------------------
  # Screen Tone Functions
  #-----------------------------------------------------------------------
  def update_tint(duration = KTS::FADE_LENGTH)
    return if $BTEST
    if KTS::USE_TONE && !$kts_event_tone && $kts_map_data[$game_map.map_id].outside_tint?
      if @hours >= KTS::T1[0] and @hours <= KTS::T1[1]
        @period = 1   
        $game_screen.start_tone_change(KTS::C1,duration)
        $kts_anti_tone = KTS::A1
      elsif @hours >= KTS::T2[0] and @hours <= KTS::T2[1]
        @period = 2
        $game_screen.start_tone_change(KTS::C2,duration)
        $kts_anti_tone = KTS::A2
      elsif @hours >= KTS::T3[0] and @hours <= KTS::T3[1]
        @period = 3
        $game_screen.start_tone_change(KTS::C3,duration)
        $kts_anti_tone = KTS::A3
      elsif @hours >= KTS::T4[0] and @hours <= KTS::T4[1]
        @period = 4
        $game_screen.start_tone_change(KTS::C4,duration)
        $kts_anti_tone = KTS::A4
      elsif @hours >= KTS::T5[0] and @hours <= KTS::T5[1]
        @period = 5
        $game_screen.start_tone_change(KTS::C5,duration)
        $kts_anti_tone = KTS::A5
      end
    else
      # no tone if indoors
        if !$kts_map_data[$game_map.map_id].outside_tint?
          $game_screen.start_tone_change(Tone.new(0,0,0,0),duration)
        end
    end
  end
  # Set weather
  def setweather(duration)
    if ((@startingweatherdelay - @hours) >= KTS::WEATHER_COOLDOWN) or
       ((@startingweatherdelay - @hours) <= -KTS::WEATHER_COOLDOWN)
      @startingweatherdelay = Time.now.hour
      the_weatherset = KTS::W[@speriod]
      @curweather = the_weatherset[rand(KTS::W[@speriod].length)]
      @weather = @curweather
    else
      @weather = @curweather
    end
    $game_screen.weather(@weather, 9 , duration)
  end
   
  #-----------------------------------------------------------------------
  # Season/weather update
  #-----------------------------------------------------------------------
  def update_weather(duration = KTS::WEATHER_LENGTH)
    return if $BTEST
    if KTS::WEATHER_SYSTEM && !$kts_event_weather && $kts_map_data[$game_map.map_id].outside_tint?
      if @month >= KTS::S1[0] and @month <= KTS::S1[1]
        @speriod = 1
      elsif @month >= KTS::S2[0] and @month <= KTS::S2[1]
        @speriod = 2
      elsif @month >= KTS::S3[0] and @month <= KTS::S3[1]
        @speriod = 3
      elsif @month >= KTS::S4[0] and @month <= KTS::S4[1]
        @speriod = 4
      end
      setweather(duration)
    else
      # no weather if indoors
        if !$kts_map_data[$game_map.map_id].outside_tint?
          Audio.bgs_stop #Stop BGS
          $game_screen.weather(0, 0, 0)
        end
    end
  end
=begin
  def screen
    if $game_temp.in_battle
      return $game_troop.screen
    else
      return $game_map.screen
    end
  end
=end
  # Extra Feature; Change BGS
  def start_bgs
    return if !$kts_map_data[$game_map.map_id].outside_tint?
     if $kts_map_data[$game_map.map_id].outside_tint?
      if  KTS::WEATHER_SYSTEM == true
        if KTS::WEATHERSOUND_OK == true
          if @weather == 1
            Audio.bgs_play("Audio/BGS/Rain", 70, 100)
          elsif @weather == 2
            Audio.bgs_play("Audio/BGS/Storm", 70, 100)
            # ADD MORE IF YOU WANT to play BGS when weather with Id @weather occurs!
            # Like this :
            # elsif @weather == Id
            #  Audio.bgs_play("Audio/BGS/SomeBGS", 70, 100)
          else
            Audio.bgs_stop
          end
        end
      end
    end
  end
end
end

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias kts_initialize initialize
  def initialize
    $kts.update_switches if KTS::DATABASE_OUTPUT
    $kts.update_variables if KTS::DATABASE_OUTPUT
    $kts.update_season_swithces if KTS::DATABASE_OUTPUT
    kts_initialize
  end
end

#==============================================================================
# Instantly updates screen tone when a new map is loaded.
#==============================================================================
class Game_Map
  alias kts_setup setup
  def setup(map_id)
    kts_setup(map_id)
    $kts_event_tone = false
    $kts.update
    $kts.update_tint(0)
    $kts.update_weather(0) if KTS::WEATHER_SYSTEM
    $kts.start_bgs
  end
end
=begin
#==============================================================================
# Instantly updates screen tone when a battle starts.
#==============================================================================
class Spriteset_Battle
  alias kts_create_battleback create_battleback
  def create_battleback
    $kts.update_tint(0)
    kts_create_battleback
  end
end

#==============================================================================
# Temporarily disables auto-toning if an event tints the screen.
#==============================================================================
class Game_Interpreter
  alias kts_Interpreter_command_223 command_223
  def command_223
    $kts_event_tone = true
    kts_Interpreter_command_223
  end
  alias kts_Interpreter_command_236 command_236
  def command_236
    $kts_event_weather = true
    kts_Interpreter_command_226
  end
end
=end
#==============================================================================
# Integrates the Time System into the Game System.
#==============================================================================
class Game_System
  # inits a KTS object
  alias kts_initialize initialize
  def initialize
    $kts=Kylock_Time_System.new
    kts_initialize
  end
  # Updates kts every game frame
  alias kts_update update
  def update
    $kts.update
    kts_update
  end
end

#==============================================================================
# Scans Map Names for Toning
#==============================================================================
class RPG::MapInfo
  def name # Definition prevents location scripts from reading anything within
    return @name.gsub(/\[.*\]/) {""} # brackets, including the brackets
  end
  def original_name
    return @name
  end
  def outside_tint?
    return @name.scan(/\[KTS\]/).size > 0
    # old regexp: return @name.scan(/[\KTS]/).size > 0
  end
end
=begin
#==============================================================================
# Sets up the time window for the menu. (MODDED)
#==============================================================================
class Window_KTS < Window_Base
  def initialize(x, y)
    super(x, y, 160, WLH+32)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.draw_text(0, -6, 120, 32,$kts.getDayName+" "+$kts.getTime, 2)
  end
  def update
    super
    $kts.update
    self.contents.clear
    self.contents.draw_text(0, -6, 120, 32, $kts.getDayName+" "+$kts.getTime, 2)
  end
end

#==============================================================================
# Adds the time window to the menu.
#==============================================================================
class Scene_Menu < Scene_Base
  alias kts_start start
  def start
    kts_start
    @kts_window = Window_KTS.new(0,304)
  end
  alias kts_terminate terminate
  def terminate
    kts_terminate
    @kts_window.dispose
  end
  alias kts_update update
  def update
    kts_update
    @kts_window.update
  end
end
=end
#==============================================================================
# Saves and Loads game time to/from save game file.
#==============================================================================
class Scene_Save
  alias kts_write_save_data write_save_data
  def write_save_data(file)
    kts_write_save_data(file)
    Marshal.dump($kts, file)
  end
end

class Scene_Load
  alias kts_read_save_data read_save_data
  def read_save_data(file)
    kts_read_save_data(file)
    $kts = Marshal.load(file)
  end
end


And well, honestly, I just feel like if it was made FOR XP, and not just me hacking up the script until it functions as I need it, mayhaps the world could utilize this script as well as me :D

Just a thought.



I have 2 questions about this :

Does it reads the actual Time setted up on the PC or just you configuring the scrip ?
Is this 100% compatible with XP ?

Spoiler: ShowHide

       @seconds = Time.now.sec 
      @minutes = Time.now.min
      @hours   = Time.now.hour
      @days    = Time.now.strftime("%j").to_i
      @weekday = Time.now.strftime("%w").to_i
      @month = Time.now.strftime("%m").to_i
      @monthname = Time.now.strftime("%b")
      @monthday = Time.now.strftime("%d")
      @year = Time.now.strftime("%Y").to_i

    $game_variables[KTS::SECONDS] = @seconds
    $game_variables[KTS::MINUTES] = @minutes
    $game_variables[KTS::HOURS]   = @hours
    $game_variables[KTS::DAYS]    = @days
    $game_variables[KTS::DAYNAME] = getDayName
    $game_variables[KTS::WEEKDAY] = @weekday
    $game_variables[KTS::MONTH] = @month
    $game_variables[KTS::MONTHNAM] = @monthname
    $game_variables[KTS::YEAR] = @year


From what I see, it reads the time set up on the PC.
Title: Re: [XP] Advanced Time and Environment System
Post by: Alton Wyte on February 13, 2010, 08:32:44 pm
Quote from: Jackolas on November 21, 2009, 08:11:57 am
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?

Thanks for wanting to help, but I started a new game and now there are no issues.
Title: Re: [XP] Advanced Time and Environment System
Post by: element on March 04, 2010, 02:09:31 pm
Can I use the code breloom showed me in keylocks script in ates.
and if yes can someone show me where to implement this code ?

In other words:
I need to know if i can makes ates work with real time,day year,... set up on PC
Title: Re: [XP] Advanced Time and Environment System
Post by: lilbrudder917 on March 04, 2010, 02:32:28 pm
Quote from: Trainer Element on March 04, 2010, 02:09:31 pm
Can I use the code breloom showed me in keylocks script in ates.
and if yes can someone show me where to implement this code ?

In other words:
I need to know if i can makes ates work with real time,day year,... set up on PC


I'm not 100% sure about this script because I haven't used it, but this is what I like to do.

Spoiler: ShowHide
class RealTime
  def initialize
        @time_stamp = Time.new
          $game_variables[1]        = @time_stamp.strftime("%y").to_i # XX in Year YYXX
          $game_variables[2]        = @time_stamp.strftime("%m").to_i # Jan = 1 cont.
          $game_variables[3]        = @time_stamp.strftime("%W").to_i # Week #, Starts Mon.
          $game_variables[4]        = @time_stamp.strftime("%w").to_i # Day of Week, S Sun.
          $game_variables[5]        = @time_stamp.strftime("%d").to_i # Day of Month
          $game_variables[6]        = @time_stamp.strftime("%H").to_i # 24 Hour
          $game_variables[7]        = @time_stamp.strftime("%I").to_i # 12 Hour
          $game_variables[8]        = @time_stamp.strftime("%M").to_i # 2-Digit Minute
  end
end

RealTime.new


and then in a Common Event...

Spoiler: ShowHide
Conditional Branch : Switch [Inside] is OFF
Conditional Branch : HOURVARIABLE = x to x
Change Screen Color Tone
end Conditional Branch
end Conditional Branch


...Basically, it changes Screen Color Tone if you are outside. When going inside (or in a cutscene), turn the Inside switch on.
Title: Re: [XP] Advanced Time and Environment System
Post by: element on March 06, 2010, 03:44:28 am
Quote from: Breloom Trainer Brudder on March 04, 2010, 02:32:28 pm
Quote from: Trainer Element on March 04, 2010, 02:09:31 pm
Can I use the code breloom showed me in keylocks script in ates.
and if yes can someone show me where to implement this code ?

In other words:
I need to know if i can makes ates work with real time,day year,... set up on PC


I'm not 100% sure about this script because I haven't used it, but this is what I like to do.

Spoiler: ShowHide
class RealTime
  def initialize
        @time_stamp = Time.new
          $game_variables[1]        = @time_stamp.strftime("%y").to_i # XX in Year YYXX
          $game_variables[2]        = @time_stamp.strftime("%m").to_i # Jan = 1 cont.
          $game_variables[3]        = @time_stamp.strftime("%W").to_i # Week #, Starts Mon.
          $game_variables[4]        = @time_stamp.strftime("%w").to_i # Day of Week, S Sun.
          $game_variables[5]        = @time_stamp.strftime("%d").to_i # Day of Month
          $game_variables[6]        = @time_stamp.strftime("%H").to_i # 24 Hour
          $game_variables[7]        = @time_stamp.strftime("%I").to_i # 12 Hour
          $game_variables[8]        = @time_stamp.strftime("%M").to_i # 2-Digit Minute
  end
end

RealTime.new


and then in a Common Event...

Spoiler: ShowHide
Conditional Branch : Switch [Inside] is OFF
Conditional Branch : HOURVARIABLE = x to x
Change Screen Color Tone
end Conditional Branch
end Conditional Branch


...Basically, it changes Screen Color Tone if you are outside. When going inside (or in a cutscene), turn the Inside switch on.


Can you make this work in ATES ? Or do you want to show me where to implement it :p
Title: Re: [XP] Advanced Time and Environment System
Post by: lilbrudder917 on March 06, 2010, 09:22:26 am
Well, when I said
QuoteI'm not 100% sure about this script because I haven't used it


I was referring to ATES. I'll attempt to make a plugin if nobody else is up to it.

EDIT: I just opened up a new project to try it out.

On line 309, replace:
@time = ATES::Time.new(0,0)

with
@time = Time.new


and it'll use real time from the internal clock.

EDIT2: It won't update on its own, though.
Title: Re: [XP] Advanced Time and Environment System
Post by: element on March 06, 2010, 02:44:37 pm
Jheej ! it gives the real time for 1 sec !!!  :haha:

And then it gives me a error like you said
Quote from: Breloom Trainer Brudder on March 06, 2010, 09:22:26 am
EDIT2: It won't update on its own, though.


I'm totally requesting this XD
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on March 08, 2010, 02:51:23 am
Quote from: Breloom Trainer Brudder on March 06, 2010, 09:22:26 am
EDIT2: It won't update on its own, though.


If you change line 325, it will.

@frame_count += 1


@time = Time.now


BTW, Time.new and Time.now do the same. I prefer .now because it's more descriptive of what it actually does.
Title: Re: [XP] Advanced Time and Environment System
Post by: lilbrudder917 on March 08, 2010, 07:07:32 am
Uh.. you sure about that, Blizzard? I just tried that out, the clock didn't change.

Also, I know Time.new and Time.now are the same.

EDIT: Ah, it's because @active is false by default. But when I changed it to true, it crashed.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on March 08, 2010, 10:40:48 am
Then the other method that's being called when @active is one should be disabled.
Title: Re: [XP] Advanced Time and Environment System
Post by: lilbrudder917 on March 08, 2010, 03:44:29 pm
Quote from: Champion Blizzard on March 08, 2010, 10:40:48 am
Then the other method that's being called when @active is one should be disabled.


There's only one method that's being called when @active is on. There is no other one.

Anyway, I found out how to make it automatically update.

Spoiler: ShowHide

  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 ATES.active? && $game_system.ates.frame_count % 40 == 0
    elsif @clock != nil
      @clock.dispose
      @clock = nil
    end
  end


to

  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.bitmap.clear
      @clock.draw if ATES.active? && Time.sec == 0
    elsif @clock != nil
      @clock.dispose
      @clock = nil
    end
  end


and

Spoiler: ShowHide

def update
    if @active
      update_progress
      update_ates_progress
    end
    update_switches
    update_screen
  end


to

  def update
    @time = Time.new
    Clock_Sprite.new
    if @active
      update_progress
      update_ates_progress
    end
    update_switches
    update_screen
  end


There's probably a different way to do it. That's just one I got working.
Title: Re: [XP] Advanced Time and Environment System
Post by: element on March 09, 2010, 01:58:38 am
It works !
Initially it didn't but then I removed the parralel event that turns on ATES
Dous that mean that coloring doesnt work ?
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on March 09, 2010, 02:45:07 am
CONGRATULATIONS! YOU JUST CAUSED A HEAVY MEMORY LEAK.

Clock_Sprite.new will make your game run so slowly so quickly that you won't even realize what hit you. You're instantiating a sprite there each frame, you're not destroying it and you're not even storing it into a variable.

    if @active # condition check
     update_progress # first method
     update_ates_progress # second method
   end # maybe you wanna count again just to be sure
Title: Re: [XP] Advanced Time and Environment System
Post by: Magus on March 09, 2010, 07:03:36 pm
I have a question:

What happens if the character is in the inside of a building, especially a lit up one. Is there anyway you can adjust it to temporarily turn off  the script when a character walks inside a building.
Title: Re: [XP] Advanced Time and Environment System
Post by: Alton Wyte on March 09, 2010, 07:08:47 pm
Quote

#     ATES.tint_on
#   Turns ATES's screen tinting on.
#
#     ATES.tint_off
#   Turns ATES's screen tinting off.
Title: Re: [XP] Advanced Time and Environment System
Post by: lilbrudder917 on March 09, 2010, 08:05:03 pm
Quote from: Champion Blizzard on March 09, 2010, 02:45:07 am
CONGRATULATIONS! YOU JUST CAUSED A HEAVY MEMORY LEAK.

Clock_Sprite.new will make your game run so slowly so quickly that you won't even realize what hit you. You're instantiating a sprite there each frame, you're not destroying it and you're not even storing it into a variable.

    if @active # condition check
     update_progress # first method
     update_ates_progress # second method
   end # maybe you wanna count again just to be sure



Odd, my game didn't lag much at all and used just as much memory as it normally does.

Also, I misunderstood you when you said the other method. I thought you meant elsewhere in the script it checks if @active = true. In any case, sorry.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on March 10, 2010, 03:00:52 am
No problem. Just make sure to double check next time. When I look for the appearance of a variable, I check for @variable, .variable and :variable. :)
Title: Re: [XP] Advanced Time and Environment System
Post by: happyman on August 10, 2010, 02:25:24 pm
How can I set up this script so that I call a common event at midnight?

I want everything to pause and the screen to fade to black, where big words say "Day 2" or something like that.  Also, certain variables in my game will change at this time.  Right now I have a parallel common event, but it's slowing down my game because it's constantly checking for midnight.  Obviously, this is stupid, so I would like the script to call a common event at midnight.

Or is there a better way?
Title: Re: [XP] Advanced Time and Environment System
Post by: stripe103 on August 10, 2010, 02:40:25 pm
I don't think that is possible to do. So it is either a parallel common event or a script that checks instead of the common event. It may be less laggy, but I'm not sure. That would be a script like this

# The id for the common event that is going to start
EVENT = 1
class Scene_Map
 alias :ori_update :update
 def update
   if $game_system.ates.time.hour == 0 && $game_system.ates.time.min == 0
      common_event = $data_common_events[EVENT]
      $game_system.map_interpreter.setup(common_event.list, 0)
    end
   ori_update
 end
end

I don't know if it works, but I think it does. But I don't know if it is less laggy.
Title: Re: [XP] Advanced Time and Environment System
Post by: happyman on August 25, 2010, 03:01:23 pm
I realized that my game isn't laggy because it's constantly checking for midnight. It's laggy because I have too many parallel common events running at the same time (Just 3, but apparently that's enough).

So, about this bit of script you posted...  I knew it would be just a few lines, and it looks good.  Would this be an entirely new script (that I post under MAIN), or do I plug it into the ATES script somewhere?  And if I wanted to call common event number 2 at midnight, what do I have to edit?
Title: Re: [XP] Advanced Time and Environment System
Post by: stripe103 on August 26, 2010, 09:51:47 am
It should be inserted in a new script section below ATES.
The second line (EVENT = 1) change it into what common event you would like to run.
Title: Re: [XP] Advanced Time and Environment System
Post by: happyman on August 26, 2010, 03:05:17 pm
It works!  Yay!  Thanks Stripe!
Title: Re: [XP] Advanced Time and Environment System
Post by: ojp2010 on August 26, 2010, 09:58:08 pm
I installed the script runs fine. However, I can't get the clock not to show. I am using ATES and the RMX-OS addon for it. Also the screen doesn't change tint from night to day. When the game starts up the screen is tinited for night, but it never changes, anyone help me?
Title: Re: [XP] Advanced Time and Environment System
Post by: Magus on September 24, 2010, 09:39:01 pm
Okay, maybe this question was asked before, but I can't find it in the thread. (So, I guess it doesn't hurt to ask anyone a simple question; after all, its just a question and its not hurting anything xD)

Question:   Okay, this thing is beyond amazing, however, the counter on the clock is counting by "20's"  I really wouldn't mind slowing down the time. Like maybe have it count by one's or two's. ANYTHING is better than having a "20 second day and 3 second night :/"

I tried increasing the "length" but of course found out that was a bad idea since the counter didn't go beyond 23 and so that idea destroyed night and caused it to flash a strange yellow.

So anyway... I'd rather have  longer times... May I ask of anyone's assistance please? Thanks very much ^_^
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on September 25, 2010, 03:47:51 am
Make sure that you properly configured everything. It seems to me that you didn't configure everything properly. Read the instructions again and see which option does what.
Title: Re: [XP] Advanced Time and Environment System
Post by: Magus on September 25, 2010, 03:45:10 pm
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# 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 = 70
 # how much time is it when the "day" starts
 DAY_START = 1
 # how much time is it when the "night" starts
 NIGHT_START = 40
 # 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


^That's how I thought it could be set up, but the 36 rule is absolute, which makes it impossible to have longer days and longer nights
Title: Re: [XP] Advanced Time and Environment System
Post by: Magus on September 26, 2010, 10:44:26 am
I know double posting fails, but I really wouldn't mind having longer days and night: however, whenever I set the length any longer, the game deletes night.
Title: Re: [XP] Advanced Time and Environment System
Post by: RenegadeNick27 on November 30, 2010, 07:00:30 pm
i am having the same problem. i have it set up so every second, another minute is added to the clock. (+00:01) but every time i start the clock, the screen fills with an solid yellow tint.

Here are my stats

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# 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 = 320
  # how much time is it when the "night" starts
  NIGHT_START = 800
  # makes the screen brighter during "summer" days
  OVERLIGHTING = false
  # makes the screen darker during the night, not recommended
  OVERDARKENING = false
  # display HUD clock
  SHOW_CLOCK = true


I dont know if i have to change the DSWITCH and NSWITCH. how do i fix this so i can see the game in day and night. :???:
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on December 01, 2010, 02:38:45 am
Why do your day and night start at 320:00 and 800:00 hours respectively?
Title: Re: [XP] Advanced Time and Environment System
Post by: RenegadeNick27 on December 01, 2010, 07:05:56 am
WHAT :^_^': i thought that i should have multiplied them the same amount as i did the seconds/per day. do you thin if i change them back to 8 and 20 it will balance out again?
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on December 01, 2010, 10:31:25 am
It should. I set it to hours so it's easier to configure and you don't have to calculate. You can also use 6 and 19 or whatever you like.
Title: Re: [XP] Advanced Time and Environment System
Post by: crow5derlock on July 27, 2011, 12:46:34 am
is there a way to change how fast the game minutes go by in the script? :???:


i apologize if this has already been answered but i'm kinda in a hurry.
Title: Re: [XP] Advanced Time and Environment System
Post by: Andreavnn on April 23, 2012, 10:16:55 pm
I've looked and searched, does the night and day time monsters work with BABS? Sorry to nerco   :facepalm:

*EDIT* Is the time settings real time or game time, there seems to be a lot of discuss about this and I got lost. I am wanting to know because I am going to event random weather condition and fogs for each period and I need to know how long to make the effects last and the wait times.  Unless I am missing something and that can be done with the script. I am still playing with and learning it.
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on April 24, 2012, 01:49:03 pm
It can be real time if you want to (you just have to configure it properly), but I suggest you use game time. Real time in game never worked out too well since people don't usually spend that many hours playing a game. Also, "real time" doesn't take your PC's actual time, it only advanced like real time i.e. a second in the game takes an actual second in real life (as opposed to e.g. a minute in game takes a second in real life).

Day and night time monsters should work with Blizz-ABS if you use the switches that have been assigned in ATES as day and night switches.
Title: Re: [XP] Advanced Time and Environment System
Post by: Andreavnn on April 24, 2012, 01:59:28 pm
Okay, sweet that is what I wanted to know. I will have to play with it when I get home from work. Another quick question when I have monster for Day and Night, when night occurs will the day monster "de-spawn" or disappear from the view of the player? Or will they stay on screen just "sleeping" and not attacking or moving?   
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on April 24, 2012, 02:36:51 pm
That depends on how you implement it. For example, if you want enemies to fall asleep and wake up, you should probably use a common event that inflicts a special "sleep" on all enemies that have certain IDs (i.e. an array of IDs of enemies that sleep during the night) during day and night, depending on the switches. Blizz-ABS has all necessary script calls for you, but it would be good if you asked somebody to put those script calls together as it gets a bit complicated if you want something like this. It's not too difficult, it only requires some careful eventing and obviously the script calls to put a certain set of enemies to sleep or wake them up.
For other enemies, you can just make them vanish. e.g. if you have some ghosts, you can simply put a night switch on them and they will literally disappear during the day. It all depends on how you want things to work.
Title: Re: [XP] Advanced Time and Environment System
Post by: Andreavnn on April 24, 2012, 02:52:58 pm
Thanks Blizz, once I get my enemies made I will make a request. Of course after I try to mess it all up myself first  ;)

*EDIT* So I am looking at something like this. A common event that checks rather ATES.night? (don't remember the actually commands name) is true if so effect all enemies with ID 1-8 with sleep and switch out their events for enemies ID 8-16 then the new enemies will "spawned" in their place. Their place being the normal start point of the day time monsters. Something along those lines? I am going to differently try to do this on my own first.

I can see why this would take very careful eventing.

**EDIT**

This is what I came up with so far, not much and I've tested it yet. Don't think it is correct anyways. Needs a bit of work still, but I need to get the special commands from BABS.

Event of Map
Spoiler: ShowHide
(http://imageshack.us/photo/my-images/703/eventq.png/)


Common Event
Spoiler: ShowHide
(http://imageshack.us/photo/my-images/821/common.png/)


State "Sleep" I named them Night and Day. Night being a state where day monsters are asleep and day being a state where night monsters are asleep.
Spoiler: ShowHide
(http://imageshack.us/photo/my-images/703/state.png/)
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on April 25, 2012, 02:58:17 am
You don't need the first one. Simply use the switches assigned to ATES.

  # switch ID of the "day" switch
  DSWITCH = 51
  # switch ID of the "night" switch
  NSWITCH = 52


As you can see, by default they are #51 and #52. Obviously you can change that to suit your needs.

As for the second event, in Blizz-ABS you can't inflict a state to an enemy like that. Look up in the manual how it's done.

And you only need one state for sleep during day and night since it does the same thing.
Title: Re: [XP] Advanced Time and Environment System
Post by: Andreavnn on April 25, 2012, 10:03:42 am
I see, seems I over complicated things. Okay I will double check the manual.

*EDIT* I got it to work! Thanks I do have a question, can I make the switch between monsters "fade" out? When the switch flips and I have the re-spawn  ID array in the event name will the monster re-spawn at the spawn point out just change where ever it is as on the map? I am going to test while I wait. :) Thanks blizz, I feel I might make things more complicated then they seem cause they can't be that easy to do. Never the less you make everything easy  :^_^':
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on April 25, 2012, 10:20:39 am
Fading is a lot more complicated than just making them appear/disappear, because you have to use the switches for something else and then manually remove enemies, etc.. This here is straight-forward and the simplest way. But it's up to you.
Title: Re: [XP] Advanced Time and Environment System
Post by: Andreavnn on April 25, 2012, 10:24:33 am
Is that might be something I want to tickle later or leave out for the moment. Alright, is there a special command to make if when D or N switch is flipped that the monster will pop at respawn point inside of just changing?
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on April 25, 2012, 10:35:25 am
Not really, no. As I said, fading and extra stuff like that requires more complicated eventing. It's up to you whether you want to try it or not.
Title: Re: [XP] Advanced Time and Environment System
Post by: Andreavnn on April 25, 2012, 10:39:54 am
Okay thanks Blizz!

*EDIT* Is there a way to add a ATES.morning and evening? I am wanting to make a event sundial that changes when the switches are flipped.

Spoiler: ShowHide
http://forum.chaos-project.com/index.php/topic,11753.msg165247.html#new (http://forum.chaos-project.com/index.php/topic,11753.msg165247.html#new)
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on April 27, 2012, 07:26:54 pm
Add this below ATES:

module ATES
 
 def self.morning?
   $game_system.ates.morning?
 end
 
 def self.evening?
   $game_system.ates.evening?
 end
 
end

class Game_ATES
 
 def morning?
   return (@time.hour.between?(ATES::DAY_START - 2, ATES::DAY_START + 2))
 end
 
 def evening?
   return (@time.hour.between?(ATES::NIGHT_START - 2, ATES::NIGHT_START + 2))
 end
 
end


This script is specific for days from 8 AM to 8 PM and might not work well with other times. Feel free to adjust them.
Title: Re: [XP] Advanced Time and Environment System
Post by: Andreavnn on April 27, 2012, 07:40:15 pm
Thanks Blizz,  here is what I have right now and I the pictures for morning and evening aren't showing up and night and day are being eased. They just keep posting over each other again, again and again. :/

Spoiler: ShowHide
(http://imageshack.us/photo/my-images/205/12184096.png/)


Spoiler: ShowHide
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# 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 = 37
  # 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 = false
  # makes the screen darker during the night, not recommended
  OVERDARKENING = false
  # display HUD clock
  SHOW_CLOCK = false
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Title: Re: [XP] Advanced Time and Environment System
Post by: Blizzard on April 28, 2012, 04:12:46 am
Your conditions will never be fulfilled as either NIGHT or DAY will capture it previously. Put the morning? and evening? conditions first and the DAY and NIGHT conditions in the else branch.
Title: Re: [XP] Advanced Time and Environment System
Post by: Andreavnn on April 28, 2012, 11:25:18 am
Thank you Blizz always the best! +1