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

Status
Not open for further replies.

Crazya

Veteran
Veteran
Joined
Mar 2, 2021
Messages
53
Reaction score
21
First Language
English
Primarily Uses
RMMZ
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 day1617206906261.png

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
Veteran
Joined
Mar 5, 2021
Messages
210
Reaction score
162
First Language
English
Primarily Uses
RMMZ
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
Veteran
Joined
Mar 2, 2021
Messages
53
Reaction score
21
First Language
English
Primarily Uses
RMMZ
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.

Firstly, thank you for replying!

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

1617213102729.png

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


1617213170736.png

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.
 
Joined
Oct 6, 2019
Messages
45
Reaction score
12
First Language
Spanish
Primarily Uses
RMMV
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
Veteran
Joined
Mar 5, 2021
Messages
210
Reaction score
162
First Language
English
Primarily Uses
RMMZ
Firstly, thank you for replying!

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
Veteran
Joined
Mar 2, 2021
Messages
53
Reaction score
21
First Language
English
Primarily Uses
RMMZ
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.


1617215076100.png



1617218214964.png


THANK YOU THIS WORKS PERFECTLY OMG.
 
Last edited:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,646
Reaction score
15,730
First Language
English
Primarily Uses
RMMV

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

Is RPG Maker VX (rgss2) still relevant? xD
ZyCHqk2.png

Something about top-downs.
I have never felt so attacked by a tree before :LZSlol: it took 10++ hours to make but at least it looks pretty LOL

Untitled-1.png
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.

Forum statistics

Threads
118,454
Messages
1,116,101
Members
155,437
Latest member
PipingHotRamen
Top