Hey guys,
This is a follow up from a topic I made a few days ago, and id like a final evaluation of my plugin - perhaps about the order of the functions, some final nitpicks, any useful advice for on the road, or anything really.
What the plugin does is replace the common event event command - instead being able to be called by common event name, instead of common event ID.
@Nolonar @Aloe Guvner Heres an alert for you both since you were involved in the previous topic. if you have nothing to add, no problem!
This is a follow up from a topic I made a few days ago, and id like a final evaluation of my plugin - perhaps about the order of the functions, some final nitpicks, any useful advice for on the road, or anything really.
What the plugin does is replace the common event event command - instead being able to be called by common event name, instead of common event ID.
@Nolonar @Aloe Guvner Heres an alert for you both since you were involved in the previous topic. if you have nothing to add, no problem!
Code:
"use strict"
function findCommonEvent(eventName) {
for (let i = 1; i < $dataCommonEvents.length; i++) {
let event = $dataCommonEvents[i];
if (event.name === eventName)
return $dataCommonEvents[i];
}
return false;
};
function doStuff(eventName, THIS) {
let ID = findCommonEvent(eventName);
if (ID) {
let eventId = THIS.isOnCurrentMap() ? THIS._eventId : 0;
THIS.setupChild(ID.list, eventId);
}
};
//function CEVENTS(NAME, THIS) {
//for(let i = 1; i < $dataCommonEvents.length; i++) {
//if ($dataCommonEvents[i].name === NAME) {
//let commonEvent = $dataCommonEvents[i];
//if (commonEvent) {
//let eventId = THIS.isOnCurrentMap() ? THIS._eventId : 0;
//THIS.setupChild(commonEvent.list, eventId);
//}
//break;
//}
//}
//};
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command !== "CommonEvent") return;
doStuff(String(args[0]), this)
};