Event Page Order Help

I did recommend Galv's system as an out-of-the-box solution but since you were willing to put in the work for a custom solution I was willing to help you get it done. If you PM me about any issue you have I'll give you the best answer I can.


Don't let that get you down. We have regular posters here who cannot read or write code but are making steady progress on their games, and programming is just one aspect of game dev. People won't even download a game if they don't like how it looks, no matter how optimally programmed it is. I've also seen people raving about games that were full of bugs and randomly crashed.
Yeah, I definitely know that. Orange Season looks pretty and was doing really well, but now people buy it for aesthetics and the coding is awful after the change of hands.
And yet you've also said in a few places that syntactically valid JavaScript isn't working in your project. This tells me that something is wrong, whether you see evidence of it or not.

To be fair, I just looked into the common event thing and Yanfly did specifically add code that stores which map event is calling a common event, so self variables/switches used in it will correctly refer back to the original map event. That's pretty neat, and I didn't know it did that.

Aside from that...I don't know what to say beyond what I already have.
And I will admit, I did a stupid ass mistake and forgot to change my bottom self variable this.setSelfVariable things so I was checking for varId instead of the variable number. So I apologize for missing it, my ADHD makes me miss stuff like that super easily.
That's the thing. If I create Plant A and Plant B, and Plant A dies, then Plant B will continue to act as its own plant. It's only when plant C, D, etc. are created that the issue occurs.
Are you using Yanfly's Event Copier like in the tutorial and are any of plant A, B, C, or D copied from the same event template?
Are you using Yanfly's Event Copier like in the tutorial and are any of plant A, B, C, or D copied from the same event template?
I am using the event copier tutorial listed here http://yanfly.moe/2018/07/13/eventing-a-foraging-system-rpg-maker-mv/!

A, B, C, etc are copied from the same event template as I am theory crafting for a singular plant for now. I would like it to branch out into becoming I have multiple events per seed. The reason for why fixing this one is so important is because if a player wants to plant a lot of the same crop, I would like them to have that option. I feel if having 100+ (just a random number) of the same crop to account for issues like that is far more clunky and bad than if I have a template crop that can be edited to fit each plant. You know what I mean?

Using @ATT_Turan 's method of condensing the variables is working because I have fixed my dumbass mistake, and again, many apologies for that.

Code:
mapId = $gameVariables.value(18);var eventId = $gameVariables.value(19);
var water = this.getSelfVariableValue(mapId, eventId, 26);
var death = this.getSelfVariableValue(mapId, eventId, 30);
var harvest = this.getSelfVariableValue(mapId, eventId, 31);
if (water <= 0) death -= 1;
if (water > 0) water -= 1;
if (water > 0) harvest -= 1;
this.setSelfVariableValue(mapId, eventId, 26, water);
this.setSelfVariableValue(mapId, eventId, 30, death);
this.setSelfVariableValue(mapId, eventId, 31, harvest);

So this all checks the map number with 18 being the first Map ID and 19 being the last Map ID checked. Var water = variable 26 which is my "watered or not" variable. 0 for no, 1 for yes. Var death is variable 30 which keeps track of days not watered, and if it goes below a certain point, then it will cause the plant to die. Var harvest is variable 31 which is variables until the crop is ready for harvest. This would vary depending on the crop.

If water is less than or equal to 0, then it subtracts one from the death counter.

If water is greater than zero, then it would subtract one from the water variable.

If water is greater than zero, it would subtract from the harvest number.

The rest of the code just sets the number variables to the equivalent of what the named variables are.

I've tried having a switch that creates a separate death page, and then resets the variable back to three and vice versa, but that doesn't seem to be doing anything either.
Using an event spawner off of the same template event you're using the event copier from is likely what's causing your issues. That tutorial doesn't use the event spawner and is assuming all the plants are there from the beginning. When you spawn new ones from that same template they're not going to be fresh plants, they're inheriting the changes that the other plants already went through.
Using an event spawner off of the same template event you're using the event copier from is likely what's causing your issues. That tutorial doesn't use the event spawner and is assuming all the plants are there from the beginning. When you spawn new ones from that same template they're not going to be fresh plants, they're inheriting the changes that the other plants already went through.
What's weird is it's only the death variable causing the problem. Watering the crop works, but it's the death variable that's the trouble. Though I have noticed that, since changing things, my crops won't grow anymore. How else could I update my crops? Is there a way to do so?
I'm going to make my last interjection here - I strongly suggest you restructure this system.

