RMMV Best way to get specific info from note tags?

bishiba

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

So I am in need of getting the damage formula and the elementId from customEffectEval I have.

So, I was going at this thing some months ago. And I did a little snippet of code, that I felt, even then, was rather messy.
JavaScript:
BISH.SkillDescription.getEffectFormula = function (i, n) {
        if (this.hasStateFormula(i, n) === true) {
            textBeforeFormula = "var damage = ";
            f = $dataStates[this.getCurState(i, n)].qmeta["Custom Regenerate Effect"];
            x = f.indexOf("var damage = "); //First part of formula string;
            x += textBeforeFormula.length;
            y = f.indexOf(";"); //Formula string ends.
            f = f.substring(x,y);
            //console.log(f);
            f = f.contains("origin.") ? f.replace("origin.", "a.") : ("Error in $dataStates[" + this.getCurState(i, n) + "].qmeta formula. Given string \"" + f + "\" cannot find \"origin.\"");
            a = this.getEffectType(i, n) + "${";
            a += f;
            a += "} ";
            a += this.getEffectElement(i, n);
            return a;
        }
    }

    BISH.SkillDescription.getEffectElement = function(i) {
        //Get the element ID of the formula.
        p = $dataStates[this.getCurState(i, n)].qmeta["Custom Regenerate Effect"];
        s = "";
        if (p.contains("var elementId = ")) {
            u = p.indexOf("var elementId = ");
            o = p.indexOf(";", u);
            u = p.substring(u, o)
            o = u.indexOf("=");
            u = u.substring(o + 2);
            s += $dataSystem.elements[u] + " damage";
            s += " ";
        }
        return s;
    }
As you can see, it's not a pretty sight. I could do it smoother now. I did a quick little fix for the first one, then I thought. I should ask if there is a better way to this that I am unaware of as of yet. So here I am, a guy, sitting in front of a screen, at a forum, asking for tips and tricks. At any rate here is what I did about 5 minutes ago.
JavaScript:
Window_SkillHelp.prototype.getEffectFormula = function (customEffectEvalString) {
        textBeforeFormula = "var damage = ";
        var x = customEffectEvalString.indexOf(textBeforeFormula);
        x += textBeforeFormula.length;
        var y = customEffectEvalString.indexOf(";");
        customEffectEvalString = customEffectEvalString.substring(x,y);
        return customEffectEvalString;
    };
Still not happy with this, but I only spent a few minutes on it to get it working with the plugin revamp.

So my question is, is there an easier way to do this, or is the approach above close to the way it should be done?

I believe the plugin in charge of assigning this specific notetag is YEP_BuffsStatesCore. But, the question should not necessarilybe treated as plugin specific.

Best regards,
Bishiba

Edit: Realizing that I never specific what I'd be looking for -.- So for example, where it says "var damage = ", I'd like to extract the damage formula so that I can calculate it. In terms of the element, I'd just like to extract the number.

Alright, so I am currently using this function:
Code:
BISH.getCustomEvalFormula = function(customEval, string) { //To find a value, it has to end with ";" and have a unique identifier.
    formulaStart     = customEval.indexOf(string) + string.length;
    formulaEnd         = customEval.indexOf(";", formulaStart);
    formula         = customEval.substring(formulaStart, formulaEnd);
    return formula;
};
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

Okay so, I'm using this script, right? And it works. If you press :Y a menu should come up allowing you to choose an item to use. Nothing happens. You press :A to open the event options menu and choose "Use an Item"? The item selection menu appears. I have no idea how I set this up or why it works the way it does. Absolutely bizarre.
A woman gave me her number without me even asking for it. Then she left because she had other patients to see.
oh, hey, I forgot about all this!

my old project got abandoned after I started working too much on stuff I'd already worked on - plus, starting to hate the story I wrote for it. Then, well, a lot of serious life **** went down. I ended up moving across the country, cutting off some people, etc. - **** was rough.

So, uh, I guess I'm back for now? Funny how things work.
I'm glad I'm sticking to my guns on having fighting game mechanics in my game, from what I've read, it's not for everyone. but for the most part, I've made it so you don't have to use them motion inputs for attacks if you don't want to.
And my project's just entered the Lunar New Year Sale 2022... Let's see if it reaches it's goal of $ 7,77.

Forum statistics

Threads
118,731
Messages
1,118,297
Members
155,883
Latest member
Lafferier
Top