Longer script call

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
Hello!

I have list that looks like below and it's quite long. If I make a change to it I want to be able to copy/paste the entire list instantly into a script. However, as you probably know, there's a limit in how many lines and/or characters you can write in the script box.

I would like to be able to just take the script and paste it into a long script.

Is it possible to have a plugin that allows me to just call a long script? And would it be difficult to make?
1596479567174.png

Best regards,
 
  • Like
Reactions: Bex

Soulrender

Jack Of All Trades
Veteran
Joined
Jan 12, 2019
Messages
778
Reaction score
420
First Language
Poland
Primarily Uses
RMMV
No, it's not, you can just simply paste your code into some text editor and save it as JS file and in plugin manager and call your methods within "Script..." event.

Take a look at this snipet:
Code:
//file: example.js
helloWorld = function(){
/* paste your stuff here */
$gameVariables.setValue(1, 100);
}
and if you call method "helloWorld()" in "Script..." event, variable number 1 will be set to 100.

Please note, that JavaScript is case sensitive so if you call HelloWorld() instead helloWorld() you will get error and nothing happens.
 

Attachments

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,562
Reaction score
3,837
First Language
English
It's not hard to combine script call commands into one big script call. It would be the same approach I use for Large Choices
http://himeworks.com/2015/10/large-choices-mv/

But the real problem is your editor is still going to be stuck at however many number of lines.
So it's an editor limitation which is not something we can do about (besides modding the editor completely, in which case you wouldn't need the do any plugin work anyways)

You can move it to an extra file, or you could put it inside a common event and then just call your common event wherever you need it.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
No, it's not, you can just simply paste your code into some text editor and save it as JS file and in plugin manager and call your methods within "Script..." event.

Take a look at this snipet:
Code:
//file: example.js
helloWorld = function(){
/* paste your stuff here */
$gameVariables.setValue(1, 100);
}
and if you call method "helloWorld()" in "Script..." event, variable number 1 will be set to 100.

Please note, that JavaScript is case sensitive so if you call HelloWorld() instead helloWorld() you will get error and nothing happens.
Hey!

This worked perfectly. I have one last question, is there some script call instead of
JavaScript:
$gameVariables.setValue(437, "This will increase your magic defense by 45% for 3 turns.");
that will store the string in a plugin parameter? Specifically:
1596489477686.png
Realizing I've marked the name... I am interested in applying the value to the "text" with a script.
 
Last edited:

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
530
Reaction score
232
First Language
English
Primarily Uses
RMMV
I have one last question, is there some script call instead of
JavaScript:
$gameVariables.setValue(437, "This will increase your magic defense by 45% for 3 turns.");
that will store the string in a plugin parameter? Specifically:
View attachment 153927
Realizing I've marked the name... I am interested in applying the value to the "text" with a script.
Short answer: Yes, this is possible (but the change won't be shown in the plugin manager).

In order for it to work, you will need to load your plugin before the plugin whose parameters you're writing to.

Something like this should work:
JavaScript:
for(var i = 0; i < $plugins.length; i++) {
    if($plugins[i].status && $plugins[i].name == "YEP_X_MessageMacros2") {
        let params = $plugins[i].parameters;
        params["Macro 23 Text"] = 42;
    }
}
This makes it ignore whatever you set in the plugin manager and instead use what you've coded in the mod plugin.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
Short answer: Yes, this is possible (but the change won't be shown in the plugin manager).

In order for it to work, you will need to load your plugin before the plugin whose parameters you're writing to.

Something like this should work:
JavaScript:
for(var i = 0; i < $plugins.length; i++) {
    if($plugins[i].status && $plugins[i].name == "YEP_X_MessageMacros2") {
        let params = $plugins[i].parameters;
        params["Macro 23 Text"] = 42;
    }
}
This makes it ignore whatever you set in the plugin manager and instead use what you've coded in the mod plugin.
Would this be the right way to add into my plugin?
JavaScript:
skillDescriptions = function(){
for(var i = 0; i < $plugins.length; i++) { if($plugins[i].status && $plugins[i].name == "YEP_X_MessageMacros2") {let params = $plugins[i].parameters;params["Macro 181 Text"] = 14241;}}
for(var i = 0; i < $plugins.length; i++) { if($plugins[i].status && $plugins[i].name == "YEP_X_MessageMacros2") {let params = $plugins[i].parameters;params["Macro 182 Text"] = 1432;}}
for(var i = 0; i < $plugins.length; i++) { if($plugins[i].status && $plugins[i].name == "YEP_X_MessageMacros2") {let params = $plugins[i].parameters;params["Macro 183 Text"] = 144322;}}
}
And to order the plugins?(Tried putting it above Message core, under EvalText, under the macros as well)
1596535191717.png
Asking since it's not working at the moment.
1596535232980.png

Best regards,
 

Attachments

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
530
Reaction score
232
First Language
English
Primarily Uses
RMMV
Would this be the right way to add into my plugin?
Uhh... no. Just use the code exactly as I posted but add additional params["..."] = ... lines.

Also, the skillDescriptions = function() { ... } means that it won't run the code unless you call skillDescriptions. That's definitely not what you want, because once you do call it, it'll do nothing useful. That code only works if run immediately when the plugin loads.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I think I've got my hero designs pretty much finialised ( still got some tweaks. ) In the end it'll be the four outfit colour variants with four different skintones.

I'm a bit conflicted. One the one hand, it's quite visually cool to make bodies of water that the player can interact with by going into it. However obscuring the player character from a gameplay perspective is pretty bad. Hmm... There's the option to make the area around the player visible, but then that kind of defeats the purpose of submerging them. :unsure:
Stream will be live shortly with some Darkest Dungeon! Feel free to drop by!
Another two plugins done! One being an on map grid inventory.
busy with my newborn child, can't even touch pc at all ;_;

Forum statistics

Threads
104,295
Messages
1,005,349
Members
135,811
Latest member
napax
Top