MV Noob can't get test plugin to work

I'm trying to learn javascript/Rpgmaker scripting but there's so many issues i don't understand,

i want this test plugin I'm working on to just display a picture when a battle starts
but i have no idea how to "call"/ make rpgmaker check the plugin and execute the code

this works fine in the terminal,
$gameScreen.showPicture(1, "pic", 0, 100, 200, 100, 100, 255, 0);

but I don't know how to make it run in a plugin

here's the full function below

function displayBattleBust()
{
$gameScreen.showPicture(1, "pic", 0, 100, 200, 100, 100, 255, 0);
}


if (SceneManager.currentScene instanceof Scene_Battle)
{
displayBattleBust();
}

also, how do I create parameters that I can change within the rpgmaker plugin menu?
Any time you post code, you should do it in the CODE tags (the </> in the edit bar). That will preserve indentation and brackets.

i want this test plugin I'm working on to just display a picture when a battle starts
but i have no idea how to "call"/ make rpgmaker check the plugin and execute the code
On the third tab of event commands there's a Script button - you can type the function call into that.

However, it's not super useful to make a plugin just for one single-line function. You could just paste your $gameScreen.showPicture() call into that Script box and no need for a plugin file.

For that matter, I don't see why you need to use the script call at all. Just make a Turn 0 troop event and use the regular Show Picture event command.

function displayBattleBust()
{
$gameScreen.showPicture(1, "pic", 0, 100, 200, 100, 100, 255, 0);
}


if (SceneManager.currentScene instanceof Scene_Battle)
{
displayBattleBust();
}
If that's literally the contents of your plugin file, it will never do anything. You have this conditional (if) statement just hanging out there, which means the engine will attempt to execute it when it first reads the plugin at the game's boot.

Since there's no SceneManager or anything else besides the database at that point, it won't do anything.

also, how do I create parameters that I can change within the rpgmaker plugin menu?
With the @param definition, as well as the @type. Official documentation is sparse, so your best bet in that case is to just open an MZ plugin up and read it.
but I don't know how to make it run in a plugin
wrong question.

you cannot make the engine call a function it knows nothing above, you have to approach it from the other side - by having your plugin inject itself into the engine.
There are several ways to do this, but usually you alias an existing function, call it from within the aliased function and then add your own commands afterwards.
or for more complex changes you might want to replace an existing function completely.

but in all cases you need to know the existing functions to redirect the engine, which means a lot of studying to learn the default engine.
wrong question.

you cannot make the engine call a function it knows nothing above, you have to approach it from the other side - by having your plugin inject itself into the engine.
There are several ways to do this, but usually you alias an existing function, call it from within the aliased function and then add your own commands afterwards.
or for more complex changes you might want to replace an existing function completely.

but in all cases you need to know the existing functions to redirect the engine, which means a lot of studying to learn the default engine.
oh okay good to know thanks, i better get studying then!
Any time you post code, you should do it in the CODE tags (the </> in the edit bar). That will preserve indentation and brackets.


On the third tab of event commands there's a Script button - you can type the function call into that.

However, it's not super useful to make a plugin just for one single-line function. You could just paste your $gameScreen.showPicture() call into that Script box and no need for a plugin file.

For that matter, I don't see why you need to use the script call at all. Just make a Turn 0 troop event and use the regular Show Picture event command.


If that's literally the contents of your plugin file, it will never do anything. You have this conditional (if) statement just hanging out there, which means the engine will attempt to execute it when it first reads the plugin at the game's boot.

Since there's no SceneManager or anything else besides the database at that point, it won't do anything.


With the @param definition, as well as the @type. Official documentation is sparse, so your best bet in that case is to just open an MZ plugin up and read it.
also good to know, but i have my reasons for doing things this way, learning to program, being able to add any type of functionality i want, minigames etc etc

thanks for the param answer
you cannot make the engine call a function it knows nothing above, you have to approach it from the other side - by having your plugin inject itself into the engine.
That's not entirely correct. You can make the engine call any function that's present in a plugin file, whether or not you've aliased it from some existing code.

For example, my standard damage calculation is outsourced into a function in a plugin file, and my damage formulae in skills consists of TurDam(a, b)
@ATT_Turan you missed the "that it knows nothing about".
in your example it isn't the engine calling anything, it is you entering the function name you know of into part of the engine (the damage formula) to call the plugin.

Original thread: https://forums.rpgmakerweb.com/threads/noob-cant-get-test-plugin-to-work.159424/