start event by name[solve]

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
485
Reaction score
190
First Language
thai
Primarily Uses
RMMV
solve
I create a function for it
Code:
callEventbyName = function(name){
    for (var i = $dataMap.events.length - 1; i > 0; i--) {
        var event = $dataMap.events[i];
        if (event.name === name) {
            $gameMap.event(i).start();
            break;
        }
    }
}
.......................................................................
now I use
$gameMap.event(3).start();
to force start event from my custom window minigame
because I use show text and other thing from that event setting
but that is a bit annoying when every time
I have to check what number of the event I use
because I make many version of map and copy it around
the number change a lot

I want to call it by event name is it possible?
like I name it
water pump fail
so I specific call event name 'water pump fail' to start
thank you
 
Last edited:

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
820
Reaction score
320
First Language
Javascript
Primarily Uses
RMMV
Glad you solved it but... more info in case you want...
Code:
$dataMap.events.filter(function (item) {if (item) {return (item.name === this.name)};}, {name:'Event Name Goes Here'})
That returns an array of the events that the names match the 'Event Name Goes Here' ;)

So that means with just 1 or 2 lines of code...
You could do something like this:
Code:
$gameVariables.setValue(1,($dataMap.events.filter(function (item) {if (item) {return (item.name === this.name)};}, {name:'Event Name Goes Here'})));
$gameVariables.value(1).forEach(function (v){$gameMap.event(v.id).start();})
...to run all events with the same name ;)
 
Last edited:

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
485
Reaction score
190
First Language
thai
Primarily Uses
RMMV
Glad you solved it but... more info in case you want...
Code:
$dataMap.events.filter(function (item) {if (item) {return (item.name === this.name)};}, {name:'Event Name Goes Here'})
That returns an array of the events that the names match the 'Event Name Goes Here' ;)

So that means with just 1 or 2 lines of code...
You could do something like this and run all events with the same name ;)
Code:
$gameVariables.setValue(1,($dataMap.events.filter(function (item) {if (item) {return (item.name === this.name)};}, {name:'Event Name Goes Here'})));
$gameVariables.value(1).forEach(function (v){$gameMap.event(v.id).start();})
thank you... but I still don't understand the filter/forEach(function)
seen it a lot but still confuse about it
so I use for loop that I understand
and that one long line code is the other thing that hurt my little confuser artist's brain a lot... :hswt:
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Ive got a long lost half uncle. Thats real cool.
I forget what is bumping rule in this forum. Is anyone know? Thank you.
BCj
Ew, why does my blogpost on the rpgmaker.net site look like a garbled mess? Are html codes disabled or something?
I feel that I should cut down on my order queue so I can get some more time for my projects, its been quite a longggg while since I worked on them LOL
I friend of mine insisted on practicing dubbing things with him... and its quite funny, yet, it really takes a huge amount of practice!

Forum statistics

Threads
97,883
Messages
947,622
Members
129,117
Latest member
Babiboo
Top