Is there a way to reset an event based on my time system? More info inside.

Status
Not open for further replies.

Crazya

Veteran
Hey, I am always grateful for the amount of help I get from this forum.

I'm not sure if this needs a script or not.

I will work on a system where A player can buy a house and rent it out and have them collect gold every 7 days in-game time.

Time system for reference: Once 24 hours hits it = to 1 day

Now, in theory, I can do IF day = 7: grabrent on. Collect a payment, grabrentoff. I know, in theory, I could do conditional branches if I'm correct and set it 7, 14, 21, and so on.

My question is, is there a way to simplify this and make it Turn the switch on every multiple of 7? or do I need a script?

Thank you, and I hope I made sense. I appreciate it in advance.

Drakkonis

Veteran
If you never reset your day count, you could use mod, or modulo. Every time you increase the day, see if day mod 7 = 0(I think it would be dayvariable % 7 in script, but there's a way in the control variable event command, too). Mod returns a remainder after dividing two numbers, so if day mod 7 equals 0, it's a multiple of 7.

Crazya

Veteran
If you never reset your day count, you could use mod, or modulo. Every time you increase the day, see if day mod 7 = 0(I think it would be dayvariable % 7 in script, but there's a way in the control variable event command, too). Mod returns a remainder after dividing two numbers, so if day mod 7 equals 0, it's a multiple of 7.

I have never used the Mod option before. I'm noob I am sorry. I haven't really used scripting but with event selection this is how it looks like

I also realized there is an option for "Multi" would that work too?

Though, i'm not sure how this works in a condtional branch or how I'd be able to turn on switch deppendent on Control variable mod.

SuzuMito7u7

Suzu
Not very sure but I found this, "n" shows all the multiples in console and "multiples" shows how many multiples are between 1-100. Hope this can help!
JavaScript:
``````function multiple(n, multiple)
{
resto = n % multiple;
if(resto==0){
console.log(n);
return true;
}else{
return false;
}}

var multiples=[];

for(var i=1;i<=100;i++)
{
if(multiple(i,7)){
multiples.push(i);
}

}
console.log("Multiples of 7:", multiples)``````

Drakkonis

Veteran

I have never used the Mod option before. I'm noob I am sorry. I haven't really used scripting but with event selection this is how it looks like

View attachment 184565

I also realized there is an option for "Multi" would that work too?

View attachment 184566

Though, i'm not sure how this works in a condtional branch or how I'd be able to turn on switch deppendent on Control variable mod.
If you're talking about "Multi" in the control variables command, that's for multiplication.
In scripting, * is multiplication, / is division, and % is mod. The event command "shorthand" you see uses the script operators in the display.

If you use the event command you show at the beginning, it will make your Day variable be the mod result, which you DON'T want, because that will overwrite your day count. You want to set another variable to Day's amount, then mod the new variable and check THAT in your event.

Basically, set any old variable you're not using equal to the value of your day variable. Then mod the new variable, which will set its value to the remainder. Then, check the value in a conditional branch. If that value is 0, turn your switch on.

Crazya

Veteran
Not very sure but I found this, "n" shows all the multiples in console and "multiples" shows how many multiples are between 1-100. Hope this can help!
JavaScript:
``````function multiple(n, multiple)
{
resto = n % multiple;
if(resto==0){
console.log(n);
return true;
}else{
return false;
}}

var multiples=[];

for(var i=1;i<=100;i++)
{
if(multiple(i,7)){
multiples.push(i);
}

}
console.log("Multiples of 7:", multiples)``````
Interesting! to be honest, I wouldn't even know where to begin by using this. Sorry, I need to learn since things like this is great =0. Thank you!
If you're talking about "Multi" in the control variables command, that's for multiplication.
In scripting, * is multiplication, / is division, and % is mod. The event command "shorthand" you see uses the script operators in the display.

If you use the event command you show at the beginning, it will make your Day variable be the mod result, which you DON'T want, because that will overwrite your day count. You want to set another variable to Day's amount, then mod the new variable and check THAT in your event.

Basically, set any old variable you're not using equal to the value of your day variable. Then mod the new variable, which will set its value to the remainder. Then, check the value in a conditional branch. If that value is 0, turn your switch on.
oh! Thank you for explaining it to me!

Hmm, something like this? forgive me if it's wrong. I may be overthinking it.

THANK YOU THIS WORKS PERFECTLY OMG.

Last edited:

Shaz

Global Moderators

Status
Not open for further replies.

Latest Profile Posts

Is RPG Maker VX (rgss2) still relevant? xD

I have never felt so attacked by a tree before it took 10++ hours to make but at least it looks pretty LOL

now seems like the worst time for me to need a better computer with how much stuff is costing. that and I don't thing there's much else I can do to make MV run any better with what I have.
Sigh... to have some variety in this weather. More than just sun and rain and wind and thunder.
In the meantime, I've discovered that I'm slowly becoming fatigued from the many sleepless nights my neighbors cause. Or at least their dogs. Always barking at something.
I might need a day to just sleep and recharge.