How to call a self made plugin from the Script tool

bomblord

Veteran
Veteran
Joined
Apr 13, 2016
Messages
87
Reaction score
11
First Language
English
Primarily Uses
I'm wanting to know how to call a function in a self made plugin from the script tool in RPG Maker MV.

When I say "script tool" I'm referring to the "script" button on the bottom right of page 3.
 

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
556
Reaction score
795
First Language
English
Primarily Uses
RMMV
You simply type the script call directly into the box. If you have a plugin with a global variable of some sorts in the plugin file. You can call it by typing the name of the namespace (if it has one). You can type more than just scripts in that box; it's mainly for typing plain JavaScript. If you provide the plugin in question, I could provide more details @bomblord.
 

bomblord

Veteran
Veteran
Joined
Apr 13, 2016
Messages
87
Reaction score
11
First Language
English
Primarily Uses
Sure, I have a file in my plugins folder with this function in it.


function lineOfSight (sightLimit, eventIdentification){
//variable
var sight; //variable to know whether the player has been seen

//if they are in the same X position and within the sight limit check for obstacles
if($gamePlayer.x == $gameMap.event(eventIdentification).x && Math.abs(($gamePlayer.y - $gameMap.event(eventIdentification).y)) <= sightLimit){
//a slightly different script runs depending on whether or not the difference in position is positive or negative
if(($gamePlayer.y - $gameMap.event(eventIdentification).y) >= 0 ){
//loop through every position between the current event and the player and check for obstacles
for(y = $gamePlayer.y; y > $gameMap.event(eventIdentification).y; y--){
//if there is something in the way break the loop to prevent the false from being overwritten
if(!($gameMap.isPassable($gamePlayer.x, y))){
sight = false;
break;
}
//if nothing is in the way the player can be seen
else
sight = true;
}
}
//run if the position is negative
if(($gamePlayer.y - $gameMap.event(eventIdentification).y) < 0){
for(y = $gamePlayer.y; y < $gameMap.event(eventIdentification).y; y++){
if(!($gameMap.isPassable($gamePlayer.x, y))){
sight = false;
break;
}
else
sight = true;
}
}
}
//run if the player and event share the same Y position and are within the sight limit
//everything else is the same as above just swapped for the Y position
if($gamePlayer.y == $gameMap.event(eventIdentification).y && Math.abs(($gamePlayer.y - $gameMap.event(eventIdentification).y)) <= sightLimit){
if(($gamePlayer.x - $gameMap.event(eventIdentification).x) >= 0){
for(x = $gamePlayer.x; x > $gameMap.event(eventIdentification).x; x--){
if(!($gameMap.isPassable(x, $gamePlayer.y))){
sight = false;
break;
}
else
sight = true;
}
}
if(($gamePlayer.x - $gameMap.event(eventIdentification).x) < 0){
for(x = $gamePlayer.x; x < $gameMap.event(eventIdentification).x; x++){
if(!($gameMap.isPassable(x, $gamePlayer.y))){
sight = false;
break;
}
else
sight = true;
}
}
}
//if after everything the player can be seen then throw event self switch A
if(sight == true)
$gameSelfSwitches.setValue([this._mapId, eventIdentification, 'A'], true);
}



I want to call that function (file name is lineOfSight.js)
 
Last edited by a moderator:

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
556
Reaction score
795
First Language
English
Primarily Uses
RMMV
Okay, so that's the whole file?
In that case, you should be able to call the function with :


lineOfSight(param1, param2)



Whatever parameters you need for it to work, but you're going to need some boilerplate code in order for that to work in MV.


You should be able to activate it by going to PluginManager in the editor. If you can't, then you need to add this line to the top of the file.


var params = PluginManager.parameters("lineOfSight");


This is so that the PluginManager can recognize the file. @bomblord


After that, lineOfSight should be available globally throughout the game.
 

bomblord

Veteran
Veteran
Joined
Apr 13, 2016
Messages
87
Reaction score
11
First Language
English
Primarily Uses
Thanks after loading it into the plugin manager I was able to call the function and verified it was working.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!

Forum statistics

Threads
106,036
Messages
1,018,461
Members
137,821
Latest member
Capterson
Top