• 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] Setting weather according to the day of the week?

  • 87
    Posts
    8
    Years
    • Seen Jul 24, 2016
    Hey I´ve trying to do this for a while, I would like to change the weather system in essentials, not based in a probability but in the day of the week.
    For example: if it is tuesday it will rain....Friday it will be a sunnyday and on and on....
    If this is too hard to accomplish do not bother yourself.
     
    Last edited by a moderator:
  • 129
    Posts
    8
    Years
    • Seen Mar 23, 2023
    The method pbGetTimeNow returns a Ruby time object set to the current time. The object has a property wday, which returns the current day of the week as an integer, with Sunday being 0, Monday being 1, etc. In your event or function where you set the weather, you can use something like the following:

    Code:
    timenow=pbGetTimeNow
    if (timenow.wday==2) #If it is Tuesday
      #code or event commands to set the whether to rainy
    elsif (timenow.wday == 5) #If it is Friday
      #code or event commands to set the whether to sunny
    end

    There is also a Essentials function pbIsWeekday which allows you to check multiple days and/or set the name of the current weekday into a variable. The first argument is a global variable number to store the name of the day in. Every argument after is which days of the week you'd like to check.

    Code:
    # Let's pretend its Tuesday:
    pbIsWeekday(1) #Sets global variable 1 to "Tuesday" so you can use "\v[1]" in text messages to print out "Tuesday" today
    pbIsWeekday(0,2) #Returns true, because today is Tuesday. Doesn't set any global variables
    pbIsWeekday(1,0,5,6) #Returns false, because it is checking for Sunday, Friday, or Saturday, and stores "Tuesday" in global variable 1
    pbIsWeekday(2,1,2) #Returns true, because it is checking for Monday or Tuesday, and stores "Tuesday" in global variable 2

    So you can do like so:

    Code:
    if (pbIsWeekday(0,2,3))
      #The above condition will be true if it is Tuesday or Wednesday
      #code or event commands to set the whether to rainy
    end
     
  • 87
    Posts
    8
    Years
    • Seen Jul 24, 2016
    The method pbGetTimeNow returns a Ruby time object set to the current time. The object has a property wday, which returns the current day of the week as an integer, with Sunday being 0, Monday being 1, etc. In your event or function where you set the weather, you can use something like the following:

    Code:
    timenow=pbGetTimeNow
    if (timenow.wday==2) #If it is Tuesday
      #code or event commands to set the whether to rainy
    elsif (timenow.wday == 5) #If it is Friday
      #code or event commands to set the whether to sunny
    end

    There is also a Essentials function pbIsWeekday which allows you to check multiple days and/or set the name of the current weekday into a variable. The first argument is a global variable number to store the name of the day in. Every argument after is which days of the week you'd like to check.

    Code:
    # Let's pretend its Tuesday:
    pbIsWeekday(1) #Sets global variable 1 to "Tuesday" so you can use "\v[1]" in text messages to print out "Tuesday" today
    pbIsWeekday(0,2) #Returns true, because today is Tuesday. Doesn't set any global variables
    pbIsWeekday(1,0,5,6) #Returns false, because it is checking for Sunday, Friday, or Saturday, and stores "Tuesday" in global variable 1
    pbIsWeekday(2,1,2) #Returns true, because it is checking for Monday or Tuesday, and stores "Tuesday" in global variable 2

    So you can do like so:

    Code:
    if (pbIsWeekday(0,2,3))
      #The above condition will be true if it is Tuesday or Wednesday
      #code or event commands to set the whether to rainy
    end
    Ty, I guess that will work. The rest is up to me.
     
    Back
    Top