• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Calender Script

Zeak6464

Zeak #3205 - Discord
1,101
Posts
11
Years
  • I been looking for a Calender to add into my pokemon game but so far no luck at all....
    I was wondering if anyone has one or knows how to make one ?
     

    Nickalooose

    --------------------
    1,309
    Posts
    16
    Years
    • Seen Dec 28, 2023
    There is a Harvest Moon tool kit in the scripts section (HMTK) I'm pretty sure that has a calendar, you could possibly use that, but give credit of course.
     

    Zeak6464

    Zeak #3205 - Discord
    1,101
    Posts
    11
    Years
  • thanks ill look into that right now
    ^didn't work ... but then i looked into pokemon coding : PokemonTime

    Code:
    ################################################################################
    # * Day and night system
    ################################################################################
    def pbGetTimeNow
      return Time.now
    end
    
    
    
    module PBDayNight
      HourlyTones=[
         Tone.new(-142.5,-142.5,-22.5,68),     # Midnight
         Tone.new(-135.5,-135.5,-24,  68),
         Tone.new(-127.5,-127.5,-25.5,68),
         Tone.new(-127.5,-127.5,-25.5,68),
         Tone.new(-119,  -96.3, -45.3,45.3),
         Tone.new(-51,   -73.7, -73.7,22.7),
         Tone.new(17,    -51,   -102, 0),      # 6AM
         Tone.new(14.2,  -42.5, -85,  0),
         Tone.new(11.3,  -34,   -68,  0),
         Tone.new(8.5,   -25.5, -51,  0),
         Tone.new(5.7,   -17,   -34,  0),
         Tone.new(2.8,   -8.5,  -17,  0),
         Tone.new(0,     0,     0,    0),      # Noon
         Tone.new(0,     0,     0,    0),
         Tone.new(0,     0,     0,    0),
         Tone.new(0,     0,     0,    0),
         Tone.new(-3,    -7,    -2,   0),
         Tone.new(-10,   -18,   -5,   0),
         Tone.new(-36,   -75,   -13,  0),      # 6PM
         Tone.new(-72,   -136,  -34,  3),
         Tone.new(-88.5, -133,  -31,  34),
         Tone.new(-108.5,-129,  -28,  68),
         Tone.new(-127.5,-127.5,-25.5,68),
         Tone.new(-142.5,-142.5,-22.5,68)
      ]
      @cachedTone=nil
      @dayNightToneLastUpdate=nil
    
    # Returns true if it's day.
      def self.isDay?(time)
        return (time.hour>=6 && time.hour<20)
      end
    
    # Returns true if it's night.
      def self.isNight?(time)
        return (time.hour>=20 || time.hour<6)
      end
    
    # Returns true if it's morning.
      def self.isMorning?(time)
        return (time.hour>=6 && time.hour<12)
      end
    
    # Returns true if it's the afternoon.
      def self.isAfternoon?(time)
        return (time.hour>=12 && time.hour<20)
      end
    
    # Returns true if it's the evening.
      def self.isEvening?(time)
        return (time.hour>=17 && time.hour<20)
      end
    
    # Gets a number representing the amount of daylight (0=full night, 255=full day).
      def self.getShade
        time=pbGetDayNightMinutes
        time=(24*60)-time if time>(12*60)
        shade=255*time/(12*60)
      end
    
    # Gets a Tone object representing a suggested shading
    # tone for the current time of day.
      def self.getTone()
        return Tone.new(0,0,0) if !ENABLESHADING
        if !@cachedTone
          @cachedTone=Tone.new(0,0,0)
        end
        if !@dayNightToneLastUpdate || @dayNightToneLastUpdate!=Graphics.frame_count       
          @cachedTone=getToneInternal()
          @dayNightToneLastUpdate=Graphics.frame_count
        end
        return @cachedTone
      end
    
      def self.pbGetDayNightMinutes
        now=pbGetTimeNow   # Get the current in-game time
        return (now.hour*60)+now.min
      end
    
      private
    
    # Internal function
    
      def self.getToneInternal()
        # Calculates the tone for the current frame, used for day/night effects
        realMinutes=pbGetDayNightMinutes
        hour=realMinutes/60
        minute=realMinutes%60
        tone=PBDayNight::HourlyTones[hour]
        nexthourtone=PBDayNight::HourlyTones[(hour+1)%24]
        # Calculate current tint according to current and next hour's tint and
        # depending on current minute
        return Tone.new(
           ((nexthourtone.red-tone.red)*minute/60.0)+tone.red,
           ((nexthourtone.green-tone.green)*minute/60.0)+tone.green,
           ((nexthourtone.blue-tone.blue)*minute/60.0)+tone.blue,
           ((nexthourtone.gray-tone.gray)*minute/60.0)+tone.gray
        )
      end
    end
    
    
    
    def pbDayNightTint(object)
      if !$scene.is_a?(Scene_Map)
        return
      else
        if ENABLESHADING && $game_map && pbGetMetadata($game_map.map_id,MetadataOutdoor)
          tone=PBDayNight.getTone()
          object.tone.set(tone.red,tone.green,tone.blue,tone.gray)
        else
          object.tone.set(0,0,0,0)  
        end
      end  
    end
    
    
    
    ################################################################################
    # * Zodiac and day/month checks
    ################################################################################
    # Calculates the phase of the moon.
    # 0 - New Moon
    # 1 - Waxing Crescent
    # 2 - First Quarter
    # 3 - Waxing Gibbous
    # 4 - Full Moon
    # 5 - Waning Gibbous
    # 6 - Last Quarter
    # 7 - Waning Crescent
    def moonphase(time) # in UTC
      transitions=[
         1.8456618033125,
         5.5369854099375,
         9.2283090165625,
         12.9196326231875,
         16.6109562298125,
         20.3022798364375,
         23.9936034430625,
         27.6849270496875]
      yy=time.year-((12-time.mon)/10.0).floor
      j=(365.25*(4712+yy)).floor + (((time.mon+9)%12)*30.6+0.5).floor + time.day+59
      j-=(((yy/100.0)+49).floor*0.75).floor-38 if j>2299160
      j+=(((time.hour*60)+time.min*60)+time.sec)/86400.0
      v=(j-2451550.1)/29.530588853
      v=((v-v.floor)+(v<0 ? 1 : 0))
      ag=v*29.53
      for i in 0...transitions.length
        return i if ag<=transitions[i]
      end
      return 0
    end
    
    # Calculates the zodiac sign based on the given month and day:
    # 0 is Aries, 11 is Pisces. Month is 1 if January, and so on.
    def zodiac(month,day)
      time=[
         3,21,4,19,   # Aries
         4,20,5,20,   # Taurus
         5,21,6,20,   # Gemini
         6,21,7,20,   # Cancer
         7,23,8,22,   # Leo
         8,23,9,22,   # Virgo 
         9,23,10,22,  # Libra
         10,23,11,21, # Scorpio
         11,22,12,21, # Sagittarius
         12,22,1,19,  # Capricorn
         1,20,2,18,   # Aquarius
         2,19,3,20    # Pisces
      ]
      for i in 0...12
        return i if month==time[i*4] && day>=time[i*4+1]
        return i if month==time[i*4+2] && day<=time[i*4+2]
      end
      return 0
    end
     
    # Returns the opposite of the given zodiac sign.
    # 0 is Aries, 11 is Pisces.
    def zodiacOpposite(sign)
      return (sign+6)%12
    end
    
    # 0 is Aries, 11 is Pisces.
    def zodiacPartners(sign)
      return [(sign+4)%12,(sign+8)%12]
    end
    
    # 0 is Aries, 11 is Pisces.
    def zodiacComplements(sign)
      return [(sign+1)%12,(sign+11)%12]
    end
    
    def pbIsWeekday(wdayVariable,*arg)
      timenow=pbGetTimeNow
      wday=timenow.wday
      ret=false
      for wd in arg
        ret=true if wd==wday
      end
      if wdayVariable>0
        $game_variables[wdayVariable]=[ 
           _INTL("Sunday"),
           _INTL("Monday"),
           _INTL("Tuesday"),
           _INTL("Wednesday"),
           _INTL("Thursday"),
           _INTL("Friday"),
           _INTL("Saturday")
        ][wday] 
        $game_map.need_refresh = true if $game_map
      end
      return ret
    end
    
    def pbIsMonth(wdayVariable,*arg)
      timenow=pbGetTimeNow
      wday=timenow.mon
      ret=false
      for wd in arg
        ret=true if wd==wday
      end
      if wdayVariable>0
        $game_variables[wdayVariable]=[ 
           _INTL("January"),
           _INTL("February"),
           _INTL("March"),
           _INTL("April"),
           _INTL("May"),
           _INTL("June"),
           _INTL("July"),
           _INTL("August"),
           _INTL("September"),
           _INTL("October"),
           _INTL("November"),
           _INTL("December")
        ][wday-1] 
        $game_map.need_refresh = true if $game_map
      end
      return ret
    end
    
    def pbGetAbbrevMonthName(month)
      return [_INTL(""),
              _INTL("Jan."),
              _INTL("Feb."),
              _INTL("Mar."),
              _INTL("Apr."),
              _INTL("May"),
              _INTL("Jun."),
              _INTL("Jul."),
              _INTL("Aug."),
              _INTL("Sep."),
              _INTL("Oct."),
              _INTL("Nov."),
              _INTL("Dec.")][month]
    end

    Still need help making it now into a Calender...
     
    Last edited:

    Luka S.J.

    Jealous Croatian
    1,270
    Posts
    15
    Years
  • PokemonTime uses the Time.now methods, which aren't applicable to your need (as far as I am aware). Time.now gets the current values for either the day, month, year or just basic time. Well actually, it can get your region and daylight savings too. It doesn't, however, have any sort of predicting functions. That is, it doesn't display how many days there are in this month, and which weekday falls onto which calendar day. The reason for this is that it reads the current information provided by windows, but only the current information.

    All I'm saying is, don't waste your time looking through PokemonTime. You will not find your answer there. I don't know where to point you though, Google search came up empty. I haven't made a calendar myself yet, so I can't share any knowledge either, as I don't have it.

    If you know how to call and use Win32API you can always look through Microsoft's API documentation (more interestingly this), and call functions directly from the Kernel32.dll. This is very advanced stuff though.
     
    Last edited:

    Zeak6464

    Zeak #3205 - Discord
    1,101
    Posts
    11
    Years
  • PokemonTime uses the Time.now methods, which aren't applicable to your need (as far as I am aware). Time.now gets the current values for either the day, month, year or just basic time. Well actually, it can get your region and daylight savings too. It doesn't, however, have any sort of predicting functions. That is, it doesn't display how many days there are in this month, and which weekday falls onto which calendar day. The reason for this is that it reads the current information provided by windows, but only the current information.

    All I'm saying is, don't waste your time looking through PokemonTime. You will not find your answer there. I don't know where to point you though, Google search came up empty. I haven't made a calendar myself yet, so I can't share any knowledge either, as I don't have it.

    If you know how to call and use Win32API you can always look through Microsoft's API documentation (more interestingly this), and call functions directly from the Kernel32.dll. This is very advanced stuff though.

    Thanks for the input tho Luka
     
    401
    Posts
    19
    Years
    • Age 29
    • Seen Dec 4, 2016
    If you're Ruby-savvy enough, you can implement the Rails Time class in RGSS. All you really need to do is extend the basic Ruby Time class with the methods Rails provides (while making sure to fill in constants with your own data).

    https://api.rubyonrails.org/classes/Time.html is the documentation for it.

    If you really want to get into it, you could port over Rail's time calculation functions which allows you to do interesting stuff like this:

    Code:
    date = Time.now
     => 16/10/2014
    
    date.tomorrow
     => 17/10/14
    
    date + 7.days
     = > 23/10.14
    
    date - 18.years
     = > 23/10/96

    which are very useful for calendar-like functions.

    The actual porting is left as an exercise to the reader.
     
    1,224
    Posts
    10
    Years
  • If you're Ruby-savvy enough, you can implement the Rails Time class in RGSS. All you really need to do is extend the basic Ruby Time class with the methods Rails provides (while making sure to fill in constants with your own data).

    https://api.rubyonrails.org/classes/Time.html is the documentation for it.

    If you really want to get into it, you could port over Rail's time calculation functions which allows you to do interesting stuff like this:

    Code:
    date = Time.now
     => 16/10/2014
    
    date.tomorrow
     => 17/10/14
    
    date + 7.days
     = > 23/10.14
    
    date - 18.years
     = > 23/10/96

    which are very useful for calendar-like functions.

    The actual porting is left as an exercise to the reader.

    This would require a bit of work, RGSS's time class is comparatively limited to the current version of Ruby's even without rails. Might be a fun challenge when I get a bit of spare time.
     
    Back
    Top