Ways to change Variable after using item ?

Hello, i am working on game with hunger system, the hunger for sure is variable,
i used a damge formula to controle the variable, something like this:
$gameVariables.setValue(19, $gameVariables.value(19) + 50);
it worked fine for me but i kept updating the game without testing it (huge mistake ...) and after i add many things and plugins i teste it the game and i found that after i use item with that formula i got this error:
Error.png

i don't know coding so i didn't understand exactly what the reason of this error ... it could be because of plugin i installed or something else, here a list of my plugins before and after the error,
Before Error:
Older Version Plugins.png

After Error Plugins:
New Version Plugins.png

There is any way i can fix this error ?
Or maybe there is other ways to controle variable using items ?
$gameVariables.setValue(19, $gameVariables.value(19) + 50);
I don't see a reason for you to be using scripting commands for this. If you mouse over the damage formula box, it says you can reference variables by using v[x]. So you would say:
Code:
v[19]+=50;
or if you're not familiar with JavaScript syntax,
Code:
v[19]=v[19]+50;
it worked fine for me but i kept updating the game without testing it (huge mistake ...) and after i add many things and plugins i teste it the game and i found that after i use item with that formula i got this error:
That code itself isn't the cause of the error you got, but because you have an invalid formula.

If that's the only thing in your damage formula...what is the actual value for the damage/healing that the skill is doing? The setValue() function doesn't return any value, so your skill is saying "damage/heal the player for this much!" and then not saying how much.

So what is the actual skill supposed to be doing? If the damage or healing is supposed to be the new value of variable 19, then you need to say so:
Code:
v[19]+=50; v[19]
A damage formula needs an actual number.
I don't see a reason for you to be using scripting commands for this. If you mouse over the damage formula box, it says you can reference variables by using v[x]. So you would say:
Code:
v[19]+=50;
or if you're not familiar with JavaScript syntax,
Code:
v[19]=v[19]+50;

That code itself isn't the cause of the error you got, but because you have an invalid formula.

If that's the only thing in your damage formula...what is the actual value for the damage/healing that the skill is doing? The setValue() function doesn't return any value, so your skill is saying "damage/heal the player for this much!" and then not saying how much.

So what is the actual skill supposed to be doing? If the damage or healing is supposed to be the new value of variable 19, then you need to say so:
Code:
v[19]+=50; v[19]
A damage formula needs an actual number.
Thank you for the reply.
That the only thing in the damge formula,
In the Effect section, i did:
Add State: Normal Attack 100%

the only reason for this items is to add the value of the hunger variable.
i try to change the Add state to heal but i get the same problem .
Thank you for the reply.
That the only thing in the damge formula,
In the Effect section, i did:
Add State: Normal Attack 100%

the only reason for this items is to add the value of the hunger variable.
i try to change the Add state to heal but i get the same problem .
Did you read my previous post?

In order to be able to type into the damage formula box, you must have used the Damage Type drop-down box above it to choose that this skill is doing some type of damage or healing.

If you are doing damage or healing, you must provide a number as to how much the skill is going to damage or heal.

If you are not doing damage or healing, you should not choose it from the Damage Type box, and the damage formula is not the correct method to do this. You should be calling a common event instead.
Did you read my previous post?

In order to be able to type into the damage formula box, you must have used the Damage Type drop-down box above it to choose that this skill is doing some type of damage or healing.

If you are doing damage or healing, you must provide a number as to how much the skill is going to damage or heal.

If you are not doing damage or healing, you should not choose it from the Damage Type box, and the damage formula is not the correct method to do this. You should be calling a common event instead.
Oh ok i get it now, sorry i am new to this stuff ...
yes i was using Hp Damge, after i add the damge formula with :
Code:
v[19]=v[19]+50;
the error massage didn't appear ,
maybe i should change Hp damge to 0 or something anyway .
Thank you so much for the help !
maybe i should change Hp damge to 0 or something anyway .
Well, as I said,
If you are not doing damage or healing, you should not choose it from the Damage Type box, and the damage formula is not the correct method to do this. You should be calling a common event instead.
But whatever works for you!
I forget to answear this question;
If you are not doing damage or healing, you should not choose it from the Damage Type box, and the damage formula is not the correct method to do this. You should be calling a common event instead.
I didn't use common event because i have many items, i want every item to have different value, with common event it possible but i think it will be much more complex,
with formula it much easy to use and navigate if i want to do some changes in the future.
I'm not convinced the battle formula is the cause. I tried recreating it without your plug ins and it works just fine.
The Error messages all have to do with Hud displays.

