• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
[v13+] Unreal Time System

Resource [v13+] Unreal Time System 1.1.1

-FL-

Pokémon Island Creator
Member
Joined
Aug 28, 2022
Posts
306
-FL- submitted a new resource:

Unreal Time System - Time passes like Minecraft and Zelda: Ocarina of Time.

gif.gif

This script makes the time in game uses its own clock that only pass when you are in game instead of using real time (like Minecraft and Zelda: Ocarina of Time).

Link


Tested on Essentials v13, v17.2, v18.1, v19.1 and v20. If this script isn't working on latest Essentials version, please...

Read more about this resource...
 

TheDizzy1

Novice
Member
Joined
Feb 13, 2021
Posts
34
I’m starting work on my game again, and I absolutely love this and can’t wait to start it back up again. As I’m thinking of scenery, is it possible to set time of day events while using this amazing resource?
 
I’m starting work on my game again, and I absolutely love this and can’t wait to start it back up again. As I’m thinking of scenery, is it possible to set time of day events while using this amazing resource?
FL's got some instructions for this at the top of the Script.rb file -
# 2. 'UnrealTime.add_seconds(seconds)' and 'UnrealTime.add_days(days)' does the
# same thing, in fact, EXTRA_SECONDS/EXTRA_DAYS call these methods.
#
# 3. 'UnrealTime.advance_to(16,17,18)' advance the time to a fixed time of day,
# 16:17:18 on this example.
 

corvo00

Rookie
Member
Joined
Jul 26, 2022
Posts
6
Dosn't work in 20.1? I installed the script above main and dosn't work.

Sorry for my english
 
I get this when I open the game
I'm not getting this error when I try it. Have you removed anything from the script? That error message is pointing to line 170, but the script doesn't reference pbGraphicsUpdate until line 271. And you're getting this error message because PokeBattle_Scene isn't a thing in v20, so there's no pbGraphicsUpdate to alias, but FL definitely accounted for that with the line PokeBattle_Scene = Battle::Scene if !defined?(PokeBattle_Scene).
 

corvo00

Rookie
Member
Joined
Jul 26, 2022
Posts
6
I'm not getting this error when I try it. Have you removed anything from the script? That error message is pointing to line 170, but the script doesn't reference pbGraphicsUpdate until line 271. And you're getting this error message because PokeBattle_Scene isn't a thing in v20, so there's no pbGraphicsUpdate to alias, but FL definitely accounted for that with the line PokeBattle_Scene = Battle::Scene if !defined?(PokeBattle_Scene).
I'm not getting this error when I try it. Have you removed anything from the script? That error message is pointing to line 170, but the script doesn't reference pbGraphicsUpdate until line 271. And you're getting this error message because PokeBattle_Scene isn't a thing in v20, so there's no pbGraphicsUpdate to alias, but FL definitely accounted for that with the line PokeBattle_Scene = Battle::Scene if !defined?(PokeBattle_Scene).
Ups! I had deleted a line unintentionally, what a fool... Thank you for responding and sorry for the inconvenience.
 

Westrah

Novice
Member
Joined
Nov 2, 2021
Posts
29
Is there a way to make this script work with Apricorns so that they respawn after "24 hours" of this scripts time?
 

Taiga

Rookie
Member
Joined
Oct 5, 2022
Posts
6
I kind of struggle to set the date to a specific time. I put in
Ruby:
Expand Collapse Copy
pbGetTimeNow.year(2028)
pbGetTimeNow.mon(8)
pbGetTimeNow.day(1)
pbGetTimeNow.hour(8)
but it just gives me an error message.
 
I kind of struggle to set the date to a specific time. I put in
Ruby:
Expand Collapse Copy
pbGetTimeNow.year(2028)
pbGetTimeNow.mon(8)
pbGetTimeNow.day(1)
pbGetTimeNow.hour(8)
but it just gives me an error message.
"An error message" could be anything, you need to share the full thing. But I'm guessing that the error is coming from the fact that pbGetTimeNow is supposed to return the current time, not set it. You should be using these commands -

1671623979234.png
 

SirWeibrot

Novice
Member
Joined
Jan 30, 2021
Posts
21
Hi, I just noticed that a caught Pokemon shows its date received based on Time.local, rather than the actual date it was received. Is there a way to change/fix this?
 

-FL-

Pokémon Island Creator
Member
Joined
Aug 28, 2022
Posts
306
Hi, I just noticed that a caught Pokemon shows its date received based on Time.local, rather than the actual date it was received. Is there a way to change/fix this?
The default Essentials use 'pbGetTimeNow' for pokémon caught date (search for 'pbGetTimeNow' on class Pokemon, should be a '@timeReceived = pbGetTimeNow.to_i'), so this may be some external script changing it.

If you want to change others 'Time.now' to use Unreal Time (or vice-versa):
Script said:
# If you wish to some parts still use real time like the Trainer Card start time
# and Pokémon Trainer Memo, just change 'pbGetTimeNow' to 'Time.now' in their
# scripts.
Do the reverse for the opposite effect if you want.
 

MakerBlack

Trainer
Member
Joined
Nov 23, 2020
Posts
88
The default Essentials use 'pbGetTimeNow' for pokémon caught date (search for 'pbGetTimeNow' on class Pokemon, should be a '@timeReceived = pbGetTimeNow.to_i'), so this may be some external script changing it.

If you want to change others 'Time.now' to use Unreal Time (or vice-versa):
Do the reverse for the opposite effect if you want.
I made a script to check the current date online as per my country.
How do I make it so that the player has access to the internet this time is reproduced and when he is offline his internal time works?

