• 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.

[Scripting Question] Seasons???

153
Posts
4
Years
    • Seen Feb 4, 2020
    I wanted to make a guy which would go to the sea during the summer and in other places for others seasons but I realised the pbIsSeason function was really strange. (why is it defined like this???)

    So I made this line in the conditional branch of a parallel process event

    (pbGetTimeNow.mon==6 && pbGetTimeNow.day>=21) || pbGetTimeNow.mon == 7 || pbGetTimeNow.mon == 8 || (pbGetTimeNow.mon == 9 && pbGetTimeNow.day <21)

    I would like to add it in the script so I can use the function pbIsSeason correctly

    I guess I must adapt it like this:

    if (pbGetTimeNow.mon==6 && pbGetTimeNow.day>=21) || pbGetTimeNow.mon == 7 || pbGetTimeNow.mon == 8 || (pbGetTimeNow.mon == 9 && pbGetTimeNow.day <21) end

    how can I do that? I'm not sure how I should add it
     
    Last edited:
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Wow, I just looked at it and pbIsSeason is very weird.

    From having looked a bit at the code, and also at pbIsSpring, pbIsSummer, etc, I think the idea is that you pass a variable to store the name of the season in, and then any number of seasons (where 0=spring, 1=summer, 2=fall, 3=winter) and you get returned a true if the current season is any of those seasons.

    … but then we look at pbGetSeason and it's also very weird:

    Code:
    def pbGetSeason
      return (pbGetTimeNow.mon-1)%4
    end

    Correct me if I'm wrong, but it sounds like you want to rip all that code out and replace it with your own functionality that checks for the seasons properly (instead of having them change every month). To do that all you need to do is return the appropriate number based on what you want the season to be, e.g.

    Code:
    def pbGetSeason
      return 0 if ...
      return 1 if (pbGetTimeNow.mon==6 && pbGetTimeNow.day>=21) || pbGetTimeNow.mon == 7 || pbGetTimeNow.mon == 8 || (pbGetTimeNow.mon == 9 && pbGetTimeNow.day <21)
      return 2 if ...
      return 3
    end

    You'll need to fill in the … for spring and fall. Note that I return 3—i.e. winter—if neither of the other three conditions matched, so you don't need to explicitly check for winter (this means that if you have a bug in how you compute the other season ranges we'll default to winter instead of crashing the game).
     
    153
    Posts
    4
    Years
    • Seen Feb 4, 2020
    Haha bro, you are everywhere.
    indeed I planned on ripping that on entirely

    Thank you so much!

    Edit: I think it's going to work, though I still have to call it each time like
    Code:
    pbSet(45,pbGetSeason)
    return "Spring" if pbGet(45)==0


    because I don't know how to do global switches and variables. How can I do so the number of the season is always and automatically stored in the variable 45?
     
    Last edited:
    153
    Posts
    4
    Years
    • Seen Feb 4, 2020
    So if someone is interested in using season properly here is what you need to do:

    1) go in PField_time
    2)Put all this in comment
    Code:
    #def pbGetSeason
    #  return (pbGetTimeNow.mon-1)%4
    #end
    
    #def pbIsSeason(seasonVariable,*arg)
     # thisseason = pbGetSeason
     # ret = false
     # for wd in arg
     #   ret = true if wd==thisseason
     # end
     # if seasonVariable>0
     #   $game_variables[seasonVariable] = [ 
     #      _INTL("Spring"),
     #      _INTL("Summer"),
     #      _INTL("Autumn"),
     #      _INTL("Winter")][thisseason] 
     #   $game_map.need_refresh = true if $game_map
     # end
     # return ret
    #end
    3)add this:
    Code:
    def pbGetSeason
      return 0 if (pbGetTimeNow.mon==3 && pbGetTimeNow.day>=21) || pbGetTimeNow.mon == 4 || pbGetTimeNow.mon == 5 || (pbGetTimeNow.mon == 6 && pbGetTimeNow.day <21)
      return 1 if (pbGetTimeNow.mon==6 && pbGetTimeNow.day>=21) || pbGetTimeNow.mon == 7 || pbGetTimeNow.mon == 8 || (pbGetTimeNow.mon == 9 && pbGetTimeNow.day <21)
      return 2 if (pbGetTimeNow.mon==9 && pbGetTimeNow.day>=21) || pbGetTimeNow.mon == 10 || pbGetTimeNow.mon == 11 || (pbGetTimeNow.mon == 12 && pbGetTimeNow.day <21)
      return 3
    end
    4)do an event like this
    pbSet(45,pbGetSeason)
    if pbGet(45)==0
    Kernel.pbMessage("it's spring")
    #I'm not sure about this syntax I didn't use the kernel.pbMessage script
    if pbGet(45)==1 end
    ...

    If someone knows how to update a variable all the time it would make this way easier to use <3
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    4)do an event like this
    Code:
    pbSet(45,pbGetSeason)
    if pbGet(45)==0
    Kernel.pbMessage("it's spring")
    end
    if pbGet(45)==1
    ...
    end

    If someone knows how to update a variable all the time it would make this way easier to use <3

    I don't know exactly how the syntax works, but maybe you could use simply use "pbGetSeason" everywhere that you're using the variable? e.g.:

    Code:
    if pbGetSeason==0
    Kernel.pbMessage("it's spring")
    end
    if pbGetSeason==1
    ...
    end

    Presumably this means we'll always recompute which season it is every time the script needs to check, and so there's nothing to keep updated?
     
    Last edited:
    153
    Posts
    4
    Years
    • Seen Feb 4, 2020
    Yeah sure. I just find it even more complete if we have a dedicated switch like the "PBDayNight.IsDay?" And actually I'm asking because I'am much interested in how to script global switches :)
     
    Last edited:
    18
    Posts
    5
    Years
    • Seen Sep 4, 2019
    So when im using my pbIsSeason in my script when it july it say Autumn if January it say summer how can i fix this?
     

    HM100

    HM100 the Techno
    113
    Posts
    7
    Years
    • Seen Apr 27, 2024
    Note that this behavior is also intentional in Generation V games as well so Essentials follows by default the Gen5 formula
     
    153
    Posts
    4
    Years
    • Seen Feb 4, 2020
    So when im using my pbIsSeason in my script when it july it say Autumn if January it say summer how can i fix this?

    Try to check the formula but to me it looks good. the first line says "if the month is the 3rd, after the 21th day (so march 21th) or it's the 4 month or the 5th or the 6th (june) before 21 then pbGetSeason will return 0.

    When in your event it's translating 0 into "it's spring"

    sorry for answering so late tell me if you still have problems
     
    Back
    Top