Is there perhaps a "hunger" bar/gauge?
I'm not convinced the battle formula is the cause. I tried recreating it without your plug ins and it works just fine.
The Error messages all have to do with Hud displays.

Is there perhaps a "hunger" bar/gauge?
There is hunger bar as images,
in the HP damge formula i didn't have damge formula i just used this $gameVariables.setValue(19, $gameVariables.value(19) + 50);
before it worked fine for me with the Hunger bar "images" but like i said after adding many things to the game i had the error,
now with ATT_Turan help when i add damge formula with my old code i didn't get error but the variable didn't work, after i used the code ATT_Turan recommend it worked fine for me.
But was that in battle? or in menu? How do you want to use it?

I'm just pointing out that, normally, in menu, there is a check to determine an item's effect.
It stops you from using a Potion on a Character with Full Health in menu, for example. But it's permitted in battle.

So, depending on the source of the problem I can see how changing the damage formula fix the error message. But I'm wondering if you're just creating another problem you haven't noticed yet.
Like, a Potion that recovers 0hp can't be used in the main menu because the system sees that as having no effect.
But was that in battle? or in menu? How do you want to use it?

I'm just pointing out that, normally, in menu, there is a check to determine an item's effect.
It stops you from using a Potion on a Character with Full Health in menu, for example. But it's permitted in battle.

So, depending on the source of the problem I can see how changing the damage formula fix the error message. But I'm wondering if you're just creating another problem you haven't noticed yet.
Like, a Potion that recovers 0hp can't be used in the main menu because the system sees that as having no effect.
I think it can be used on both, i didn't try item that increas the player hunger variable value but in menu it work,
i notice when i used healing effect to it, when the player is full health it wont work that why in did it as damge formula that deal 0 damge to the player
before i had the problem to make the item usable i had effect add state normal attack100%, now i didn't change that .
here a pic for it:
SS.png
So v[18]= doesn't change the variable. It's just references the value for damage calculation.
Unless there's something in the plugins that I don't know about that does damage formulas differently.

Just to confirm. This is or isn't working for you?
@Warthief you might have another, completely unrelated problem.

you listed plugins as a screenshot of the plugin folder. That does exactly nothing as a plugin in the folder is not automatically activated - you need to activate them in the plugin manager.

And the reason why we prefer screenshots of the plugin manager for those lists is not only because that has more info, but also because it shows the order of the plugins.

Because the order is important - and if you added the plugins in the alphabetical order from the folder-screenshots, a lot of them will cause problems for being in the wrong order.

Please make sure that you got them in the correct order, especially the YEP ones.
So v[18]= doesn't change the variable. It's just references the value for damage calculation.
Oh, I see what you're saying. It copies the array for reference.
I'm not convinced the battle formula is the cause.
As for this, it certainly seems to be. The error message (provided double is non-finite) is what you get when you provide a function that doesn't return a value as an argument for another function that expects a value.
So v[18]= doesn't change the variable. It's just references the value for damage calculation.
Unless there's something in the plugins that I don't know about that does damage formulas differently.

Just to confirm. This is or isn't working for you?
It worked fine for me.
And the reason why we prefer screenshots of the plugin manager for those lists is not only because that has more info, but also because it shows the order of the plugins.
Yes true i should have get screen shoot from the plugin manager .
Oh, I see what you're saying. It copies the array for reference.
I notice something, the problem for me was not because my old formula, i don't know why but i did by mistake create item that have empty damge formula and i got the same error, but i don't think this could create error in new project .

Original thread: https://forums.rpgmakerweb.com/threads/ways-to-change-variable-after-using-item.145282/