Here is the code.

Script:
Expand Collapse Copy
# Hora da internet - Brasil by Maker Black

def get_hour_online
  $offline = false
  # faz uma solicitação HTTP GET para um servidor que fornece a data atual
  response = HTTPLite.get("http://worldtimeapi.org/api/timezone/America/Sao_Paulo")
  # extrai a data atual do hash da resposta
  current_date = response[:body].match(/"datetime":"([^"]+)"/)[1] 
  status = response[:status]
  # Converte o valor em pbGetTimeNow
  if status == 200
    pbHour = current_date.slice(0..9) + " "
    pbHour += current_date.slice(11..18) + " -"
    pbHour += current_date.slice(27..28)
    pbHour += current_date.slice(30..31)
  else
    $offline = true
  end
  return pbHour
end

This script returns the structure of a pbGetTimeNow in string, for example:
2023-03-07 12:57:20 -0300

I tried to make pbGetTimeNow's time_ret equal to this time
but the structure seems to be different and generates errors, how to fix it?
 

-FL-

Pokémon Island Creator
Member
Joined
Aug 28, 2022
Posts
306
Script:
Expand Collapse Copy
# Hora da internet - Brasil by Maker Black

def get_hour_online
  $offline = false
  # faz uma solicitação HTTP GET para um servidor que fornece a data atual
  response = HTTPLite.get("http://worldtimeapi.org/api/timezone/America/Sao_Paulo")
  # extrai a data atual do hash da resposta
  current_date = response[:body].match(/"datetime":"([^"]+)"/)[1] 
  status = response[:status]
  # Converte o valor em pbGetTimeNow
  if status == 200
    pbHour = current_date.slice(0..9) + " "
    pbHour += current_date.slice(11..18) + " -"
    pbHour += current_date.slice(27..28)
    pbHour += current_date.slice(30..31)
  else
    $offline = true
  end
  return pbHour
end

This script returns the structure of a pbGetTimeNow in string, for example:
2023-03-07 12:57:20 -0300

I tried to make pbGetTimeNow's time_ret equal to this time
but the structure seems to be different and generates errors, how to fix it?
This method returns a string. The pbGetTimeNow return Time object. Since the json response also returns a timestamp, I used it instead (it is easier) to convert into a Time object using Time.at method.

Ruby:
Expand Collapse Copy
# Hora da internet - Brasil by Maker Black, ajustada por FL
def get_date_online
  ret = nil
  $offline = false
  # faz uma solicitação HTTP GET para um servidor que fornece a data atual
  response = HTTPLite.get("http://worldtimeapi.org/api/timezone/America/Sao_Paulo")
  # extrai o timestamp atual do hash da resposta
  current_date = response[:body].match(/"unixtime":([^"]+),/)[1]
  status = response[:status]
  # Converte o valor em pbGetTimeNow
  if status == 200
    ret = Time.at(current_date.to_i)
  else
    $offline = true
  end
  return ret
end

I made a script to check the current date online as per my country.
How do I make it so that the player has access to the internet this time is reproduced and when he is offline his internal time works?
The script below only checks date when game is loaded. After, it will use the last date counting the time internally

Put this below my script and set PROPORTION as 1 in my script.

Ruby:
Expand Collapse Copy
# Hora da internet - Brasil by Maker Black, ajustada por FL
def get_date_online
  ret = nil
  $offline = false
  # faz uma solicitação HTTP GET para um servidor que fornece a data atual
  response = HTTPLite.get("http://worldtimeapi.org/api/timezone/America/Sao_Paulo")
  # extrai o timestamp atual do hash da resposta
  current_date = response[:body].match(/"unixtime":([^"]+),/)[1]
  status = response[:status]
  # Converte o valor em pbGetTimeNow
  if status == 200
    ret = Time.at(current_date.to_i)
  else
    $offline = true
  end
  return ret
end

$time_checked = false
$last_date = nil

class PokemonGlobalMetadata
  attr_accessor :last_recorded_timestamp
end

module UnrealTime
  class << self
    alias :initial_date_old :initial_date
    def initial_date
      return Time.now if !$PokemonGlobal || !UnrealTime::ENABLED
      if !$time_checked
        $time_checked = true
        online_date = get_date_online
        $PokemonGlobal.last_recorded_timestamp = online_date.to_i if online_date
        UnrealTime.reset
      end
      if $PokemonGlobal.last_recorded_timestamp && !$last_date
        $last_date = Time.at($PokemonGlobal.last_recorded_timestamp)
      end
      return $last_date || initial_date_old
    end
  end
end
 

Jukes

Cooltrainer
Member
Joined
Jul 15, 2023
Posts
102
it doesn't seem to be working for me, do I need to set it up in some way? I installed it and it still seems to be still using local time.
 

-FL-

Pokémon Island Creator
Member
Joined
Aug 28, 2022
Posts
306
it doesn't seem to be working for me, do I need to set it up in some way? I installed it and it still seems to be still using local time.
Strange. Did you recompiled the plugins (only if you added as plugin)? Did you tested using one of methods in the instructions (notes section), like:
Code:
Expand Collapse Copy
pbGetTimeNow.strftime("%I:%M %p"))
?
 

CelestialFearow

Venipede User
Member
Joined
Jul 24, 2020
Posts
200
Hello, can you add an option in the option menu to be able to deactivate this system if the player wish to? When trun off, the game should use the player's pc time instead.
 
Back
Top