Get item/skill effect values in a formula

Hey and hello everyone,
im using the VE -Mix Actions plugin which lets you like the name suggests mix items and skills together.
The plugin gives me the option to get the last used items/skills in a mix to use them in the forula for the resulting skill.
It looks basicly like this: this.mixItem(MIX_ID). So i could use them in the formula like this: this.mixItem(ID) + this.mixItem(ID).
So lets say i use two potions for the mix. The potion has the effect heal hp and a vaule of 500. I want to get the value in my formula. But i have no idea where i can see those variables in the help manual. RGSS was way easier to learn then JS is.
I hope someone can help me with that. Big Thx in advance!

EDIT: It should look like this if im not wrong (just different names for the variables):
this.mixItem(MIX_ID).effects.healHP + this.mixItem(MIX_ID).effects.healHP
Some suggestions:

  1. JS typically uses camelCase for variables where ruby uses snake_case. Often if you know what something was in ruby/VX Ace you can just convert it
  2. The best way to see variables is to use the built in console (press F8 during playtest to open it). You get autocomplete for variable names and you can always check the current value
  3. If you're looking for help with a specific plugin, you should give a link to it
  4. Documentation for the base MV variables and classes here
Some suggestions:

  1. JS typically uses camelCase for variables where ruby uses snake_case. Often if you know what something was in ruby/VX Ace you can just convert it
  2. The best way to see variables is to use the built in console (press F8 during playtest to open it). You get autocomplete for variable names and you can always check the current value
  3. If you're looking for help with a specific plugin, you should give a link to it
  4. Documentation for the base MV variables and classes here

1. Yeah i know about the camelCase format in JS but its good to know that i can convert most of the variables in case they exist like in RGSS.
That will help alot i guess.
2. Ok got that, i guess that will also help alot.
3. Its not about the plugin itself since the plugin command just returns the item or skill object. I get your point but basicly my question was how i get variables form items/skills and nothing about the script itself. I just explained too much in the first place im sorry! 😛
4. Thats exactly what i missed in the Help which came with MV. Big thx for that mate!
It looks like Game_Action.prototype.mixItem ultimately returns a value from $dataItems, $dataSkills, $dataWeapons, or $dataArmors (or null). They all have somewhat different property structures, so that will affect how you reference them in your formula, but in the case of your potion, if it's item ID 1 and the only effect it has is "Heal HP: 500":
Code:
this.mixItem(1).effects[0].value2;
would return the "500" part of that effect.

If the potion restored a value from the damage formula, though, you'd have to figure out how to parse:
Code:
this.mixItem(1).damage.formula

Skills and items have effects, so you can reference those in the .effects property (which is an array). They also have damage, which is referenced in the .damage property. Weapons and armors just have params, but it doesn't seem like you're as concerned about that.
It looks like Game_Action.prototype.mixItem ultimately returns a value from $dataItems, $dataSkills, $dataWeapons, or $dataArmors (or null). They all have somewhat different property structures, so that will affect how you reference them in your formula, but in the case of your potion, if it's item ID 1 and the only effect it has is "Heal HP: 500":
Code:
this.mixItem(1).effects[0].value2;
would return the "500" part of that effect.

If the potion restored a value from the damage formula, though, you'd have to figure out how to parse:
Code:
this.mixItem(1).damage.formula

Skills and items have effects, so you can reference those in the .effects property (which is an array). They also have damage, which is referenced in the .damage property. Weapons and armors just have params, but it doesn't seem like you're as concerned about that.

Oh i see even if had the first part i could not use it cus i need to parse it with "damage.formula". Good to know for other stuff like that.
Big thx for helping me out that quick mate!
Actually, it might already be parsed for you if you're putting it in the formula. When an item or skill's damage formula is evaluated, it's passed through a JavaScript eval statement, which does the type coercion and variable replacements for you.

Try referencing something like this.mixItem(1).damage.formula and see what happens. Worst case scenario, you get an error and you just go back and remove it.
Actually, it might already be parsed for you if you're putting it in the formula. When an item or skill's damage formula is evaluated, it's passed through a JavaScript eval statement, which does the type coercion and variable replacements for you.

Try referencing something like this.mixItem(1).damage.formula and see what happens. Worst case scenario, you get an error and you just go back and remove it.

The parse doesnt work for me it returns 0:
Code:
this.mixItem(1).damage.formula + this.mixItem(2).damage.formula

The first way works but not as it should do. Instead of 1000 it returns 700:
Code:
this.mixItem(1).effects[0].value2 + this.mixItem(2).effects[0].value2

