- Joined
- Aug 28, 2017
- Messages
- 95
- Reaction score
- 99
- First Language
- English
- Primarily Uses
- RMMV
*Update 09/24: This plugin is dead. Please see my Universal Remote Control instead
Introduction:
Count number of events with Event Name = "insert_name" and store their event IDs into an array.
Remotely activate self-switches based on event names.
Features:
How to use:
Dump the .js file in your project plugins folder and add it to your plugin manager. The order this plugin is loaded shouldn't matter.
Thanks to:
Soulpour777 for his scripting tutorial!
Author's Notes:
I hope this plugin will be helpful to some people! This has been super useful to me in shortening script calls in my "Police vs Thief" game.
If you look through the script, it's not the most elegant thing. I highly welcome any suggestions to improve. This is my first ever rpg maker plugin, and my first time writing in javascript (I used to use the monster called C++, that was 5 years ago when I was still in school). Perhaps the next update will add more functions such as the ability to activate multiple switches. I've been playing with rmmv for... 2 weeks?
Introduction:
Count number of events with Event Name = "insert_name" and store their event IDs into an array.
Remotely activate self-switches based on event names.
Features:
- Count the number and log the IDs of Event Names containing the word(s) of interest.
- e.g. If all NPCs have NPC in their event name, you can store their Event IDs in a variable as an array. The total number of NPCs on the map can also be stored into a variable.
- An array of strings ["Tom", "Dick", "Harry"] can be used as input as well as individual strings "Tom", "Dick", "Harry"
- Remote control Self-switches by matching Event Names, works for Yanfly's self-switch plugin!
- e.g. If all children have "child" in their event name, you can turn on their self-switch to make them all flee from you at once in a game of tag. No need for a common event/global switch and parallel processes all over the place.
- e.g. If you type a string or array of strings into a variable (via another plugin (http://biud436.tistory.com/58) or script call), you can drop a lightning bolt on "EnterNameHere" anywhere on the same map.
- Set your own conditions to whether the Event ID will be included or not.
- Some javascript knowledge required
- Script calls from other plugins can be used in conditions. I have not yet found any conflicts with Yanfly, LTN, Galv, Hime, Khas, and Orange.
- e.g. Choose to exclude dead NPCs who have self-switch "D" on.
- Once Event IDs are stored in a variable, they can be used as a source array for further functions. This prevents having to loop through every single event on the map when you just want to activate/search through a subset of events.
- More detail on plugin functions and usage is found in the plugin help box.
- Please read carefully especially when using conditions involving Event IDs. e.g. Checking if their dead/alive self-switch is on. Also watch out for special javascript characters.
How to use:
Dump the .js file in your project plugins folder and add it to your plugin manager. The order this plugin is loaded shouldn't matter.
Thanks to:
Soulpour777 for his scripting tutorial!
Author's Notes:
My script calls used to look like:
...Okay, bad. And I do this OVER and OVER again?
What the script calls now look like:
Er... Somewhat better I guess!?
Code:
//On map entry
var npc = [];
for (i = 1; i < 999; i++) {
if ($dataMap.events[i] == null) {
break;
}
else if ($dataMap.events[i].name.includes("NPC") && !this.getSelfSwitchValue(this._mapId, i, 18)) {
npc.push(i);
}
}
$gameVariables.setValue(65, npc)
$gameVariables.setValue(64, npc.length)
//Parallel common event
var npc = $gameVariables.value(65);
var nearby = [];
for (i = 0; i < npc.length; i++) {
if (Galv.DETECT.event(npc[i],$gameVariables.value(11),true) && $dataMap.events[npc[i]].name.includes("Policeman") && !this.getSelfSwitchValue(this._mapId, npc[i], 18)) {
nearby.push(npc[i]);
}
}
if (nearby.length > 0) {$gameVariables.setValue(83, nearby)}
for (i = 0; i < npc.length; i++) {
if (Galv.DETECT.event(npc[i],$gameVariables.value(11),true) && $dataMap.events[npc[i]].name.includes("FBI") && !this.getSelfSwitchValue(this._mapId, npc[i], 18)) {
nearby.push(npc[i]);
}
}
if (nearby.length > 0) {$gameVariables.setValue(84, nearby)}
var victimfamilies = $gameVariables.value(85);
for (i = 0; i < npc.length; i++) {
for (j = 0; j < victimfamilies.length; j++) {
if (Galv.DETECT.event(npc[i], $gameVariables.value(11), true) && $dataMap.events[npc[i]].name.includes(victimfamilies[j]) && this.getSelfSwitchValue(this._mapId, npc[i], 18) == false) {
nearby.push(npc[i]);
}
}}
if (nearby.length > 0) {$gameVariables.setValue(86, nearby)}
What the script calls now look like:
Code:
this.countevent("NPC", 64, 65, "!this.getSelfSwitchValue(this._mapId, id, 18)");
this.counteventarray("Policeman", 0, 83, 65, "Galv.DETECT.event(sourcearray[id],$gameVariables.value(11),true) && !this.getSelfSwitchValue(this._mapId, sourcearray[id], 18)");
this.counteventarray("FBI", 0, 84, 65, "Galv.DETECT.event(sourcearray[id],$gameVariables.value(11),true) && !this.getSelfSwitchValue(this._mapId, sourcearray[id], 18)");
var victimfamilies = $gameVariables.value(85);
this.counteventarray(victimfamilies, 0, 86, 65, "Galv.DETECT.event(sourcearray[id],$gameVariables.value(11),true) && !this.getSelfSwitchValue(this._mapId, sourcearray[id], 18)");
I hope this plugin will be helpful to some people! This has been super useful to me in shortening script calls in my "Police vs Thief" game.
If you look through the script, it's not the most elegant thing. I highly welcome any suggestions to improve. This is my first ever rpg maker plugin, and my first time writing in javascript (I used to use the monster called C++, that was 5 years ago when I was still in school). Perhaps the next update will add more functions such as the ability to activate multiple switches. I've been playing with rmmv for... 2 weeks?
Last edited:


