Script to set text YEP Message Macros

bishiba

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

I have the below script that sets a variable to the description and then I have to manually type in the variable reference in the Macro 101 Text parameter.

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:
1596494626773.png
So is there some code I can use that will apply "This will increase your magic defense by 45% for 3 turns." that can be implemented the same way as I have done below?
JavaScript:
$gameVariables.setValue(437, "This will increase your magic defense by 45% for 3 turns.");
$gameVariables.setValue(438, "This will increase the target's fire resist by 35% for 3 turns.");
$gameVariables.setValue(439, "This will decrease the target's fire resist by 25% for 3 turns.");
...........................................
...........................................
$gameVariables.setValue(575, "This will decrease the target's physical defense by 60% for 3 turns.");
$gameVariables.setValue(576, "This will decrease the target's personal hit by 30% for 3 turns.");
$gameVariables.setValue(577, "This will decrease the target's physical damage by 25% for 3 turns.");
Any thoughts, even if it is something different is greatly appreciated.
 

ATT_Turan

Veteran
Veteran
Joined
Jul 2, 2014
Messages
89
Reaction score
39
First Language
English
Why are you doing two steps with making the game set the value of an in-game variable to that text string every time you include it in a message box to the user?

The intended use of this plugin is you would, for example:
Set Macro 1 Text to "This will increase your magic defense by 45% for 3 turns."
Set Macro 1 Name to "magdef"
In text that will be displayed to the user, type \magdef

I don't understand the purpose of the global variable. In fact, since the plugin is for displaying text strings, I don't think it can execute scripts at all like you're trying to do.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
Why are you doing two steps with making the game set the value of an in-game variable to that text string every time you include it in a message box to the user?

The intended use of this plugin is you would, for example:
Set Macro 1 Text to "This will increase your magic defense by 45% for 3 turns."
Set Macro 1 Name to "magdef"
In text that will be displayed to the user, type \magdef

I don't understand the purpose of the global variable. In fact, since the plugin is for displaying text strings, I don't think it can execute scripts at all like you're trying to do.
Hey!

Well I wouldn't put time and effort into the first part if I hadn't made sure the first part already worked. Ask the question since it does work. I was also unsure if it would work. I thought it would just read the string within the variable but it actually removed the string within the variable.

I see what you mean with the "why do this?", as I did not explain. What I do is I take all the lines in the description column and paste it directly into my plugin. So I can't do that in the actual plugin, there I would have to add each of these separately into each of the macro text boxes. And if I then made a change to my description generator I would again have to add each changed description into the macro text boxes separately. This way I just need to write in the macro text box once to refer to the variable. And then I can change every single variable with just one single copy / paste. there's about 300 skill description lines, so manually changing them each time would be a massive pain.
1596533898943.png
But if I could change it so I could with the plugin instantly add this to the macro, I don't have to add the ${gameVariables.value(xxx)} into each of the 300 macro boxes I need to fill. Since I have other stuff to work on as well, I can wait with doing that til I know if I can do the thing I am asking here! :)
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
New message for separate clarity.

I will try using this from another post I made.
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.
 

Attachments

ATT_Turan

Veteran
Veteran
Joined
Jul 2, 2014
Messages
89
Reaction score
39
First Language
English
I see the point, now, you're trying to have the text dynamically calculate as it is displayed to the user.

I still don't think the variables help you at all in this situation, I would think it's easier to just write a little plugin that has functions to produce these text strings that you can call and avoid the whole usage of the variables - but I'm glad you got it to do what you want! :)
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Recent threads, and my very poor algorithm for my minimap plugin have made me face the fact that I need to review algorithms and such.

Going through Cracking the Coding Interview now. I am so excited.
Kes
I've seen a reference to a Community Lighting plugin for MZ, but cannot find it. Is it still in beta?

Todo:
Add fog of war
Add enemy indicators
Make window draggable
Optimise map drawing algorithm (5 seconds to load the map you see, so it's a... poo-poo algorithm)

Any suggestions? :kaoblush:
bleh studio hell job haha at least they like it didnt had time to do much laundry tho ;w;'....YES I DO AT LEAST TAKE A SHOWER everyday!
Ami
--- Food Ingredients ---

Hero: Since the Chef are in Hospital,we can't eat his Dish in 3 Days.
F.Mage: What we have to Eat?
M.Healer: Don't worry,we can Eat the Food Ingredients.
Hero & F.Mage
: Really?

(3 Days Later)

Chef: Hi,Guys. I'm Ba---
(Entire Party Collapse After Eat Raw Meat)
Chef: Wha...WHAT GOING ON HERE!!!!!!

Forum statistics

Threads
102,913
Messages
995,920
Members
134,363
Latest member
Wilsonliz
Top