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
340
Reaction score
446
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,969
Reaction score
4,549
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
340
Reaction score
446
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

I've been trying very hard to distance myself from my inspirations, but maybe It would be better just to accept it.
3uL5XnP.gif
For my 100th post, I wanted to thank this forums community for the generosity and respect that each of you show.

I'm always impressed when I see the 6x veterans (in number of years compared to my presence here on these forums) continue to help and support all the community members on a daily basis, the awesome artists who share their creations with so much passion...
If a person becomes voluntarily missing, does it cause the butterfly effect?
normal_water_is_fine.jpg

Just going to use stationary water for the randomized maps. Sure, particles would look cool... But this is about compromising and not spending countless hours making the perfect water particle for each set piece with water. :kaoswt:
Maybe I should get rid of the Banish ability in my game. It's a non-elemental spell that doesn't even appear in the magic chart. It's only there because my Elementalist doesn't use light or dark magic. It only effects summoned creatures.

Forum statistics

Threads
121,912
Messages
1,145,147
Members
160,181
Latest member
lewzah
Top