Vlue 270 Posted April 28, 2012 (edited) Basic Game Time + Night/Day v1.6 by V.M. Introduction Provides a series of functions to set and recall a new variable known as game time, as well custom tints based on current game time to give the appearance of night and day. Features - Game Time, complete with unfancy little clock - Night and Day cycle with custom tints and timing Screenshots How to Use Plug and play and customize if needed Script Convenient Pastebin: Here Click here instead if you want to go that extra mile: Here FAQ None at the moment Credit and Thanks - By V.M. - Free to use in any project with credit given Author's Notes Hopefully nothing explodes V1.6: Added function to hide and show clock with script call V1.5: Added functions to stop time or tinting V1.4: Fixed bug where toggling game clock with it unused would crash game Edited August 5, 2012 by Vlue 24 david yu, rapture, esrann and 21 others reacted to this Share this post Link to post Share on other sites
odd boy 2 Posted April 28, 2012 Is it possible to turn off the tint or the clock at the game using a script call? I don't see any instruction about that in the script. Share this post Link to post Share on other sites
Vlue 270 Posted April 28, 2012 Is it possible to turn off the tint or the clock at the game using a script call? I don't see any instruction about that in the script. Tint yes, clock no! Or that was the case, however I just edited it. It's under the script calls up the top, the instructions that is. For ease tho, the commands are GameTime::pause_tint(true/false) and GameTime::clock(true/false) Share this post Link to post Share on other sites
odd boy 2 Posted April 28, 2012 Sweet~ I want to try it...but I can't right now... Anyway, Thanks for add that features 1 Vlue reacted to this Share this post Link to post Share on other sites
Plebian 1 Posted April 28, 2012 Woooooo! A day/night script! Gonna try as soon as I finish Zelda melody 3 1 Vlue reacted to this Share this post Link to post Share on other sites
Maus Merryjest 17 Posted April 28, 2012 I LOVE this script, it's awesome! I've got one small question as to how to implement something, though: I'm using Khas' lighting effects for this game. They require for this to be called so that the lights are visible: s = $game_map.effect_surface s.change_color(120,0,0,0,150) How can I implement that to your script so that every time midnight comes around, that happens as well, and when sunrise comes, it is lifted? This is the only way in which I could make, say, those lamp lights appear as darkness seeps in. Share this post Link to post Share on other sites
Vlue 270 Posted April 28, 2012 (edited) I LOVE this script, it's awesome! I've got one small question as to how to implement something, though: I'm using Khas' lighting effects for this game. They require for this to be called so that the lights are visible: s = $game_map.effect_surface s.change_color(120,0,0,0,150) How can I implement that to your script so that every time midnight comes around, that happens as well, and when sunrise comes, it is lifted? This is the only way in which I could make, say, those lamp lights appear as darkness seeps in. Not the first person to ask that! You can put this below my script to make it work with Khas: module GameTime def self.init $game_time = 0 $game_time_surface = $game_map.effect_surface end def self.tint(tint = 60) if USE_TINT != true then return end for i in NOTINTMAPS if $game_map.map_id == i $game_map.effect_surface.change_color(0,10,10,10,25) return end end if SceneManager::scene_is?(Scene_Map) then else return end case $game_time when PRESUNRISE_TIME .. SUNRISE_TIME $game_map.effect_surface.change_color(tint,PRESUNRISE_TONE.red,PRESUNRISE_TONE.green,PRESUNRISE_TONE.blue,PRESUNRISE_TONE.gray) when SUNRISE_TIME .. NOONSTART_TIME $game_map.effect_surface.change_color(tint,SUNRISE_TONE.red,SUNRISE_TONE.green,SUNRISE_TONE.blue,SUNRISE_TONE.gray) when NOONSTART_TIME .. NOONEND_TIME $game_map.effect_surface.change_color(tint,NOONSTART_TONE.red,NOONSTART_TONE.green,NOONSTART_TONE.blue,NOONSTART_TONE.gray) when NOONEND_TIME .. PRESUNSET_TIME $game_map.effect_surface.change_color(tint,NOONEND_TONE.red,NOONEND_TONE.green,NOONEND_TONE.blue,NOONEND_TONE.gray) when PRESUNSET_TIME .. SUNSET_TIME $game_map.effect_surface.change_color(tint,PRESUNSET_TONE.red,PRESUNSET_TONE.green,PRESUNSET_TONE.blue,PRESUNSET_TONE.gray) when SUNSET_TIME .. 1440 $game_map.effect_surface.change_color(tint,SUNSET_TONE.red,SUNSET_TONE.green,SUNSET_TONE.blue,SUNSET_TONE.gray) when 0 .. MIDNIGHT_TIME $game_map.effect_surface.change_color(tint,SUNSET_TONE.red,SUNSET_TONE.green,SUNSET_TONE.blue,SUNSET_TONE.gray) when MIDNIGHT_TIME .. PRESUNRISE_TIME $game_map.effect_surface.change_color(tint,MIDNIGHT_TONE.red,MIDNIGHT_TONE.green,MIDNIGHT_TONE.blue,MIDNIGHT_TONE.gray) end end end Edited April 28, 2012 by Vlue Share this post Link to post Share on other sites
Maus Merryjest 17 Posted April 28, 2012 Wow, That's amazing Vlue! Thank you! My one last question is: how would one , say, flip on a switch (say, #100, "NightTime") and then remove it when dawn ...er... dawns? That way I can have special encounters that wander around the map that are only found at night, and shop doors wouldn't work past a certain hour. Share this post Link to post Share on other sites
Vlue 270 Posted April 28, 2012 Parallel process common event with a conditional branch using the script call: if GameTime::hour? > ### and GameTime::hour? < ### Replace first ### with the time for night to start and second ### with the time for night to end And switch ON in the first branch and OFF in the else branch(and remember it's in 24 hour clock, so 0-23) Can also be done with any event, oh say shop doors, to only move player during set hours and say it's closed during others. When Dawn Dawns. I want to make that a game name now. Share this post Link to post Share on other sites
Crimexx 13 Posted April 28, 2012 Have you added a way for night-time to not affect certain maps, with say a comment command? Share this post Link to post Share on other sites
Maus Merryjest 17 Posted April 28, 2012 I gave it a try with a common event, but I ended up getting this error message: Script 'Game_Interpreter' line 450: SyntaxError occurred. unexpected $end, expecting keyword_then or';' or'\n' if GameTime::hour? >19 and GameTime::hour> <6 Share this post Link to post Share on other sites
Vlue 270 Posted April 28, 2012 I gave it a try with a common event, but I ended up getting this error message: Script 'Game_Interpreter' line 450: SyntaxError occurred. unexpected $end, expecting keyword_then or';' or'\n' if GameTime::hour? >19 and GameTime::hour> <6 Oh my bad, the if is implied with script calls in conditional branches, so just " GameTime::hour? > 19 and GameTime::hour? < 6 " Share this post Link to post Share on other sites
Maus Merryjest 17 Posted April 29, 2012 That works as far as code goes- but for some reason the switches aren't getting flipped when reaching the hour. I'm going to look and see what might be the problem. Share this post Link to post Share on other sites
Ice Nick 3 Posted April 29, 2012 (edited) I have an odd problem, it seems that my dash is slower after 6pm and before 9am :S. 9am to 6pm is normal dash speed. EDIT: Im using lighting effects from 6pm to 6am. Edited April 29, 2012 by Ice Nick Share this post Link to post Share on other sites
Vlue 270 Posted April 29, 2012 I have an odd problem, it seems that my dash is slower after 6pm and before 9am :S. 9am to 6pm is normal dash speed. EDIT: Im using lighting effects from 6pm to 6am. That's umm... interesting. Only thing this script has in common with the dash function is that the default key for toggling the clock window is same as the dash key. I spent a good few minutes dashing just to see if it would do so, but to no avail. Take a look around for some kind of anomaly. Have you added a way for night-time to not affect certain maps, with say a comment command? There's a Constant in the customization for that You can add an array of maps not to be affected by the tint. Share this post Link to post Share on other sites
Ice Nick 3 Posted April 29, 2012 That's umm... interesting. Only thing this script has in common with the dash function is that the default key for toggling the clock window is same as the dash key. I spent a good few minutes dashing just to see if it would do so, but to no avail. Take a look around for some kind of anomaly. I rebinded the toggle to Q. It goes full speed when in doors or maps without lighting effects, as far as I can tell. It doesn't quiet look like lag but it slows the speed of dash... Im confused lol Share this post Link to post Share on other sites
Vlue 270 Posted April 29, 2012 I rebinded the toggle to Q. It goes full speed when in doors or maps without lighting effects, as far as I can tell. It doesn't quiet look like lag but it slows the speed of dash... Im confused lol You and me both! Share this post Link to post Share on other sites
Plebian 1 Posted April 29, 2012 Out of curiosity, is there a way to set the starting time to some other time rather than 12:00 AM? Also, some of my maps are affected by the tinting but some aren't..... ?_? Share this post Link to post Share on other sites
Ice Nick 3 Posted April 29, 2012 (edited) The commands are in the script lines 7-14 #Usage: Script calls: # GameTime::minute? - returns the current minute # GameTime::hour? - returns the current hour # GameTime::set(time) - sets the game time to time, in frames (max:1440) # GameTime::change(time) - increments the game time! (can be negative) # GameTime::pause_time(set) - stops time for events and stuff, true or false # GameTime::pause_tint(set) - time runs, but tints do not update # GameTime::clock(set) - sets whether clock is visible or not Im not sure about the time, but easiest way I can think of is making an autorun process on starting screen that GameTime::set(time), then remove event and it should be X o'clock at start. For example: Create an event that is Autorun, Script (Page 3) GameTime::set 480. Then remove it, this will set the game to 8 am. Around line 60 you have, #Include the ids of any maps not to be tinted based on time # Usually reserved for indoor maps NOTINTMAPS = [002] This part is "indoors" or caves, the tint will not change, you just set map id in those NOTINTMAPS = [x,x,x,x,x,etc...] Edited April 29, 2012 by Ice Nick Share this post Link to post Share on other sites
Maus Merryjest 17 Posted April 29, 2012 I honestly can't figure out why the common event isn't working. It's set as a parallel process activated by a switch. I flip the switch--- and when 19 hours come around... the Nighttime switch doesn't get flipped Share this post Link to post Share on other sites
odd boy 2 Posted April 29, 2012 Uh...One question again.. How to make the player can't hide the clock.. So exactly like turn off the toggle button.. Well, I'm sorry ask you again about this Share this post Link to post Share on other sites
Maus Merryjest 17 Posted April 29, 2012 (edited) Well, I'm an idiot XD I was sort of sleep deprived, so I guess I didn't catch the logic of the issue before, but now I realize what the problem is: You can't have a value that is both greater than 19 and lesser than 6 at the same time. So actually what I'll need to do is to create two conditional branches, the first one having the values > 19 < 24 and the second one >-1 and < 6. Of course, you run into an issue there, which is: if both branches have an 'off' condition for the switch when conditions aren't met--- that means that one branch's off condition will override another, which is indeed what happened when I ran the test. Still a little sleep-addled, but I'll let you know how i solve the issue when (if) I solve it At first I thought that using => 0 would work, but it errors out when I do that, so I'm trying to find a way around it. =========================================== EDIT: WAHAHA! I got it! Slightly convoluted, but it works! Edited April 29, 2012 by Maus Merryjest Share this post Link to post Share on other sites
Ice Nick 3 Posted April 29, 2012 (edited) Uh...One question again.. How to make the player can't hide the clock.. So exactly like turn off the toggle button.. Well, I'm sorry ask you again about this You want the clock always on, never turned off? Leave Clock toggle with nothing. USE_CLOCK = true CLOCK_POSITION = 4 CLOCK_TOGGLE = @Maus Merrjest, Not sure what you mean, Note that the clock uses a 24 hour time. I have a common event that is called shadows, it creates player shadows when the sun is up, it runs like this. From 6am to 9pm this switch is off. Conditional Branch: Script: GameTime::hour? >= 6 and GameTime::hour? < 21 Script: Shadows on Else Script: Shadows off Branch End Edited April 29, 2012 by Ice Nick Share this post Link to post Share on other sites
Urchreon 9 Posted April 29, 2012 Is it possible to make certain events come out after a certain time? Share this post Link to post Share on other sites
Ice Nick 3 Posted April 29, 2012 (edited) Is it possible to make certain events come out after a certain time? Why yes! Same as my shadow code. I provided another example. Below is the code for having a shop or whatever, appear or open from 9am to 5pm. Conditional Branch: Script: GameTime::hour? >= 9 and GameTime::hour? < 17 Switch 1 On Else Switch 1 Off Branch End Edited April 29, 2012 by Ice Nick Share this post Link to post Share on other sites