Charas-Project

  • Home
  • Help
  • Search
  • Calendar
  • Login
  • Register
*
Please login or register.

Login with username, password and session length
 

News:

New forum theme up and running!



  • Charas-Project »
  • Game Creation »
  • Requests »
  • RPG Maker Programming »
  • Day n Night and Timer Operations
« previous next »
  • Print
Pages: 1 [2] 3

Author Topic: Day n Night and Timer Operations  (Read 12883 times)

Offline evmaster

  • Member
  • Associate
  • *
  • Posts: 231
Re: Day n Night and Timer Operations
« Reply #15 on: August 14, 2012, 07:17:02 PM »
Where should I make the change?
Logged

Offline Natako

  • Queen of Nonsense
  • Exemplar
  • *
  • Posts: 1,012
  • Jack of a few unremarkable trades, master of none.
Re: Day n Night and Timer Operations
« Reply #16 on: August 14, 2012, 07:45:33 PM »
Okay, my following post is going to be confusing. I'm much better at explaining concepts like this with screenshots or lines of "code" than in words.

The way you have it set up now, it's working like real time. In other words, one in-game hour = one IRL hour. What you need to do is cut down on the amount of time it takes for one in-game hour to pass.

When I was working on this last night, I had a similar setup to Prpl's but I only used two variables, one for hours and one for minutes. Each passing second would add +1 to the minute variable, so in other words, a minute IRL would be equivalent to an in-game hour with an entire day comprising of 24 minutes in-game.

The length of an in-game second is determined by that "Wait 1.0 sec" command at the very beginning of the chain as this affects the time delay between each increase of the "Seconds" variable. The minimum value that RPG maker will allow you to enter for that command is 0.1 seconds, so if you were to change that value to its absolute minimum, an in-game minute would be 6 seconds, an in-game hour would be 6 minutes, and a day would be 2 hours and 24 minutes. That's a bit long for a single in-game day, so then again I wouldn't recommend this method unless you really want to have days that are 2 and a half hours long.

I recommend using just two variables - one for hours and one for minutes - instead unless you really want a longer day in your game. Set the Wait command to however much time you want an in-game minute to take (e.g. one second) and have the hours variable increase by one when minutes = 60.

I'll go over Prpl's event code in a bit and see if I can explain a bit more clearly what I'm trying to say. Yeah, I'm bad at explaining things like this lol.
Logged
Retiring the deadlines because I think I've proven that I can get stuff done. It might come on my own time, but it will be better quality that way.

Pants.

Offline Meiscool

  • Staff
  • Exemplar
  • *
  • Posts: 1,138
  • I died for YOUR sins.
Re: Day n Night and Timer Operations
« Reply #17 on: August 14, 2012, 07:49:27 PM »
Take out the seconds I guess... at this point it is kinda of up to personal preference, ya know?

EDIT: Actually, you could change the wait at the top to 0.0 and that might correct the problem.
Logged

Offline evmaster

  • Member
  • Associate
  • *
  • Posts: 231
Re: Day n Night and Timer Operations
« Reply #18 on: August 14, 2012, 08:07:51 PM »
o_o

I just want a short day and night thingy. Kinda like the Harvest Moon one. And have some Npcs be at different places throughout the day.
Logged

Offline Natako

  • Queen of Nonsense
  • Exemplar
  • *
  • Posts: 1,012
  • Jack of a few unremarkable trades, master of none.
Re: Day n Night and Timer Operations
« Reply #19 on: August 14, 2012, 08:52:03 PM »
It's copypasta edit time! Yay!

Taking Prpl's formula, you want to edit it down so it only contains two variables: one for Minutes and one for Hours.

==========

Wait 1.0 seconds
VAR Minutes, +1
IF VAR Minutes >= 60
¤VAR Hours, +1
¤VAR Minutes, = 0
    ELSE
    IF Hours >= 19
      IF Day is ON
      ¤ Hide screen
      ¤ Play sound (like the inn sound)
      ¤ Tint screen (dark blue for that nighty feeling)
      ¤ Switch day: OFF
      ¤ Switch night: ON
      ¤ Show screen
      ELSE
      IF Hours >= 5
        IF Night is ON
        ¤ Hide screen
        ¤ Play sound (like the chicken sound)
        ¤ Tint screen (normal tint)
        ¤ Switch day: ON
        ¤ Switch night: OFF
        ¤ Show screen
        ELSE
        IF Hours = 25
         ¤ VAR hours, = 1
The end

=========
If you edit it down to something like this, it should work and the days would be 24 minutes as opposed to real time.

If you don't like that amount of time for a day, change the Wait 1.0 Seconds to a lower or higher number depending on how long you want the day to be. This amount reflects how long it takes for each in-game minute to pass.

