Repeat Events without Individual Switches

stopbeingbored

Villager
Member
Joined
Mar 30, 2015
Messages
9
Reaction score
3
First Language
German
Primarily Uses
RMMV
Hello all,

Me again. This time I am trying to make a general event, which gives resources, repeat without giving it an individual on/off-switch; in this example, a tree.

Setup (Which I already have and is working):
1. Event "tree" is empty until random variable "resource spawn" = 1.Test Tree 1.PNG
2. Once "resource spawn" = 1, the tree appears and can be interacted with.
Test Tree 2.PNG
3. Hitting the tree with an axe activates self-switch B, which looks like a tree stump.
Test Tree 3.PNG
4. Hitting the stump with an axe gives item "wood" and activates self-switch C, which has a blank sprite.
5. On the self-switch B page, whenever the variable "resource spawn" is next =1, it will deactivate all self switches and repeat the process.
Test Tree 4.PNG

The problem here is probably evident: If the variable = 1, the tree appears, but by the time it is felled, the variable might still be =1, causing it to instantly reappear rather than with a delay of e.g. a day (in the evented time system I am using).

My issue is that I want to be able to create dozens, if not more, of these events, to scatter around maps for random chances to get wood. However, I want to do this without having to create an individual on/off switch for every single one of them, and rather make it a simple copy-paste-event.

Is this possible, or am I doomed to use a final individual off-switch per tree?

Many thanks for your help. I hope this makes sense, but please let me know if you require further explanation.

SBB
 
Last edited:

fizzly

Veteran
Veteran
Joined
Mar 23, 2012
Messages
596
Reaction score
368
First Language
Polish
Primarily Uses
RMMV
You can't do that without a script, then, because you need to set switch/variable for every single tree. Your solution is... Self Switches & Variables by YEP, or by Ivra, or HimeWorks I think.
 

stopbeingbored

Villager
Member
Joined
Mar 30, 2015
Messages
9
Reaction score
3
First Language
German
Primarily Uses
RMMV
I have the self switches plug-in, which is working great, but they don't help with my problem, only make it... longer. :'D

However, I understand that this might not be possible. Thank you for taking the time to respond.
 

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
165
First Language
English
Primarily Uses
RMMV
You don't need a plugin for this. You can assign the tree its own variable, let's call it regrow, with a script call:
JavaScript:
$gameMap.event(this.eventId()).regrow === undefined && ($gameMap.event(this.eventId()).regrow = 0);
Then everytime the resource spawn is 1 do this script call:
JavaScript:
$gameMap.event(this.eventId()).regrow += 1;
So now the tree has it's own "growing" variable that increases whenever your resource spawn is ready. Then let's say you want the tree to be done growing after two resource cycles, you put this into the script section of a conditional branch:
JavaScript:
$gameMap.event(this.eventId()).regrow >= 2;
And then deactivate the self switches in that conditional branch, and also remember to reset the tree's regrow variable with a script call:
JavaScript:
$gameMap.event(this.eventId()).regrow = 0;

You might want to tune your resource spawn to happen more often if you think the tree regrows too slowly.
 
Last edited:

stopbeingbored

Villager
Member
Joined
Mar 30, 2015
Messages
9
Reaction score
3
First Language
German
Primarily Uses
RMMV
@ozubon Thank you for your help! I am an absolute beginner when it comes to using scripts, but I think I understand. I will try to implement this tonight or tomorrow morning and see if I can get it to work. :smile:
 

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
165
First Language
English
Primarily Uses
RMMV
No problemo! I'm not 100% I understand how your resource spawn variable works but I took a guess.
If you're having trouble with the script calls or my tip in general just let me know :)
 

stopbeingbored

