• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Assistance w/ adding a value per value.

flyinian

Member
I have a time system in my game. Minutes, Days, months, years. What are ways that I could add a value(lets say 100) for every day that passes in game?

I know I could go:

GML:
if (day == 1 || day == 2 || ect.)
{
    value += 1;
};
That will only add 1 if day is equal to 1. Are there better ways of doing this?

As always, Thank you.
 
Last edited:
H

Homunculus

Guest
You can use the mod operator to check for that. I imagine you have code somewhere that is supposed to advance the in game time as well as days etc..., in there you can do something like
GML:
if(day mod 5 == 0) {
    //action that happens every 5 days
}
 

flyinian

Member
You can use the mod operator to check for that. I imagine you have code somewhere that is supposed to advance the in game time as well as days etc..., in there you can do something like
GML:
if(day mod 5 == 0) {
    //action that happens every 5 days
}
Okay, thank you. I'll give this a try.
 
Top