I have a very simple plugin that uses 1 parameter.
When the player triggers an event with the Action Button, the plugin will update a variable inside my plugin and store the eventID. When the player presses and hold the "ok" button, I have a popup window at the top that shows values stored.
This works, however, I don't want to type in the eventId parameter via Plugin Command in the Event Editor every time when I set this up. You'd think I could do a this._eventId and pass that into my plugin somehow.
I get the impression that I could do that with Script in the Event Editor. I have no confirmation if this is doable or not. Any attempts I made at using script so far do not work. So either it doesn't work, or there is a syntax/setup I do not know.
Notes:
Yes, I know the event editor is set up to give me infinite 0 gold.
End goal is to have multiple treasure chests that respawn their contents after specified number of seconds, each with its own instance of a timer. This way I could have an area of respawning chests. When using the plugin, I envision that I could write a Script in the Event Editor to streamline this a little bit so I am only inputting the duration of the timer, not both the duration of the timer AND the eventID because the eventId appears in the top header of the Event Editor and seems like it could be accessible.
If this works, I would copy and paste the chest event with a X timer set 100 times, without changing the eventID manually. And still have the flexibility to change the timer duration for specific chest if so desired. This would be a huge timer saver when it comes to setting up the events.
Basically, I want to ability to use both the Plugin Command or a Script in Event Editor to access my Plugin. I've been having difficulty finding something that makes this clear whether or not Script will work in this way.
Plugin Code
Event Editor Contents
Event Editor Screen Shot
I imagine Script would look like this but it never accesses my code:
Screenshot of Event Editor Using Script instead of Plugin Command:
When the player triggers an event with the Action Button, the plugin will update a variable inside my plugin and store the eventID. When the player presses and hold the "ok" button, I have a popup window at the top that shows values stored.
This works, however, I don't want to type in the eventId parameter via Plugin Command in the Event Editor every time when I set this up. You'd think I could do a this._eventId and pass that into my plugin somehow.
I get the impression that I could do that with Script in the Event Editor. I have no confirmation if this is doable or not. Any attempts I made at using script so far do not work. So either it doesn't work, or there is a syntax/setup I do not know.
Notes:
Yes, I know the event editor is set up to give me infinite 0 gold.
End goal is to have multiple treasure chests that respawn their contents after specified number of seconds, each with its own instance of a timer. This way I could have an area of respawning chests. When using the plugin, I envision that I could write a Script in the Event Editor to streamline this a little bit so I am only inputting the duration of the timer, not both the duration of the timer AND the eventID because the eventId appears in the top header of the Event Editor and seems like it could be accessible.
If this works, I would copy and paste the chest event with a X timer set 100 times, without changing the eventID manually. And still have the flexibility to change the timer duration for specific chest if so desired. This would be a huge timer saver when it comes to setting up the events.
Basically, I want to ability to use both the Plugin Command or a Script in Event Editor to access my Plugin. I've been having difficulty finding something that makes this clear whether or not Script will work in this way.
Plugin Code
//=============================================================================
// PluginWithParametersTest
// PluginWithParametersTest.js
//=============================================================================
/*:
* @target MZ
* @plugindesc Testing plugin Command with parameters
* @author Me
* @help Testing plugin Command with parameters
* @url N/A
*
* @version 1.0
* @website N/A
* @license pending
*
* @param eventId
* @text Event ID
* @desc The ID of the event affected.
* @type number
* @default 1
*
* @command set
* @text Set eventId
* @desc Set eventId
*
* @arg eventId
* @text Event ID
* @desc The ID of the event affected.
* @type number
* @default 1
*
*/
var eventId = null; // debugging popup window
var popUpWindow = null;
(function() {
var pluginInfo = {
name: "PluginWithParametersTest",
description: "PluginWithParametersTest",
version: "1.0"
};
// Register your command(s)
PluginManager.registerCommand(pluginInfo.name ,"set", function(args) {
//put your code here for your plugin command.
eventId = Number(args.eventId);
$gameMessage.add("eventId: " + eventId + " as plugin command.");
});
// Add the update function to the game loop.
var _Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
_Scene_Map_update.call(this);
update.call(this);
};
// allows a fake debug dialog appear when triggered by "ok"
var update = function() {
if (Input.isPressed("ok")) {
if (!popUpWindow) {
popUpWindow = new Window_Base(new Rectangle(0, 0, Graphics.boxWidth, 100));
popUpWindow.drawText("Plugin With Parameters Test", 0, 0, Graphics.boxWidth, "center");
popUpWindow.drawText(eventId, 0, 28, Graphics.boxWidth, "center");
SceneManager._scene.addChild(popUpWindow);
}
} else {
// Remove the pop-up window when the key is released.
if (popUpWindow) {
SceneManager._scene.removeChild(popUpWindow);
popUpWindow = null;
}
}
};
})();
Event Editor Contents
◆Set Movement Route:This Event (Wait)
: :◇Direction Fix OFF
: :◇Turn Left
: :◇Wait:3 frames
: :◇Turn Right
: :◇Wait:3 frames
◆Change Gold:+ 0
◆Text:None, None, Window, Bottom
: :0\G were found!
◆Plugin Command:PluginWithParametersTest, Set eventId
: :Event ID = 42
Event Editor Screen Shot
I imagine Script would look like this but it never accesses my code:
◆Set Movement Route:This Event (Wait)
: :◇Direction Fix OFF
: :◇Turn Left
: :◇Wait:3 frames
: :◇Turn Right
: :◇Wait:3 frames
◆Change Gold:+ 0
◆Text:None, None, Window, Bottom
: :0\G were found!
◆Script:var eventId = this._eventId;
: :$gameMap._interpreter.pluginCommand("PluginWithParametersTest", "set", { eventId: eventId});
Screenshot of Event Editor Using Script instead of Plugin Command: