Script Unreal Time System (like Minecraft) Page 5

Started by FL August 3rd, 2012 4:30 AM
  • 39047 views
  • 121 replies

Atlat

Atlat

Male
Seen May 23rd, 2022
Posted March 16th, 2022
27 posts
2.2 Years
Is there a way to check if a second has passed? I'm trying to make it so that a variable decreases every second, and all of my attempts have just led to errors.
Atlat

FL

Pokémon Island Creator

Male
Seen 1 Day Ago
Posted 2 Days Ago
2,098 posts
11.8 Years
Is there a way to check if a second has passed? I'm trying to make it so that a variable decreases every second, and all of my attempts have just led to errors.
# Variable 90 should have pbGetTimeNow.to_i when the time start counting.
# Variable 91 is the variable that the time is decreased.
secondsPassed = pbGetTimeNow.to_i - $game_variables[90]
$game_variables[90] = $game_variables[90] + secondsPassed
$game_variables[91] = $game_variables[91] - secondsPassed
I put this script on a script event command (remember to run extendtext.exe or put this script on a def at script editor and call it).

Atlat

Atlat

Male
Seen May 23rd, 2022
Posted March 16th, 2022
27 posts
2.2 Years
Does that work all of time time, no matter where you are? Or does that only work on, say, the map that it was called on? Because what I need is the former of the two that is always checking for whenever a second passes.
Atlat

FL

Pokémon Island Creator

Male
Seen 1 Day Ago
Posted 2 Days Ago
2,098 posts
11.8 Years
Does that work all of time time, no matter where you are? Or does that only work on, say, the map that it was called on? Because what I need is the former of the two that is always checking for whenever a second passes.
Works all of time if you make a Common Event with parallel trigger.

FL

Pokémon Island Creator

Male
Seen 1 Day Ago
Posted 2 Days Ago
2,098 posts
11.8 Years
Updated to version 1.1:
  1. Can pass year 2036 (only for Essentials v19 or higher)
  2. Constant TONE_CHECK_INTERVAL
  3. advance_to/reset/add_seconds new methods
  4. Refresh tone when time change
  5. Fix float imprecision on extra time
  6. Major refactor
Seen October 8th, 2021
Posted October 7th, 2021
1 posts
272 Days
Hello FL. I have a question related to your Unreal Time System script. Would it be possible to set your script up for a specific map in a way so that it's always nighttime there? There's not a way to do something like that with the default map metadata, so I was curious if something like permanent nighttime would be possible with your script. Thanks in advance if you can help me out.

FL

Pokémon Island Creator

Male
Seen 1 Day Ago
Posted 2 Days Ago
2,098 posts
11.8 Years
Hello FL. I have a question related to your Unreal Time System script. Would it be possible to set your script up for a specific map in a way so that it's always nighttime there? There's not a way to do something like that with the default map metadata, so I was curious if something like permanent nighttime would be possible with your script. Thanks in advance if you can help me out.
Permanent night time did you mean only shading or the other night effects like encounters?

If is only shading, just make the map as indoor and use the event "Change Screen Tone" when teleported into map. You don't need my script.

If isn't only shading, on entering at map, call script command `UnrealTime.advance_to(22)`, and the switch SWITCH_STOPS as on. On exiting map, set this switch as off.

OpalHeart

Age 23
She/Her or He/Him
In my room
Seen 23 Hours Ago
Posted 2 Days Ago
29 posts
4 Years
I'm loving your script so far!

However, I'm wondering if there's a way I can make it so that there are only 4 months per year with 31 days per month? The fangame I'm working on is a Pokemon/Harvest Moon type of crossover. Any advice would be appreciated.
Looking for someone to help me with my Pokemon fangame!

If you're interested, my Discord is Opal_Sparks#5369

FL

Pokémon Island Creator

Male
Seen 1 Day Ago
Posted 2 Days Ago
2,098 posts
11.8 Years
I'm loving your script so far!

However, I'm wondering if there's a way I can make it so that there are only 4 months per year with 31 days per month? The fangame I'm working on is a Pokemon/Harvest Moon type of crossover. Any advice would be appreciated.
After the script end add:
module UnrealTime
  MONTH_DAYS = 31
  MONTHS = 4
  INITIAL_YEAR = 1

  def self.day
    return total_days % MONTH_DAYS + 1
  end

  # Starts on 1
  def self.mon
    return (total_days/MONTH_DAYS) % MONTHS + 1
  end

  def self.year
    return total_days/(MONTH_DAYS*MONTHS) + INITIAL_YEAR
  end

  def self.total_days
    c_date = pbGetTimeNow 
    i_date = initial_date
    return (c_date.yday - i_date.yday) + ((c_date.year - i_date.year)*365.250001).floor
  end
