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
341
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,552
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
341
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 wonder... If I develop my own game hacks, does it count as beating the game my own way?
First 12 minutes of gameplay.

bio-Synthetica's Database plugin is complete. Players will be able to find and unlock various tutorials and lore as they reach certain points. There are 5 categories of files you can unlock: Audio Clips, Data Files, Bestiary, Earth History, and Tutorials.

1653160049600.png

Thank you Dsiver for this amazing plugin! :kaothx:
My favorite kind of progress? Reverse progress! First, change some small feature of your game. Second, go back through and change 6,000 tiny things related to that minor alteration just to get your game playable again. What fun!

Forum statistics

Threads
122,011
Messages
1,145,882
Members
160,280
Latest member
Dion40
Top