I have no idea how it comes to 700 since i have variance on my skill.
You could try this:
Code:
var item1 = this.mixItem(1); console.log(item1); var item2 = this.mixItem(2); console.log(item2); item1.effects[0].value2 + item2.effects[0].value2;
Then open up your dev console (F8 by default) and use the skill that has that formula. I haven't tested it, but it should log the two objects and you can expand them and look at their various properties. If you do, perhaps post screenshots of each object's damage and effects properties?
You could try this:
Code:
var item1 = this.mixItem(1); console.log(item1); var item2 = this.mixItem(2); console.log(item2); item1.effects[0].value2 + item2.effects[0].value2;
Then open up your dev console (F8 by default) and use the skill that has that formula. I haven't tested it, but it should log the two objects and you can expand them and look at their various properties. If you do, perhaps post screenshots of each object's damage and effects properties?

The console returns this error message:
Code:
VM457:1 Uncaught TypeError: this.mixItem is not a function
    at <anonymous>:1:18
That's... Odd. What do you get when you do:
Code:
console.log(this); this.mixItem(1).effects[0].value2 + this.mixItem(2).effects[0].value2;
does it still say this.mixItem is not a function? Does it log something for this?
That's... Odd. What do you get when you do:
Code:
console.log(this); this.mixItem(1).effects[0].value2 + this.mixItem(2).effects[0].value2;
does it still say this.mixItem is not a function? Does it log something for this?

That gives me console output but i cant find the value of 500 anywhere.

Code:
Game_Action {_subjectActorId: 1, _subjectEnemyIndex: -1, _forcing: false, _item: Game_Item, _targetIndex: 0, …}
Right. It's strange that you would get the error "this.mixItem" is not a function, when the Plugin declares "Game_Action.prototype.mixItem" as a method.

Are you sure you didn't make a typo somewhere on the first try? What if you do:
Code:
console.log(this, this.mixItem, this.mixItem(1), this.mixItem(2)); this.mixItem(1).effects[0].value2 + this.mixItem(2).effects[0].value2;

I would expect to see a Game_Action instance, a function declaration, then a couple Game_Item instances. I'm interested in seeing the damage and effects properties of the Game_Items.
Ok this gives me that in the console but i didnt found anything inside of the many subcategorys.
Code:
Game_Action {_subjectActorId: 1, _subjectEnemyIndex: -1, _forcing: false, _item: Game_Item, _targetIndex: 0, …} ƒ (index) {
        var obj = this.mixAction()[index - 1]
        return obj ? this.subject().getMixItem(obj) : null;
    } {id: 1, animationId: 41, consumable: true, damage: {…}, description: "", …} {id: 2, animationId: 41, consumable: true, damage: {…}, description: "", …}
When you console.log something, there should be some arrows on the left-hand side you can use to expand various properties out.

I'm looking for something like this:
wIlcDxC.png
When you console.log something, there should be some arrows on the left-hand side you can use to expand various properties out.

I'm looking for something like this:
wIlcDxC.png


Here is what i get but nothing helpfull so far:
sdfdsfgdgdfgdfcpjwt.png
Can you open up the two Game_Items instead of the Game_Action? Try running this, it should get rid of the stuff we don't need to look at:

Code:
console.log(this.mixItem(1), this.mixItem(2)); this.mixItem(1).effects[0].value2 + this.mixItem(2).effects[0].value2;

You should get two Objects that you can expand, we'll want to look at the damage and effects for both.
Can you open up the two Game_Items instead of the Game_Action? Try running this, it should get rid of the stuff we don't need to look at:

Code:
console.log(this.mixItem(1), this.mixItem(2)); this.mixItem(1).effects[0].value2 + this.mixItem(2).effects[0].value2;

You should get two Objects that you can expand, we'll want to look at the damage and effects for both.

Now i can see the value of 500 for one of the two items used:
unbenanntiskdn.png
If you open up the second one (there's another expandable item in your screenshot, it says "Object" - that's mixItem 2), is it also 500?

Also, can we see a screenshot of the skill where you're using the two mixItems in your formula?
If you open up the second one (there's another expandable item in your screenshot, it says "Object" - that's mixItem 2), is it also 500?

Also, can we see a screenshot of the skill where you're using the two mixItems in your formula?

Ok now i got it hehe. It was the small arrow just benath the first object... So dumb i didnt seen it before lol.
This is what the console give me:
Spoiler: Console
consolemixjvksc.png
Idk why its 200 but at least we found the error. ^^
It looks to me like mixItem(1) returns a Trank, which restores 500 HP, and mixItem(2) returns a Magisches Wasser, which presumably restores 200 HP (I'm guessing it originally restored 200 MP, but I think the value1 property is indicating it's restoring HP now).

I'd check your item database for item 2 (or whatever item Magisches Wasser is) and check its effects.

Original thread: https://forums.rpgmakerweb.com/threads/get-item-skill-effect-values-in-a-formula.105261/