start event by name[solve]

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
490
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
824
Reaction score
323
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
490
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 Profile Posts

Jumping and gravitation 0.1 build - RPG Maker MV
Currently playing final fantasy 3 on DS. It's an old one but its a classic.
BCj
Gotta love some gossip :D
Please do not buy games from g2a.com. The sellers have total power over you. The website has many scam sellers. It looks cheap, but the key code didn't work.

Forum statistics

Threads
97,946
Messages
948,078
Members
129,200
Latest member
jakeofblades
Top