I am using Yanfly's self-Variables to make plants grow. I am also using Galv's Event spawner to allow player to choose which crop to plant. So, I don't "know" the event id. I assume I need to iterate through all Events on the Map (once/day) and find which ones have been watered, then grow them.
All I'm trying to do is iterate through the game events and I have searched for an hour and all I'm getting is AI generated "code" that doesn't work and no actual human-written code...
This is what I have so far...
//below code is placed in parallel event that runs once/day
for (var eventId = 1; eventId < $gameMap.events().length; eventId++) {
var e = $gameMap.events(eventId);
//Yanfly code below DOES work. It is only the above iteration that I can't figure out.
if (this.getSelfVariableValue(4, e, 23) === 1) this.setSelfVariableValue(4, e, 23, 2); //grow1
else if (this.getSelfVariableValue(4, e, 23) === 3) this.setSelfVariableValue(4, e, 23, 4); //grow2
//...and so on
}
Note: I haven't actually solved the problem, but I was misunderstanding it.
$gameMap.events().length gets the amount of events
but this.getSelfVariableValue(4, eventNum, 23) gets the initialized idNumber of the Event
Unfortunately, the idNumber could be higher than the total amount of events on screen (after you delete some!) so the newer crops I create aren't being iterated over. So, waht I need to figure out is how to find the number of the Event in $gameMap.events() and what idNumber it has, not what postioin in the array it has...
Since I already "closed" this question, no one might see it, so I will try and figure it out and post the answer here if I ever do...
All I'm trying to do is iterate through the game events and I have searched for an hour and all I'm getting is AI generated "code" that doesn't work and no actual human-written code...
This is what I have so far...
//below code is placed in parallel event that runs once/day
for (var eventId = 1; eventId < $gameMap.events().length; eventId++) {
var e = $gameMap.events(eventId);
//Yanfly code below DOES work. It is only the above iteration that I can't figure out.
if (this.getSelfVariableValue(4, e, 23) === 1) this.setSelfVariableValue(4, e, 23, 2); //grow1
else if (this.getSelfVariableValue(4, e, 23) === 3) this.setSelfVariableValue(4, e, 23, 4); //grow2
//...and so on
}
Note: I haven't actually solved the problem, but I was misunderstanding it.
$gameMap.events().length gets the amount of events
but this.getSelfVariableValue(4, eventNum, 23) gets the initialized idNumber of the Event
Unfortunately, the idNumber could be higher than the total amount of events on screen (after you delete some!) so the newer crops I create aren't being iterated over. So, waht I need to figure out is how to find the number of the Event in $gameMap.events() and what idNumber it has, not what postioin in the array it has...
Since I already "closed" this question, no one might see it, so I will try and figure it out and post the answer here if I ever do...