Jump to content

Welcome to Xbox Society

Xbox Society is an adults only gaming community.  We operate a casual, laid back approach because we appreciate that when you factor in family, work etc.. you might not get a lot of time on your beloved xbox and gaming hobby so the time you spend here needs to be hassle free and fun.

We have plenty of casual challenges and competitions, coupled with weekly gaming events and a friendly, vibrant community
Register
JasonSchlueter

Seasonal Checker

Recommended Posts

In Project CARS 2 randomizer I've been posting about, I've had a very simple method of determining in which season the random date falls.  I simply choose the month (not exact but good enough) and "reverse" the season if it's in Oceania or Africa.  It's verbose but easy to read.

 

    if ($thetrack[0] -notin ("Oceania","Africa"))
        {
            if ($thetime.Month -in (3, 4, 5))
                {$theseason = "Spring"}
            elseif ($thetime.Month -in (6, 7, 8))
                {$theseason = "Summer"}
            elseif ($thetime.Month -in (9, 10, 11))
                {$theseason = "Fall"}
            elseif ($thetime.Month -in (12, 1, 2))
                {$theseason = "Winter"}
        }
    else
        {
                if ($thetime.Month -in (3, 4, 5))
                {$theseason = "Fall"}
            elseif ($thetime.Month -in (6, 7, 8))
                {$theseason = "Winter"}
            elseif ($thetime.Month -in (9, 10, 11))
                {$theseason = "Spring"}
            elseif ($thetime.Month -in (12, 1, 2))
                {$theseason = "Summer"}
        }

I was thinking about doing this a different way, like saying this is the month then separately reversing the month if the continent was one of those two but it seemed like too much work.  Are there any programmers or scripters who can think of a slick way to do this?  This works just fine - I just like to keep code clean and efficient.

Share this post


Link to post
Share on other sites

you could try using a "for loop" statement, have a loop go through the different conditions and when it matches it is then triggered and returns a function object or continues the next line of code. for example:

for (var i = 0; i < Weather.Count; i++)
{
  // matching statements here
}
return;

something along those lines if that makes sense.

  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×