By the way, this is copy-pasted and I tend to miss obvious things when I do that, so feel free to correct me if I overlooked something in Prpl's programming.

As for the NPC's, I'll update with a screenshot showing how to do this since I'm better at explaining with pictures than text.

======

Update: NPC's

Method 1

Here's one method of making NPC's appear at certain times. RPG Maker 2003 only allows you to use one variable as an event precondition, so you wouldn't be able to make an NPC show up at odd times this way (E.g. 7:30, 7:45)...but let's say you wanted an NPC to show up at 7PM and disappear at 5AM. You would want to set your pages up like this.

The first page accounts for 5AM until 7, when the NPC is invisible. The second page accounts for 7-midnight, and the third page accounts for midnight - 5AM.

[spoiler][/spoiler]

[spoiler][/spoiler]

[spoiler][/spoiler]

Of course, depending on your ranges of time, you would have to modify the preconditions. I think this will only work if the transparent NPC is on the first page. I tested with the above pages and it worked perfectly.

Method 2

As for times which aren't right on the hour, I would recommend using switches to make the NPC's appear. You would have to use conditional branches to make the switches turn on and off when hours and minutes reached the proper amounts. You can do this by setting things up the following way:

Let's say we want a certain NPC to show up at 10:30AM and disappear at 3:03PM.

Create a parallel process event for the NPC to show up. Set up like so:

[spoiler][/spoiler]

Now we must create a second event for the NPC in question with two pages. The first page should be a blank sprite, and the second page should contain the NPC sprite and the switch as a precondition.

[spoiler][/spoiler]
[spoiler][/spoiler]

And there you have it. This method is easier than the first, but the problem with it is that you'll have a million events and switches cluttering your game (personal pet peeve of mine, I try to minimize on these things). If that doesn't bother you, go ahead and do this instead because it's probably easier to figure out than the other method I showed you.

And there you have it.
« Last Edit: August 14, 2012, 11:45:36 PM by Natako »
Logged
Retiring the deadlines because I think I've proven that I can get stuff done. It might come on my own time, but it will be better quality that way.

Pants.

Offline Prpl_Mage

  • Administrator
  • Sage
  • *
  • Posts: 7,645
  • The Administrator Mage
    • Check out our itch website
Re: Day n Night and Timer Operations
« Reply #20 on: August 14, 2012, 10:12:54 PM »
Sorry Nat, got one of those laying around and figured it could save you the trouble. Without doubt you seem to have it under control.

Common events (found in the database) works across all maps at all time, useful for stuff that's global.
And Eve, The example was made using real time. So unless you want it to be really slow(like watching grass grow) either remove the part with seconds so that 1 second equals 1 ingame minute. and therefore 1 minuter equals 1 in game hour.
Just like Nat here showed you. I'll let her finish though. See if there's anything left to add then.

Also, to check if stuff is working. Press F9 during test play to check the values of variables and state of switches. Just to see if variables actually get values and such.
« Last Edit: August 14, 2012, 10:47:52 PM by Prpl_Mage »
Logged
Cool RPGM Project!
Sprite till you die

Oh my god, this was ...10 years ago...

Offline Natako

  • Queen of Nonsense
  • Exemplar
  • *
  • Posts: 1,012
  • Jack of a few unremarkable trades, master of none.
Re: Day n Night and Timer Operations
« Reply #21 on: August 14, 2012, 11:42:50 PM »
Quote from: Prpl_Mage on August 14, 2012, 10:12:54 PM
Sorry Nat, got one of those laying around and figured it could save you the trouble.

Was just joking with you, hehe.

Anyway, EV, I updated my "tutorial" of sorts with some screenshots now. If you change your parallel process event for the time to my modified version of purple's, it should prove much more to your liking. As for the NPC's, I listed two methods above: one would only allow you to have NPC's appear/disappear right on the hour but would eliminate a lot of events/switches/clutter from your game, but the second method is much simpler to use and you can have your NPC's appear at any time during the day you wish, although you'll have to make an event and a switch for each NPC in this fashion. Take a look and see what works for you.
Logged
Retiring the deadlines because I think I've proven that I can get stuff done. It might come on my own time, but it will be better quality that way.

Pants.

Offline evmaster

  • Member
  • Associate
  • *
  • Posts: 231
Re: Day n Night and Timer Operations
« Reply #22 on: August 15, 2012, 01:11:20 AM »
Well, I made the wait shorter. I waited it out and the event started to go to night, but then it goes to day and loops again and again. I think
I did something wrong.

You guys have been a great help. :bend:
Logged

Offline Prpl_Mage

  • Administrator
  • Sage
  • *
  • Posts: 7,645
  • The Administrator Mage
    • Check out our itch website
