Trying to use "ForEach"

Status
Not open for further replies.

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,778
Reaction score
1,206
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi, people!

I'm trying to change some events in my map to use Stepping.
By default, all of them are with the Stepping box unchecked.
But something happens, then a lot of them have to change to Stepping animation.
Well, I manage to use the script call to all of them in this way(using move route script field):

Code:
$gameMap.event(2).setStepAnime(true);
$gameMap.event(3).setStepAnime(true);
$gameMap.event(4).setStepAnime(true);
etc...

But, how can I make this more simple?
I'm trying to use "ForEach" to englobe all events.
I try to put the id of the events in a variable:
var casa = [2, 3, 4, 5]
$gameMap.event(casa).setStepAnime(true);

or
var casa = [2, 3, 4, 5]
$gameMap.event((forEach(casa))).setStepAnime(true);

But I can't get it to work :(

I already try to use the sentence "for (var i = 1; i < $gameMap._event.length; i++) $gameMap.event(i).setStepAnime(true)"

Well, I try a lot of things, but I can't get it to work.
 

EmptyVoid_

Veteran
Veteran
Joined
Jun 26, 2019
Messages
30
Reaction score
15
First Language
English
Primarily Uses
RMMV
I'll look into this for you when I get some free time tomorrow. I'll post my solution sometime later if I manage to get some free time later!
 

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
699
Reaction score
3,451
First Language
English
Primarily Uses
N/A
I tried something like this:
var temp = $gameMap.events()
temp.forEach(function(element){
element.stepAnime = true
})

When I tried to do it without capturing the array, it didn't work. However, when i assigned the array to a variable, it worked for me
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,778
Reaction score
1,206
First Language
Portuguese - Br
Primarily Uses
RMMZ
You could try this.
Code:
var casa = [2, 3, 4, 5];
casa.forEach(function(eventId) {
     $gameMap.event(eventId).setStepAnime(true);
});
OHH GOD!!! That's it!!
It also makes me understand properly how to use this type of code!
Thanks a lot!
 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Stream will be live shortly! I will be beginning a play-through of Resident Evil 4! Feel free to drop by!

1st iteration on castle interior in Tiled.
I've started up Pillars of Eternity. It's interesting how the game does a "select choice" cutscene using still image art for dramatic flair. I wonder if that might work for my RPGMaker project.
The self-righteous indignation of family when you expect them to pay back money you've leant to them never ceases to amaze me.
Gamedev for relaxing? yes or no?

Forum statistics

Threads
107,744
Messages
1,031,809
Members
139,883
Latest member
DeAngelis
Top