# Using logic to dictate days, months and years in game

## How do I…

In creating an event upon which a button press adds one to the value of the day I have encountered an issue.

I have date month and year as numeric variables and I had managed it to go ok but every month had 31 days so I tried to fix this using while loop to check if values are equal to the numeric vale of the month . i.e. if 4 (April) = 30 (as it has 30 days) then add one to the month variable and set day back to one. the same for 28 days for February and the rest are 31.

## What is the expected result

I expected or hoped the months would act correctly and change as specified.

## What is the actual result

The game then crashes when I try to go from day 30 to 31, I am assuming I have done some form of loci wrongly or my event structure isn’t quite right.

## Related screenshots

Any help would be greatly appreciated, it really should be simple but evidently not for me

I using this to loop around 4 digits

Now what you see here is
If i press F1 then 2nd action will add to variable save p1 id 1
BUT i do not want it to go above 4
That is why above it i have action to mod that variable

What it does mod(Save.P1.ID,4) ← After ID there is comma since it is expect as mod(Number , Number)
And variable uses dots not comas

Anyway what it does is
i do not remember how to technically call it but
mod(number to mod , value of of how high it can go)

So if you would have variable Seconds for example where each second adds 1 to it
And you want it to loop around 10
Then you would use
Change variable Seconds set to mod(Seconds,10)
IF it would be for minutes and you would wish to loop around 60
mod(Minutes,60)
Now i hope you get idea how it works

Now another tricky part is
As you see in screenshot i have trigger once in condition
And thanks to it
IF 1st is change variable set to
Then below is change variable add 1
Then it will loop trough 1 2 3 4 skipping 0

BUT if i reverse order

And below is mod

Then it will loop to 3 from 0
So 0 1 2 3

I think if i would not use trigger once it would also mod trough 0 1 2 3
Since that counts 4 digits
So order of actions is crucial here

Now armed with that knowledge
You make condition
To mod your variable Days to whatever you want
For example
Imagine you have idk febuary which have 29 days
But you count have 31 days by default yet you want it to count 29 starting from 1 and ending on 29

Then you go with
Condition variable month is equal to 2 (or febuary if it is string)
Here you need to have some condition that will kick start it every day
For example if time is 00:00 hours
Trigger once

Action
Change variable Days set to mod(Days,29)

And you do same crap for other months
You can have multiple months as same condition for example here in condition you could put every single month that counts 29 days

Now i guess you would need to also have some event to which would check what day of month it is so it switches to next month
But i guess if you get so far you will be able to figure it out
If not i would have few stupid ideas

Brother, this is unnecessary. Just use an array.