Scripts, Tutorials & Tools This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.

Reply
 
Thread Tools
  #26    
Old June 28th, 2016 (8:46 AM).
HarmonyConcept HarmonyConcept is offline
     
    Join Date: Sep 2015
    Gender: Female
    Posts: 207
    Thank you for this script. It is working fine, however I have two questions regarding what can be done with it.

    1) Is it possible to reach directly a defined hour? I believed you answered a similar question some time ago:

    Spoiler:
    Quote:
    Originally Posted by FL View Post

    For forcing to the player pass the time until it reach into a certain time, there serveral ways, three examples (the first is the worst) that make the player going into 6:00:00 PM (both are doable with events, but I use scripts for better performance).

    Code:
    hour = 18 # 0..23
    min = 0
    sec = 0 
    timeNow = pbGetTimeNow
    while (timeNow.hour != hour &&
        timeNow.min != min && 
        timeNow.sec != sec)
      $game_variables[87]+=1
      timeNow = pbGetTimeNow
    end
    Code:
    hour = 18 # 0..23
    min = 0
    sec = 0
    timeNow = pbGetTimeNow
    secInDay = 60*60*24
    timeDifference = Time.new(
      timeNow.year, timeNow.mon, timeNow.day,
      hour, min, sec)
    timeDifference += secInDay # Add a day
    secondsAdded = (timeDifference-timeNow)%secInDay
    $game_variables[87]+=secondsAdded
    Code:
    hour = 18 # 0..23
    min = 0
    sec = 0
    timeNow = pbGetTimeNow
    secInDay = 60*60*24
    secNow = pbGetTimeNow.hour*60*60+pbGetTimeNow.min*60+pbGetTimeNow.sec
    secWished = hour*60*60+min*60+sec
    timeDifference += secInDay # Add a day
    secondsAdded = secWished-secNow
    secondsAdded +=secInDay if secondsAdded<0
    $game_variables[87]+=secondsAdded
    All untested.


    However when I try to use one of those methods I get an error:

    Spoiler:
    Interpreter:276:in `pbExecuteScript'
    Interpreter:1606:in `command_355'
    Interpreter:494:in `execute_command'
    Interpreter:193:in `update'
    Interpreter:106:in `loop'
    Interpreter:198:in `update'
    Scene_Map:103:in `update'
    Scene_Map:101:in `loop'
    Scene_Map:114:in `update'
    QuickSave:26:in `main'
    Exception: RuntimeError
    Message: Script error within event 22, map 77:
    Exception: SyntaxError
    Message: (eval): 10:in `pbExecuteScript'compile error
    (eval): 8: syntax error
    pbGet(77)+=1
    ^
    ***Full script:
    hour = 18 # 0..23
    min = 0
    sec = 0
    timeNow = pbGetTimeNow
    while (timeNow.hour != hour &&
    timeNow.min != min &&
    timeNow.sec != sec)
    pbGet(77)+=1
    timeNow = pbGetTimeNow
    end


    2) Is it possible to pause - and unpause - the system in an event so that time doesn't pass - and freezes?

    Thanks!
    Reply With Quote
      #27    
    Old June 28th, 2016 (10:51 AM).
    Letrax's Avatar
    Letrax Letrax is offline
       
      Join Date: Feb 2016
      Gender: Male
      Posts: 78
      Hey is it somehow possible to use the time system with the clock displayed on KleinsBwKit?
      I dont want the real time to be displayed but the time of the game
      Reply With Quote
        #28    
      Old June 29th, 2016 (3:39 AM).
      FL's Avatar
      FL FL is offline
      Pokémon Island Creator
         
        Join Date: Sep 2010
        Gender: Male
        Posts: 1,770
        Quote:
        Originally Posted by HarmonyConcept View Post
        Thank you for this script. It is working fine, however I have two questions regarding what can be done with it.

        1) Is it possible to reach directly a defined hour? I believed you answered a similar question some time ago:

        Spoiler:




        However when I try to use one of those methods I get an error:

        Spoiler:
        Interpreter:276:in `pbExecuteScript'
        Interpreter:1606:in `command_355'
        Interpreter:494:in `execute_command'
        Interpreter:193:in `update'
        Interpreter:106:in `loop'
        Interpreter:198:in `update'
        Scene_Map:103:in `update'
        Scene_Map:101:in `loop'
        Scene_Map:114:in `update'
        QuickSave:26:in `main'
        Exception: RuntimeError
        Message: Script error within event 22, map 77:
        Exception: SyntaxError
        Message: (eval): 10:in `pbExecuteScript'compile error
        (eval): 8: syntax error
        pbGet(77)+=1
        ^
        ***Full script:
        hour = 18 # 0..23
        min = 0
        sec = 0
        timeNow = pbGetTimeNow
        while (timeNow.hour != hour &&
        timeNow.min != min &&
        timeNow.sec != sec)
        pbGet(77)+=1
        timeNow = pbGetTimeNow
        end


        2) Is it possible to pause - and unpause - the system in an event so that time doesn't pass - and freezes?

        Thanks!
        1. In the last example, remove the line 'timeDifference += secInDay'. Maybe you have trouble calling it as event command, so copy into a script section the code:

          Code:
          def setNewTime(hour,min=0,sec=0) # Hour is 0..23
            timeNow = pbGetTimeNow
            secInDay = 60*60*24
            secNow = pbGetTimeNow.hour*60*60+pbGetTimeNow.min*60+pbGetTimeNow.sec
            secWished = hour*60*60+min*60+sec
            secondsAdded = secWished-secNow
            secondsAdded +=secInDay if secondsAdded<0
            $game_variables[NTN_EXTRASECONDS]+=secondsAdded
          end
          And call this line at a script command: 'setNewTime(18,0,0)'.
        2. Put a switch number in NTN_SWITCHSTOPS field and turn on this switch while the event is happening.

        Quote:
        Originally Posted by Letrax View Post
        Hey is it somehow possible to use the time system with the clock displayed on KleinsBwKit?
        I dont want the real time to be displayed but the time of the game
        Yes, just make sure that this clock uses the time received from pbGetTimeNow method instead of something line Time.now.
        __________________
        Reply With Quote
          #29    
        Old September 26th, 2016 (9:41 AM).
        rizakh rizakh is offline
           
          Join Date: Jul 2015
          Posts: 35
          Its awesome and i want to use that, but, i figured when this script is on, essentials not load load scripts that work only in nighttime(or other times). In grass by example, if you set landday and landnight only landday pokemons r show.
          Reply With Quote
            #30    
          Old October 5th, 2016 (5:59 PM).
          FL's Avatar
          FL FL is offline
          Pokémon Island Creator
             
            Join Date: Sep 2010
            Gender: Male
            Posts: 1,770
            Quote:
            Originally Posted by rizakh View Post
            Its awesome and i want to use that, but, i figured when this script is on, essentials not load load scripts that work only in nighttime(or other times). In grass by example, if you set landday and landnight only landday pokemons r show.
            This doesn't happen. What version are you using?
            __________________
            Reply With Quote
              #31    
            Old October 6th, 2016 (7:10 AM).
            rizakh rizakh is offline
               
              Join Date: Jul 2015
              Posts: 35
              Quote:
              Originally Posted by FL View Post
              This doesn't happen. What version are you using?
              16.2
              Reply With Quote
                #32    
              Old October 8th, 2016 (4:42 PM).
              Horosaki's Avatar
              Horosaki Horosaki is offline
                 
                Join Date: Aug 2016
                Gender: Male
                Posts: 7
                How can i make an event to use the days of the week with this script?

                The event should read the day of the week to do what it is intended to...
                Reply With Quote
                  #33    
                Old October 11th, 2016 (5:02 AM).
                FL's Avatar
                FL FL is offline
                Pokémon Island Creator
                   
                  Join Date: Sep 2010
                  Gender: Male
                  Posts: 1,770
                  Quote:
                  Originally Posted by rizakh View Post
                  16.2
                  I tested this version and is working.

                  Quote:
                  Originally Posted by Horosaki View Post
                  How can i make an event to use the days of the week with this script?

                  The event should read the day of the week to do what it is intended to...
                  All checks and time-based events works like default Essentials.
                  __________________
                  Reply With Quote
                    #34    
                  Old November 30th, 2016 (8:06 AM).
                  Hargatio's Avatar
                  Hargatio Hargatio is offline
                     
                    Join Date: Jan 2014
                    Posts: 55
                    Awesome script, it works absolutely fine.

                    To make it more realistic, I changed the graphics in the outdoor-tileset and made the windows/doors brighter.

                    To make it work I created an event on every window, with a new page where the default switch 15 "s:PBDayNight.isNight?(pbGetTimeNow)" is on. Additionally the event named "RegularTone"

                    So if it's night the switch turns on and the window shines bright.

                    But it only works, when the map refreshes (player changes the map, e.g. goes into a house and outside again).
                    If it gets dark and he's walking around, the windows stay dark.
                    And of course the other way round, when daylight comes back the windows are still glowing until the player enters a house and leave it again.

                    Is there any possibility to let the switch activated autimatically as soon as it gets dark, without going into a house and outside again?


                    The two top pictures are correct, the two lower ones incorrect.
                    Reply With Quote
                      #35    
                    Old December 4th, 2016 (5:19 AM).
                    FL's Avatar
                    FL FL is offline
                    Pokémon Island Creator
                       
                      Join Date: Sep 2010
                      Gender: Male
                      Posts: 1,770
                      Quote:
                      Originally Posted by Hargatio View Post
                      Awesome script, it works absolutely fine.

                      To make it more realistic, I changed the graphics in the outdoor-tileset and made the windows/doors brighter.

                      To make it work I created an event on every window, with a new page where the default switch 15 "s:PBDayNight.isNight?(pbGetTimeNow)" is on. Additionally the event named "RegularTone"

                      So if it's night the switch turns on and the window shines bright.

                      But it only works, when the map refreshes (player changes the map, e.g. goes into a house and outside again).
                      If it gets dark and he's walking around, the windows stay dark.
                      And of course the other way round, when daylight comes back the windows are still glowing until the player enters a house and leave it again.

                      Is there any possibility to let the switch activated autimatically as soon as it gets dark, without going into a house and outside again?


                      The two top pictures are correct, the two lower ones incorrect.
                      After line 'updateold' add:

                      Code:
                              if !@lastHour || @lastHour != pbGetTimeNow.hour
                                @lastHour = pbGetTimeNow.hour
                                $game_map.need_refresh = true
                              end
                      This ensures one refresh per game hour.
                      __________________
                      Reply With Quote
                        #36    
                      Old December 4th, 2016 (7:47 AM).
                      Hargatio's Avatar
                      Hargatio Hargatio is offline
                         
                        Join Date: Jan 2014
                        Posts: 55
                        Quote:
                        Originally Posted by FL View Post
                        After line 'updateold' add:

                        Code:
                                if !@lastHour || @lastHour != pbGetTimeNow.hour
                                  @lastHour = pbGetTimeNow.hour
                                  $game_map.need_refresh = true
                                end
                        This ensures one refresh per game hour.
                        Thanks for your reply, where do I find the line 'updateold'?
                        I was looking in the script section but couldn't find it.
                        Reply With Quote
                          #37    
                        Old December 6th, 2016 (7:31 AM).
                        FL's Avatar
                        FL FL is offline
                        Pokémon Island Creator
                           
                          Join Date: Sep 2010
                          Gender: Male
                          Posts: 1,770
                          Quote:
                          Originally Posted by Hargatio View Post
                          Thanks for your reply, where do I find the line 'updateold'?
                          I was looking in the script section but couldn't find it.
                          At my script.
                          __________________
                          Reply With Quote
                            #38    
                          Old January 9th, 2017 (11:40 AM).
                          ~YumYum~ ~YumYum~ is offline
                             
                            Join Date: Jan 2017
                            Gender: Other
                            Posts: 3
                            Is it possible for the time to pass by even when the game isn't running? oO
                            Reply With Quote
                              #39    
                            Old January 9th, 2017 (10:16 PM).
                            Rot8er_ConeX's Avatar
                            Rot8er_ConeX Rot8er_ConeX is offline
                               
                              Join Date: May 2015
                              Location: The Dissa Region
                              Gender: Male
                              Posts: 822
                              Quote:
                              Originally Posted by ~YumYum~ View Post
                              Is it possible for the time to pass by even when the game isn't running? oO
                              . . .

                              use Default Essentials.
                              __________________
                              Features of Pokemon Entropy

                              The black circular "doodles" in the lower right corner of my avatar are actually my username written in Gallifreyan. Yes I'm a Whovian.
                              Reply With Quote
                                #40    
                              Old January 10th, 2017 (1:16 AM).
                              Letrax's Avatar
                              Letrax Letrax is offline
                                 
                                Join Date: Feb 2016
                                Gender: Male
                                Posts: 78
                                But I dont want the real time.
                                I want time to move faster ingame.
                                Reply With Quote
                                  #41    
                                Old January 10th, 2017 (6:18 AM).
                                PhantomBima PhantomBima is offline
                                   
                                  Join Date: May 2016
                                  Location: East Java
                                  Gender: Male
                                  Nature: Quiet
                                  Posts: 24
                                  # Time proportion here. # So if it is 100, one second in real time will be 100 seconds in game. # If it is 60, one second in real time will be one minute in game. NTS_TIMEPROPORTION=60
                                  Change the time proportion there if you want the time to be faster.
                                  Reply With Quote
                                    #42    
                                  Old January 10th, 2017 (2:45 PM).
                                  Rot8er_ConeX's Avatar
                                  Rot8er_ConeX Rot8er_ConeX is offline
                                     
                                    Join Date: May 2015
                                    Location: The Dissa Region
                                    Gender: Male
                                    Posts: 822
                                    Quote:
                                    Originally Posted by PhantomBima View Post
                                    # Time proportion here. # So if it is 100, one second in real time will be 100 seconds in game. # If it is 60, one second in real time will be one minute in game. NTS_TIMEPROPORTION=60
                                    Change the time proportion there if you want the time to be faster.
                                    That's not all he wants, though. He wants time to be faster in-game, but still pass when the game is off.
                                    __________________
                                    Features of Pokemon Entropy

                                    The black circular "doodles" in the lower right corner of my avatar are actually my username written in Gallifreyan. Yes I'm a Whovian.
                                    Reply With Quote
                                      #43    
                                    Old January 12th, 2017 (5:27 AM).
                                    FL's Avatar
                                    FL FL is offline
                                    Pokémon Island Creator
                                       
                                      Join Date: Sep 2010
                                      Gender: Male
                                      Posts: 1,770
                                      Quote:
                                      Originally Posted by ~YumYum~ View Post
                                      Is it possible for the time to pass by even when the game isn't running? oO
                                      You don't need my script for doing this. Put the below code above main (untested):

                                      Code:
                                      def pbGetTimeNow
                                        return Time.now if !$PokemonGlobal || !$PokemonGlobal.startTime
                                        timeProportion = 2
                                        return (Time.now - $PokemonGlobal.startTime)*timeProportion + $PokemonGlobal.startTime
                                      end
                                      __________________
                                      Reply With Quote
                                        #44    
                                      Old January 12th, 2017 (10:31 AM).
                                      Letrax's Avatar
                                      Letrax Letrax is offline
                                         
                                        Join Date: Feb 2016
                                        Gender: Male
                                        Posts: 78
                                        Ty! But when I add it i get a Type Error.
                                        Reply With Quote
                                          #45    
                                        Old January 23rd, 2017 (2:35 PM).
                                        FL's Avatar
                                        FL FL is offline
                                        Pokémon Island Creator
                                           
                                          Join Date: Sep 2010
                                          Gender: Male
                                          Posts: 1,770
                                          Quote:
                                          Originally Posted by WLD42 View Post
                                          Hi there, Unreal Time users,

                                          I'm struggling to figure out an issue in which the Time Received (and Time Hatched, if applicable) on a Pokémon's or Egg's summary screen is 4 hours earlier than the actual time it was received or hatched. I successfully added the "Watch in the Pokégear" feature using the tutorial that's on the Essentials Wiki (also by FL; your scripts are fantastic), so I'm able to compare the time shown in the summary screen to the time shown in the Pokégear, and confirm that the summary screen is the only one that's incorrect.

                                          I first realized the issue because I'd set the game's initial time to be 1:18am, and I noticed that Pokémon and Eggs were showing their Time Received as the previous day. I then made the following changes to PScreen_Summary, on PageOneEgg and on PageTwo:
                                          Code:
                                           if pokemon.timeReceived
                                                month=pbGetAbbrevMonthName(pokemon.timeReceived.mon)
                                                date=pokemon.timeReceived.day
                                                year=pokemon.timeReceived.year
                                                time=pokemon.timeReceived.strftime("%I:%M %p") # CHANGED
                                                memo+=_INTL("<c3=404040,B0B0B0>{1} {2}, {3} at {4}\n",month,date,year,time) # CHANGED
                                          It successfully added the hour and minute received to the summary screen, in addition to the date and year that were already there, and I was able to confirm that the difference was 4 hours; for example, a Pokémon received at 1:30am would show 9:30pm of the previous day on its summary screen. However, I've got no clue why it's happening, or how to fix it.

                                          I did also check the summary screen with Unreal Time turned off, and the time and date shown then matched the real time, which was also what displayed in the Pokégear.

                                          Any thoughts? Thank you!
                                          The Time Received used global time by Maruno's decision. To use default time, change line '@timeReceived=time.getgm.to_i # Use GMT' into '@timeReceived=pbGetTimeNow'.
                                          __________________
                                          Reply With Quote
                                            #46    
                                          Old January 24th, 2017 (7:50 AM).
                                          WLD42's Avatar
                                          WLD42 WLD42 is offline
                                             
                                            Join Date: Jan 2017
                                            Posts: 7
                                            Thanks so much, FL! That solved it.

                                            For whatever reason, Time Hatched was still showing as 4 hours previous, even when Time Received was correct. I went into PScreen_EggHatching, and it already said 'pokemon.timeEggHatched=pbGetTimeNow', so I just added '+14400' (4hrs in seconds) to the end of it, which was a bit of a "blunt instrument" style approach, but it worked! Don't know why that would have been the case, but I solved it, so I'm happy.
                                            Reply With Quote
                                              #47    
                                            Old January 28th, 2017 (5:54 AM).
                                            FL's Avatar
                                            FL FL is offline
                                            Pokémon Island Creator
                                               
                                              Join Date: Sep 2010
                                              Gender: Male
                                              Posts: 1,770
                                              Quote:
                                              Originally Posted by WLD42 View Post
                                              Thanks so much, FL! That solved it.

                                              For whatever reason, Time Hatched was still showing as 4 hours previous, even when Time Received was correct. I went into PScreen_EggHatching, and it already said 'pokemon.timeEggHatched=pbGetTimeNow', so I just added '+14400' (4hrs in seconds) to the end of it, which was a bit of a "blunt instrument" style approach, but it worked! Don't know why that would have been the case, but I solved it, so I'm happy.
                                              Forget my last post. Change '.utc' in my script to '.local'. I updated the script.

                                              Your solution mess the time if the player was in any other different timezone.
                                              __________________
                                              Reply With Quote
                                                #48    
                                              Old February 16th, 2017 (4:49 PM). Edited February 16th, 2017 by Raizu.
                                              Raizu's Avatar
                                              Raizu Raizu is offline
                                              The Horizon
                                                 
                                                Join Date: Feb 2017
                                                Location: Stafford, Virginia
                                                Gender: Male
                                                Nature: Modest
                                                Posts: 2
                                                This script was really awesome the only problem I have now is that I tried to put it in another project and when I go to the pause menu it won't display in the pause menu. Do I have to do something to make the time display in the pause menu?
                                                Reply With Quote
                                                  #49    
                                                Old February 24th, 2017 (4:00 PM).
                                                FL's Avatar
                                                FL FL is offline
                                                Pokémon Island Creator
                                                   
                                                  Join Date: Sep 2010
                                                  Gender: Male
                                                  Posts: 1,770
                                                  Quote:
                                                  Originally Posted by Raizu View Post
                                                  This script was really awesome the only problem I have now is that I tried to put it in another project and when I go to the pause menu it won't display in the pause menu. Do I have to do something to make the time display in the pause menu?
                                                  Just follow the examples about how to get a date string.

                                                  By the way, what you done?
                                                  __________________
                                                  Reply With Quote
                                                    #50    
                                                  Old February 25th, 2017 (8:11 PM). Edited February 25th, 2017 by Raizu.
                                                  Raizu's Avatar
                                                  Raizu Raizu is offline
                                                  The Horizon
                                                     
                                                    Join Date: Feb 2017
                                                    Location: Stafford, Virginia
                                                    Gender: Male
                                                    Nature: Modest
                                                    Posts: 2
                                                    ASo do I take this
                                                    pbGetTimeNow.strftime("%I:%M %p")
                                                    and place it below the #= line?
                                                    I don't quite understand scripting but I'm learning with it.

                                                    For the second question I'm working on a game where the player has psychic powers who is destined to become a watcher (another group similar to rangers but have the capabilities to their powers to help people) along with your mentor Zoroark to guide you to your goal. I haven't been working on it for the past 3 years because my computer was broken so I had to get a new one.
                                                    Reply With Quote
                                                    Reply

                                                    Quick Reply

                                                    Join the conversation!

                                                    Create an account to post a reply in this thread, participate in other discussions, and more!

                                                    Create a PokéCommunity Account
                                                    Thread Tools

                                                    Posting Rules
                                                    You may not post new threads
                                                    You may not post replies
                                                    You may not post attachments
                                                    You may not edit your posts

                                                    BB code is On
                                                    Smilies are On
                                                    [IMG] code is On
                                                    HTML code is Off

                                                    Forum Jump


                                                    All times are GMT -8. The time now is 12:37 PM.