All of this activity should not be on the plants, the plants should not all be parallel events, and you shouldn't be calling more common events from within the events.

You should have one parallel common event that runs every X frames and it iterates through all of the plant events spawned on the map to check their status.

That one event will make them need water (which really should be a boolean/switch, not a variable you're doing numeric math with); it will adjust the death/harvest days if necessary; and it will toggle a self switch if that plant needs to change its status/image on the map.

The only thing that isn't going to be in that single event is watering, and that is what's in the plant event itself. Make the plants be an Action Trigger event, and that event (in the appropriate stages of growth) is toggling on the "watered" switch.

Having every plant call other events is just asking for weird things to happen, and having the system spread over so many events and pages makes it (as you can see) extremely hard to comprehend and troubleshoot.

Good luck!
What's weird is it's only the death variable causing the problem. Watering the crop works, but it's the death variable that's the trouble. Though I have noticed that, since changing things, my crops won't grow anymore. How else could I update my crops? Is there a way to do so?
I'm going to need some time to look through the tutorial, how Yanfly implemented things, and what you changed because there is a lot of moving parts here. This is actually a really difficult system to implement for a beginner from scratch so you shouldn't feel bad about not getting it. I also think Yanfly's berry refresh system is only going to cover a part of the plant's growth cycle and might not be appropriate for the full lifecycle of the plant.
I'm going to make my last interjection here - I strongly suggest you restructure this system.

All of this activity should not be on the plants, the plants should not all be parallel events, and you shouldn't be calling more common events from within the events.

You should have one parallel common event that runs every X frames and it iterates through all of the plant events spawned on the map to check their status.

That one event will make them need water (which really should be a boolean/switch, not a variable you're doing numeric math with); it will adjust the death/harvest days if necessary; and it will toggle a self switch if that plant needs to change its status/image on the map.

The only thing that isn't going to be in that single event is watering, and that is what's in the plant event itself. Make the plants be an Action Trigger event, and that event (in the appropriate stages of growth) is toggling on the "watered" switch.

Having every plant call other events is just asking for weird things to happen, and having the system spread over so many events and pages makes it (as you can see) extremely hard to comprehend and troubleshoot.

Good luck!
Before you go, can you define iterate? Is there an easier way to cycle through the events? I really am restructuring it, I'm just not sure how to get the event Id/ make sure the correct event is selected! If I can understand how to cycle through the events, I should be able to make progress. Would it be the same way as with the yanfly system, or would it be different?
I'm going to need some time to look through the tutorial, how Yanfly implemented things, and what you changed because there is a lot of moving parts here. This is actually a really difficult system to implement for a beginner from scratch so you shouldn't feel bad about not getting it. I also think Yanfly's berry refresh system is only going to cover a part of the plant's growth cycle and might not be appropriate for the full lifecycle of the plant.
Hey take all the time you need. I'm aware it's difficult, and probably not the best choice for a burnt out college kid. But I have been so into farming games from an early age, so getting the base for it would help so much. When I get paid, I'm more than happy to compensate you for taking your time and helping me too!
Before you go, can you define iterate? Is there an easier way to cycle through the events? I really am restructuring it, I'm just not sure how to get the event Id/ make sure the correct event is selected! If I can understand how to cycle through the events, I should be able to make progress. Would it be the same way as with the yanfly system, or would it be different?
Probably a javascript for loop, which I could write for you but I need to review what needs to be done here so I reference the right inputs.
Iterate - to do something repeatedly, go through a series.

I'm just not sure how to get the event Id/ make sure the correct event is selected
I'm not really sure what you mean - there is no "correct" event, unless you are spawning other events on this map that aren't plants, in which case you need a way to check (you can use another self switch to designate "is this a plant").

! If I can understand how to cycle through the events, I should be able to make progress
You're already doing this in your bed event. There are ways to streamline it, but you're doing it.

I'm presuming you have a logical error in this portion of your code:
Code:
if (water > 0) water -= 1;
if (water > 0) harvest -= 1;
Because you say:
variable 26 which is my "watered or not" variable. 0 for no, 1 for yes.
If water is greater than zero, then it would subtract one from the water variable.
If water is greater than zero, it would subtract from the harvest number.
You subtract one from water before checking for the harvest, so water will never be greater than 0 at that point unless you set it to 2 at some point (and you say it's only 0 or 1).

So I'll change that in my demonstration below.

Code:
function UpdatePlants(){
for (let i=1000; i<$gameMap.events().length; i++)
{
    if (!$gameMap.events()[i])
        continue;

    if (!this.getSelfVariableValue(1, i, 26))
        this.setSelfVariableValue(1, i, 30, this.getSelfVariableValue(1, i, 30)-1);

    else
    {
        this.setSelfVariableValue(1, i, 26, this.getSelfVariableValue(1, i, 26)-1);
        this.setSelfVariableValue(1, i, 31, this.getSelfVariableValue(1, i, 31)-1);
    }

    ['A', 'B', 'C', 'D'].forEach(letter => $gameSelfSwitches.setValue([1, i, letter], false));

// Dead page?
    if (this.getSelfVariableValue(1, i, 26)<0)
        $gameSelfSwitches.setValue([1, i, 'A'], true);

    else if (this.getSelfVariableValue(1, i, 31)<=0 && this.getSelfVariableValue(1, i, 31)>=-4)
    {
// Watered seeds page?
        if (this.getSelfVariableValue(1, i, 26))
            $gameSelfSwitches.setValue([1, i, 'C'], true);

// Seeds growing page?
        else
            $gameSelfSwitches.setValue([1, i, 'B'], true);
    }

// Second growth page?
    if (this.getSelfVariableValue(1, i, 31)<-4 && this.getSelfVariable(1, i, 31)>=-9)
            $gameSelfSwitches.setValue([1, i, 'D'], true);

// Second stage watered - you need to make a self switch for this
    else
        this.setSelfSwitchValue(1, i, ID, true);
}};

Screw condensing it down, leave it readable, paste it into a text editor, save as a *.js file, include it as a plugin. Then you make a parallel common event that waits some number of frames then has the Script command UpdatePlants();

Leave the plant event page 1. Change page 2 to Action Trigger, condition of self switch A. Pull the actual effects of your water plant common event out of the common event and paste them into there (you don't need the junk with player positioning and stuff, just changing whatever self variables).

Change page 3 to Action Trigger, condition self switch B. Page 4 is self switch C. Page 5 is self switch D. Page 6 is switch of whatever free ID you wrote in there.

Any of the other stages that can be watered have the code right in there when you activate the event. Get rid of all of the custom page conditions.
Iterate - to do something repeatedly, go through a series.


I'm not really sure what you mean - there is no "correct" event, unless you are spawning other events on this map that aren't plants, in which case you need a way to check (you can use another self switch to designate "is this a plant").


You're already doing this in your bed event. There are ways to streamline it, but you're doing it.

I'm presuming you have a logical error in this portion of your code:
Code:
if (water > 0) water -= 1;
if (water > 0) harvest -= 1;
Because you say:

You subtract one from water before checking for the harvest, so water will never be greater than 0 at that point unless you set it to 2 at some point (and you say it's only 0 or 1).

So I'll change that in my demonstration below.

Code:
function UpdatePlants(){
for (let i=1000; i<$gameMap.events().length; i++)
{
    if (!$gameMap.events()[i])
        continue;

    if (!this.getSelfVariableValue(1, i, 26))
        this.setSelfVariableValue(1, i, 30, this.getSelfVariableValue(1, i, 30)-1);

    else
    {
        this.setSelfVariableValue(1, i, 26, this.getSelfVariableValue(1, i, 26)-1);
        this.setSelfVariableValue(1, i, 31, this.getSelfVariableValue(1, i, 31)-1);
    }

    ['A', 'B', 'C', 'D'].forEach(letter => $gameSelfSwitches.setValue([1, i, letter], false));

// Dead page?
    if (this.getSelfVariableValue(1, i, 26)<0)
        $gameSelfSwitches.setValue([1, i, 'A'], true);

    else if (this.getSelfVariableValue(1, i, 31)<=0 && this.getSelfVariableValue(1, i, 31)>=-4)
    {
// Watered seeds page?
        if (this.getSelfVariableValue(1, i, 26))
            $gameSelfSwitches.setValue([1, i, 'C'], true);

// Seeds growing page?
        else
            $gameSelfSwitches.setValue([1, i, 'B'], true);
    }

// Second growth page?
    if (this.getSelfVariableValue(1, i, 31)<-4 && this.getSelfVariable(1, i, 31)>=-9)
            $gameSelfSwitches.setValue([1, i, 'D'], true);

// Second stage watered - you need to make a self switch for this
    else
        this.setSelfSwitchValue(1, i, ID, true);
}};

Screw condensing it down, leave it readable, paste it into a text editor, save as a *.js file, include it as a plugin. Then you make a parallel common event that waits some number of frames then has the Script command UpdatePlants();

Leave the plant event page 1. Change page 2 to Action Trigger, condition of self switch A. Pull the actual effects of your water plant common event out of the common event and paste them into there (you don't need the junk with player positioning and stuff, just changing whatever self variables).

Change page 3 to Action Trigger, condition self switch B. Page 4 is self switch C. Page 5 is self switch D. Page 6 is switch of whatever free ID you wrote in there.

Any of the other stages that can be watered have the code right in there when you activate the event. Get rid of all of the custom page conditions.
Can I have the harvest variables be something that is custom per plant? I’d like some plants to be longer/shorter growth times.

Also, feel free to send me a paypal or kofi link, and I’ll pay you for doing so much for me!

@AquaEcho if you can edit this to: allow different harvest times, and it functions when the player goes to bed in a different map, I will also compensate you for your time! Just feel free to message the conversation we already have going and send me a paypal or kofi link!
Then you make a parallel common event that waits some number of frames then has the Script command UpdatePlants();
Unless you're updating the plants multiple times a day, i.e. they're progressing through growth stages, this seems unnecessary. Any update to the growth stage should be when the player waters the plant or sleeps (or a force update at some time early morning if the player stays up all night).

unless you are spawning other events on this map that aren't plants, in which case you need a way to check (you can use another self switch to designate "is this a plant").
May be needed if you want to spawn random insects or something on the map too. I would do it with a <plant> tag in the notebox.

Can I have the harvest variables be something that is custom per plant? I’d like some plants to be longer/shorter growth times.
Yes, you need to clarify at what stages the growth lengths between plants are different. Also, I assume this is like Harvest Moon where some plants are harvestable multiple times while others are once only.

@AquaEcho if you can edit this to: allow different harvest times, and it functions when the player goes to bed in a different map, I will also compensate you for your time! Just feel free to message the conversation we already have going and send me a paypal or kofi link!
The bed thing is easy, just call the same bed common event on every usable bed. I don't need a tip for this, and ATT_Turan did most of the work. If he wants a tip that's up to him.
Unless you're updating the plants multiple times a day, i.e. they're progressing through growth stages, this seems unnecessary. Any update to the growth stage should be when the player waters the plant or sleeps (or a force update at some time early morning if the player stays up all night).


May be needed if you want to spawn random insects or something on the map too. I would do it with a <plant> tag in the notebox.


Yes, you need to clarify at what stages the growth lengths between plants are different. Also, I assume this is like Harvest Moon where some plants are harvestable multiple times while others are once only.
Yes, you get it! I want it similar to Harvest Moon where you can have crops like, say a turnip. Usually turnips take about 7 days, while a crop like a potato takes more like 15 days. I would eventually like to have spawns like insects, and I would like to have events that when you purchase/construct buildings, a switch would flip and just make a very large event image take the place of some rubble or an empty building.

But I would also like things like trees or bushes that can grow and then be harvested from multiple times. I figured that would be something where it grows, but it isn't affected by water or death as most games just require that you have enough space. I was thinking I would make a special location/greenhouse specifically for trees and bushes so that it wasn't messily tied into the other regular crops.

The growth stages between regular crops would vary from the beginning. Some seeds only take 4 days to sprout, and others would take 5-6. If it makes it easier, I could make them all sprout at the same time, but have the stages between the second stage, third stage, and finally "harvest"/final stage be different in order to give the illusion of difference.
Yes, you get it! I want it similar to Harvest Moon where you can have crops like, say a turnip. Usually turnips take about 7 days, while a crop like a potato takes more like 15 days. I would eventually like to have spawns like insects, and I would like to have events that when you purchase/construct buildings, a switch would flip and just make a very large event image take the place of some rubble or an empty building.

But I would also like things like trees or bushes that can grow and then be harvested from multiple times. I figured that would be something where it grows, but it isn't affected by water or death as most games just require that you have enough space. I was thinking I would make a special location/greenhouse specifically for trees and bushes so that it wasn't messily tied into the other regular crops.

The growth stages between regular crops would vary from the beginning. Some seeds only take 4 days to sprout, and others would take 5-6. If it makes it easier, I could make them all sprout at the same time, but have the stages between the second stage, third stage, and finally "harvest"/final stage be different in order to give the illusion of difference.
If you're willing to pay you might as well commission ATT_Turan to write the whole plugin since he's already done half of it.
If you're willing to pay you might as well commission ATT_Turan to write the whole plugin since he's already done half of it.
It's whoever is available/willing! If @ATT_Turan will do it, then I'll commission him! I still would like to pay you for your help that you've given me! Even if it's like a little tip amount or something!
Yes, you get it! I want it similar to Harvest Moon where you can have crops like, say a turnip. Usually turnips take about 7 days, while a crop like a potato takes more like 15 days.

The growth stages between regular crops would vary from the beginning. Some seeds only take 4 days to sprout, and others would take 5-6. If it makes it easier, I could make them all sprout at the same time, but have the stages between the second stage, third stage, and finally "harvest"/final stage be different in order to give the illusion of difference.

But I would also like things like trees or bushes that can grow and then be harvested from multiple times. I figured that would be something where it grows, but it isn't affected by water or death as most games just require that you have enough space.
You might need a json file to keep track of all these properties of the different plants. This is going to require someone with programming knowledge.

I was thinking I would make a special location/greenhouse specifically for trees and bushes so that it wasn't messily tied into the other regular crops.
This is just a new map with maybe an indoor map property so it's not affected by weather or season changes.

I would eventually like to have spawns like insects
This is pretty easy and you can do with the event spawner in a couple minutes. It's only complicated if you want to catch them and track all your catches in a log or glossary.

I would like to have events that when you purchase/construct buildings, a switch would flip and just make a very large event image take the place of some rubble or an empty building.
You can do this with that tile swapping plugin Shaz made. You're just overwriting an area of tiles.
You might need a json file to keep track of all these properties of the different plants.
I have a few plugins that have json file properties, so maybe I can figure out how to do it? I'm not phenomenal with json files, but if there's a tutorial or two that can help, maybe I can figure out how to do it. I can get the basic gist of things, even if it doesn't seem like it lol

I would just have to not complicate things too much since I clearly have that tendency--
This is just a new map with maybe an indoor map property so it's not affected by weather or season changes.
Yeah, I figured it would just be having a growth cycle that takes a month, and it only bares fruit in like a certain season. Otherwise it would just be the same event with no major sprite changes.
This is pretty easy and you can do with the event spawner in a couple minutes. It's only complicated if you want to catch them and track all your catches in a log or glossary.
I have made a mining system in a different project that works pretty well. It would essentially be a random spawn of x amount of insects, and it would be a parallel process of whether or not it applies. Maybe an event copier, but that's about it. I didn't plan on making a log or glossary, but a museum where they can be donated. That way the player can choose items, and if it's already there, the museum can say "this is already here".
You can do this with that tile swapping plugin Shaz made. You're just overwriting an area of tiles.
That too! I haven't gotten super far with the art, so it's just vague planning in my head rn!

Original thread: https://forums.rpgmakerweb.com/threads/event-page-order-help.157193/