Serpenking

Warper
Member
Joined
Jan 22, 2022
Messages
3
Reaction score
2
First Language
English
Primarily Uses
RMMV
So, I'm a beginner playing around with the software, going fairly smoothly, but I have a bit of an issue. I'm trying to work on some basic farming sim mechanics, starting with collecting milk from animals.

My initial plan was when the player interacted with the animal and received milk, a switch would trigger, prompting a message explaining that the animal could not be milked again until tomorrow.

I added a "going to bed" event on the bed that reset this switch, allowing the player to collect milk "the next day"

However I realize will get messy once more animals are added into the equation, as each animal's daily resource would have to be it's own switch.

I was wondering if there was an easier/more concise way to do this "daily reset" mechanic?

I played around with the self switches as that concept seemed to fit what I was going for better, but then realized that self switches are supposed to be permanent, single use type of switches. Is there a way to make the "go to bed" event force these self switches to turn back off?
 

SeaPhoenix

Veteran
Veteran
Joined
May 14, 2015
Messages
347
Reaction score
454
First Language
English
Primarily Uses
RMMV
You can use a script call to control other events' self switches, where value is true to turn it on and false to turn it off:
Code:
$gameSelfSwitches.setValue([mapId, eventId, switchId], value);

So for example, let's say the cow is on map 1, its event id is 5, and you had turned on self switch A when milking the cow. In your "going to bed' event, you can use the following code in script call to turn that self-switch off:
Code:
$gameSelfSwitches.setValue([1, 5, 'A'], false);

You can copy-and-paste the code above and just change the mapIds and eventIds for all the animal events.

If you're familiar with Javascript or would like to learn more, you can put the eventIds in an array; see the script call list here for "Turn on/off self switches (range)":
https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-mz-script-call-list.46456/
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
4,977
Reaction score
4,587
First Language
English
Primarily Uses
RMMZ
So, I'm a beginner playing around with the software, going fairly smoothly, but I have a bit of an issue. I'm trying to work on some basic farming sim mechanics, starting with collecting milk from animals.

My initial plan was when the player interacted with the animal and received milk, a switch would trigger, prompting a message explaining that the animal could not be milked again until tomorrow.

I added a "going to bed" event on the bed that reset this switch, allowing the player to collect milk "the next day"

However I realize will get messy once more animals are added into the equation, as each animal's daily resource would have to be it's own switch.

I was wondering if there was an easier/more concise way to do this "daily reset" mechanic?

I played around with the self switches as that concept seemed to fit what I was going for better, but then realized that self switches are supposed to be permanent, single use type of switches. Is there a way to make the "go to bed" event force these self switches to turn back off?
I've actually submitted a tutorial for how to create events for timer-based respawning gathering nodes which would be perfect for this, just waiting for approval.
 

Serpenking

Warper
Member
Joined
Jan 22, 2022
Messages
3
Reaction score
2
First Language
English
Primarily Uses
RMMV
You can use a script call to control other events' self switches, where value is true to turn it on and false to turn it off:
Code:
$gameSelfSwitches.setValue([mapId, eventId, switchId], value);

So for example, let's say the cow is on map 1, its event id is 5, and you had turned on self switch A when milking the cow. In your "going to bed' event, you can use the following code in script call to turn that self-switch off:
Code:
$gameSelfSwitches.setValue([1, 5, 'A'], false);

You can copy-and-paste the code above and just change the mapIds and eventIds for all the animal events.

If you're familiar with Javascript or would like to learn more, you can put the eventIds in an array; see the script call list here for "Turn on/off self switches (range)":
https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-mz-script-call-list.46456/
Thank you for replying! It means a lot. So, I would use the above code in the event page, under the "script" command? And I would need a line for each animal?
 

SeaPhoenix

Veteran
Veteran
Joined
May 14, 2015
Messages
347
Reaction score
454
First Language
English
Primarily Uses
RMMV
@Serpenking yes, use "Script" on the 3rd page of the event commands. You can type in multiple script calls in the box that pops up, but there's a limited number of lines available (maybe 10-12?). But you can type in multiple things on one line; just make sure each script call is separated by a semi-colon, e.g.:
Code:
$gameSelfSwitches.setValue([1, 5, 'A'], false); $gameSelfSwitches.setValue([2, 3, 'B'], false);

If you end up using all the lines in that box, just use another script command after that. (Or you can use a for loop with the eventIds in an array as mentioned earlier to keep things more succinct.)
 

Serpenking

Warper
Member
Joined
Jan 22, 2022
Messages
3
Reaction score
2
First Language
English
Primarily Uses
RMMV
@Serpenking yes, use "Script" on the 3rd page of the event commands. You can type in multiple script calls in the box that pops up, but there's a limited number of lines available (maybe 10-12?). But you can type in multiple things on one line; just make sure each script call is separated by a semi-colon, e.g.:
Code:
$gameSelfSwitches.setValue([1, 5, 'A'], false); $gameSelfSwitches.setValue([2, 3, 'B'], false);

If you end up using all the lines in that box, just use another script command after that. (Or you can use a for loop with the eventIds in an array as mentioned earlier to keep things more succinct.)
Once again thank you! That clears things up! I really appreciate it.
 

Latest Threads

Latest Profile Posts

Playing FF4 for the first time, the pacing is pretty insane o_O Only 2.5 hours in and already changing class? I barely got to play as the first one xD
One year and two days ago, I got RMMV. So far I have:

» Gotten Ideas™ from VXA’s music.
» Made a test project to teach myself the basics.
» Successfully done up a no-combat outline for Ideas™.
» Entered the Boss Battle Build Bout.
» Burned out for over seven months after trying the One Map Challenge.
» Found my groove again about a month ago.

And it feels good to be back on track again.
Let there be light!

Forum statistics

Threads
123,063
Messages
1,153,708
Members
161,401
Latest member
Otak5313
Top