Re: Day n Night and Timer Operations
« Reply #23 on: August 15, 2012, 07:39:07 AM »
Did you remember the switches? In conditional branch and such?

Does it go night and directly back to day or is the problem when it finally turns to day?
PS you can change values of variables in the F9 interface if you want to speed things up even more.
Logged
Cool RPGM Project!
Sprite till you die

Oh my god, this was ...10 years ago...

Offline evmaster

  • Member
  • Associate
  • *
  • Posts: 231
Re: Day n Night and Timer Operations
« Reply #24 on: August 15, 2012, 02:52:59 PM »
"Does it go night and directly back to day?"

This.

Thank you for telling me about F9.
Logged

Offline Prpl_Mage

  • Administrator
  • Sage
  • *
  • Posts: 7,645
  • The Administrator Mage
    • Check out our itch website
Re: Day n Night and Timer Operations
« Reply #25 on: August 15, 2012, 07:59:38 PM »
Okay might be a stupid question. But does both the day and the night switch start as ON? It might be causing this.
Logged
Cool RPGM Project!
Sprite till you die

Oh my god, this was ...10 years ago...

Offline evmaster

  • Member
  • Associate
  • *
  • Posts: 231
Re: Day n Night and Timer Operations
« Reply #26 on: August 15, 2012, 10:56:02 PM »
I redid the whole event from scratch. Now it turns to night, stays night but the screen keeps being hidden and shown again and again.
You were right about the switch thing.

Logged

Offline Natako

  • Queen of Nonsense
  • Exemplar
  • *
  • Posts: 1,012
  • Jack of a few unremarkable trades, master of none.
Re: Day n Night and Timer Operations
« Reply #27 on: August 16, 2012, 12:06:56 AM »
Okay, I see why it's doing that. Because it's currently set up so that it hides the screen, tints it, and shows it again when hours >= 19, it continues to do this as there's nothing to keep the operation from carrying itself out.

There are two things that you can do.

You take out the hide/show effect so that the screen does not hide itself when the screen changes tint (in other words, you'll see the screen fade from daytime to nighttime lighting without any black screens in between). That's an easy solution, but I'm not sure that this is what you want your transition to look like.

Another thing that you can do involves multiple pages. What you'll need to do is set up a second page for when the NIGHT switch is on so that the fade out/fade in effect will stop after its first occurrence. Let me go ahead and try to make this up in RPG Maker for you and I'll post a screenshot.

Edit: Okay, here you go. This will show you how to set up your screens for either method.

Erasing Show/Hide Screen:

You'll also need to take out your sound effects. Otherwise, they would continue to play after the screen changed. If you use this method, you could select a different BGM for night and day and have the music fade out and in between each transition for greatest effect.

[spoiler][/spoiler]

Keeping Show/Hide Screen:

You'll have to put your events in two pages. It's not necessary to use the DAY switch in this operation as the event will function without it. However, the NIGHT switch is necessary to activate the second page of the event.

[spoiler][/spoiler]
[spoiler][/spoiler]

I tested both of these in RPG Maker and both work. Use whichever you prefer.

Please note that with the last method, Show screen has to be placed BEFORE turning on the NIGHT switch as otherwise it will switch to the second page before the screen fades in and you'll be stuck looking at a blank screen.
« Last Edit: August 16, 2012, 01:06:38 AM by Natako »
Logged
Retiring the deadlines because I think I've proven that I can get stuff done. It might come on my own time, but it will be better quality that way.

Pants.

Offline evmaster

  • Member
  • Associate
  • *
  • Posts: 231
Re: Day n Night and Timer Operations
« Reply #28 on: August 22, 2012, 06:12:36 PM »
I did the first method and took out the hide screen and such. Now my character lags while walking, almost as if there is a 1 sec wait.
Logged

Offline Natako

  • Queen of Nonsense
  • Exemplar
  • *
  • Posts: 1,012
  • Jack of a few unremarkable trades, master of none.
Re: Day n Night and Timer Operations
« Reply #29 on: August 22, 2012, 06:19:25 PM »
Not sure if this is what's causing it, but do you have it set to wait while the screen changes color? You can uncheck the checkbox and that way it won't wait for the screen to change. Seems a bit strange, though...if it's a parallel process, it shouldn't affect the character. Can you post a screenshot of the event code?
Logged
Retiring the deadlines because I think I've proven that I can get stuff done. It might come on my own time, but it will be better quality that way.

Pants.

  • Print
Pages: 1 [2] 3
« previous next »
  • Charas-Project »
  • Game Creation »
  • Requests »
  • RPG Maker Programming »
  • Day n Night and Timer Operations
 

  • SMF 2.0.10 | SMF © 2015, Simple Machines
  • XHTML
  • 2O11
  • RSS
  • WAP2
  • Simple Machines Forum