Villager
Member
Joined
Mar 30, 2015
Messages
9
Reaction score
3
First Language
German
Primarily Uses
RMMV
Ack, I'm sorry @ozubon, but I am failing at the first step... How do I assign the tree its own variable, please? Will I need separate event pages for it? And do I have to fill in any bits of the script call with my map and event IDs or is that already automatically assigned through the script? ^^; as I said, I've never really used scripts before!
 

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
165
First Language
English
Primarily Uses
RMMV
You call this one whenever you like, but before you do any of the other script calls:
JavaScript:
$gameMap.event(this.eventId()).regrow === undefined && ($gameMap.event(this.eventId()).regrow = 0);
I guess in the setup on page one, before the first control self switch? It only does what it does once so you don't have to worry about it resetting anything, just call it before the other script calls and it should do its job.

No, you don't have to fill in anything. You only have to replace this.eventId() with an event id if you're doing it from separate event or a common event. Otherwise this.eventId() refers to the event that's using it. So you can leave it just as it is as long as it's called from the event it's intended for :')

Don't be apologetic about that you haven't really used scripts, that breaks my heart! There's a first for everything, never mind bungholes who judge you for not knowing something!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,141
Reaction score
12,416
First Language
English
Primarily Uses
RMMV
You could use my multi timer plugin and self switches.

 

stopbeingbored

Villager
Member
Joined
Mar 30, 2015
Messages
9
Reaction score
3
First Language
German
Primarily Uses
RMMV
@Shaz I actually looked at similar plugins, but this would conflict with the day/night system I have built... Thank you though! I might check it again if I exhaust my other options.

@ozubon Thank you for your kind words, that means a lot. I have managed to get the event to work, but sadly it now reproduces my original error, which is that once I have completed the event, it immediately respawns from the beginning as the resource variable is still set to 1... am I making a mistake somewhere please?

Tree Autorun 1.PNG
Test Tree X.PNG
Test Tree Y.PNG
 

Attachments

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
165
First Language
English
Primarily Uses
RMMV
The resource variable should only go to 1 every now and then, after a random time am I right?
You have a system that adds 1 to the resource variable various times during the day cycle?

As you have it setup now nothing "eats" that resource variable. So on page 4 of the tree the first conditional will be true two times really fast and then before you know it the second one is true too.

What the computer thinks now at lightning speed is bascially:
if Resources is 1, add 1 to regrow
sure is, let's add 1 to regrow
OK, regrow is now 1
if regrow is 2 or more, turn off every self switch
regrow isn't that, do nothing
OK, end of the line, let's go back to the top
if Resources is 1, add 1 to regrow
still holds true, let's add 1 to regrow
OK, regrow is now 2
if regrow is 2 or more, turn off every self switch
regrow is that, let's turn off every self switch

In the first branch on page four, after $gameMap.event(this.eventId()).regrow += 1; set Resources to 0.
That way the regrow variable won't immediately fill up, but have to wait until Resources is 1 again.

EDIT:
:kaodes: Just realized you don't need the script calls at all, all you had to do in your original setup is set Resources to 0 in the final page and set the first page to be parallell. Way to overcomplicate things huh!

But heyy cool flashy scripts I guess smh
 
Last edited:

stopbeingbored

Villager
Member
Joined
Mar 30, 2015
Messages
9
Reaction score
3
First Language
German
Primarily Uses
RMMV
!!!!!

@ozubon I worked it out, thank you so much! This means I now need only a variable per map, not one per resource. You're fantastic.

Also, I feel like I have learned a lot about how scripts work in MV with this, and by watching some tutorials last night. All in all, I am very happy. :kaojoy:
 

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Profile Posts

Any also thought it's too cringy to put the word "and you" in your credit as a special thanks?
Cause that's what I thought...
Everyone in the US right now: Please stay safe.
Symphony Celestia: Prophecy of the Falling Stars RPG Maker music pack WIP. Symphony Celestia is a new series that focuses on symphonic and orchestrated music to tell a story. Each story will include compositions that make up that story from beginning to end. Themes include: Battles, adventures, character themes, etc. Below is a video preview to the first story.

Jumping and gravitation 0.1 build - RPG Maker MV
It's ironic, but one of the many hilarious things done with Shia's Just Do It speech was to make a hype song, and....I know what it is.....but I still get inspired by it! I'm like..."Yes I can!!"

Forum statistics

Threads
97,975
Messages
948,246
Members
129,227
Latest member
HamadAhli
Top