Remote Event Counting and Control by Name *dead, see Universal Remote Control*

dahlys

Meatbun
Veteran
Joined
Aug 28, 2017
Messages
95
Reaction score
99
First Language
English
Primarily Uses
RMMV
Remote Event Counting and Control
by Dahlys
Download Link
*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:
  • 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.
Screenshots:


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:
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)}
...Okay, bad. And I do this OVER and OVER again?

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)");
Er... Somewhat better I guess!?

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:

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,223
Reaction score
8,470
First Language
English
Primarily Uses
RMMV
Granted I haven't finished my coffee yet, but from looking over this, this seems it could be incredibly useful in a lot of ways, particularly for creating some unique minigames. Thanks for sharing!
 

dahlys

Meatbun
Veteran
Joined
Aug 28, 2017
Messages
95
Reaction score
99
First Language
English
Primarily Uses
RMMV
@mlogan
Minigames is an interesting idea. I was mostly thinking along the lines of saving cpu resources on my 8 year old laptop and 4 year old android phone, by minimizing parallel processes. E.g One common event controls all the light switches, simply because they were named "Light no. XXX". Using source arrays also prevents stupidly looping over 100+ events most of which are doors and lights.
 
Last edited:

Neo Soul Gamer

Veteran
Veteran
Joined
Aug 10, 2012
Messages
647
Reaction score
382
First Language
English
Primarily Uses
N/A
The flexibility you've given us here is actually amazing! Thanks for sharing this plugin with us.
 

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

Latest Threads

Latest Profile Posts

I FINALLY DID IT! 5 years making my very first game and I just officially released it on STEAM..... OMG..... I can say I finished a game! The feelings!!!!!
Stream will be live shortly! I am going to be playing some Among Us! Feel free to drop by!
Ami
tv program always get the ratings (it's the reason why drama series has 1000+ episode),also full and nonsense of censorship (weird blur, a scene getting cut because the unconvenient viewer,but it unconvenient to me either. you never see what the original is)

i know the reason is to take cover the viewer from the negative thing,but i just laughing and mocking of them that they're always suck :guffaw:
Star Chart Idea - Just something I am working on.
My sister learned spanish the old fashioned way and saw my way of conjugating. I don't use the formal method and just wing it. I thought her heart might explode. Apparently, different words use different endings. Weird part is even though I never learned the difference, I still can tell when the endings "look wrong".

Forum statistics

Threads
104,453
Messages
1,006,397
Members
135,962
Latest member
DeadMansWonderland
Top