end
Call 'UnrealTime.day', 'UnrealTime.mon' and 'UnrealTime.year' to get these values.

FL

Pokémon Island Creator

Male
Seen 1 Day Ago
Posted 2 Days Ago
2,098 posts
11.8 Years
I don't know if this is the right place to ask, but is there any way to make the game connect to the internet and set the game time ALWAYS in a specific time zone?
My question is asked because, I realized that if I plant a berry, and advance the computer's time, it is simply ready.
Yes! But this is unrelated with this script, except if you use this script as plan B, so the time won't pass if player has no internet. You can also sync the time on startup and use the script to pass the time, so you don't need to sync frequently.

You need to call a time API and return it with Time object on pbGetTimeNow.

Quick Question: I want to ask this real quick but is it possible to apply this to a gba game that I want to play on my GBA console? And maybe mod it so that the time works similar to PLA time cycle? Like an hour = a day and speed it up by taking a rest at a Pokecenter or healing spot?
This script? No. And Unreal time? Yes! I don't know how. I don't know much about rom hacking.
Seen 6 Hours Ago
Posted 3 Days Ago
102 posts
1.3 Years
Yes! But this is unrelated with this script, except if you use this script as plan B, so the time won't pass if player has no internet. You can also sync the time on startup and use the script to pass the time, so you don't need to sync frequently.

You need to call a time API and return it with Time object on pbGetTimeNow.
Can you give me an example script for me to put to check the internet time when starting the game? This part I don't understand, but about booting with your script, I learned easily.

FL

Pokémon Island Creator

Male
Seen 1 Day Ago
Posted 2 Days Ago
2,098 posts
11.8 Years
Can you give me an example script for me to put to check the internet time when starting the game? This part I don't understand, but about booting with your script, I learned easily.
I have no example about this one because it is a bit tricky. You need to combine a webcall, to receive something from time API and parse the input (time value) from a JSON.

FL

Pokémon Island Creator

Male
Seen 1 Day Ago
Posted 2 Days Ago
2,098 posts
11.8 Years
Hi there!! Looks like this script is no longer working on the new version of essentials (v20) D:
Thanks for the report!

I will wait a little to update my scripts to v20 (maybe a v20.1). I probably will update on June or July.

FL

Pokémon Island Creator

Male
Seen 1 Day Ago
Posted 2 Days Ago
2,098 posts
11.8 Years
Just change line 271 from

to

and it should work on v20!!

Edit: Oh no... emojis.. I don't know how to make that go away. It's replacing a colon and an `S`.

class Battle : : Scene (without spaces, except after the word `class`)
Thanks! Since it's just this, script was updated!

Callmefreak

Female
Hope Peak's Academy
Seen 7 Hours Ago
Posted 1 Week Ago
116 posts
9.3 Years
I don't know if you're the one to ask, or if this is a thing I could do without your script, but since I am using your script I'm going to try to ask here first.

Would it be possible to make switches based on a certain time of day? Like how there's "s:PBDayNight.isDay?" but specifically for a certain hour of the day? Like if I wanted to have an event happen specifically at 2 PM, for example?
And if so, do you happen to have the numbers for every hour at 12 AM for 24 hours handy? (Like 12 AM, 1 AM, etc.) It's not a big deal if not. I can figure that out on my own.

FL

Pokémon Island Creator

Male
Seen 1 Day Ago
Posted 2 Days Ago
2,098 posts
11.8 Years
I don't know if you're the one to ask, or if this is a thing I could do without your script, but since I am using your script I'm going to try to ask here first.

Would it be possible to make switches based on a certain time of day? Like how there's "s:PBDayNight.isDay?" but specifically for a certain hour of the day? Like if I wanted to have an event happen specifically at 2 PM, for example?
And if so, do you happen to have the numbers for every hour at 12 AM for 24 hours handy? (Like 12 AM, 1 AM, etc.) It's not a big deal if not. I can figure that out on my own.
Yes! Just change the switch name. Example (for 2 PM):
s:pbGetTimeNow.hour==14
Number range is 0-23. This works even without my script.

Callmefreak

Female
Hope Peak's Academy
Seen 7 Hours Ago
Posted 1 Week Ago
116 posts
9.3 Years
Yes! Just change the switch name. Example (for 2 PM):
s:pbGetTimeNow.hour==14
Number range is 0-23. This works even without my script.
I uh... I just saw where the default Essentials time script is. Wow. Thanks for answering anyway!