MV I need a plugin that when using an object changes the value of a variable. [SOLVED]

It's simple, what I want is that when using an object a variable is changed as it says in the title. But without using a "common event".

I know the request is short but it is just that xD. Thanks for reading.
It's simple, what I want is that when using an object a variable is changed as it says in the title. But without using a "common event".

I know the request is short but it is just that xD. Thanks for reading.
My latest script can handle this and much more 😉


Setup would be something like this:
Spoiler: Parameter setup & Other info
1651970597345.png


Using the following Parameters
Class: Game_Party
Property of function: prototype
Function: consumeItem

This script used in the "post script" parameter would set game variable 50 to become the item name:
$gameVariables.setValue(50, item.name);

Of course you can alter the script to become whatever you desire 😉
If you want to set it to a certain property of the item like name, id, etc.
Here is the data class info for "item" for your reference 😉

Spoiler: Video of setup & how it looks in game
Which kind of "Object" are we talking about?
My latest script can handle this and much more 😉


Setup would be something like this:
Spoiler: Parameter setup & Other info
View attachment 225538

Using the following Parameters
Class: Game_Party
Property of function: prototype
Function: consumeItem

This script used in the "post script" parameter would set game variable 50 to become the item name:
$gameVariables.setValue(50, item.name);

Of course you can alter the script to become whatever you desire 😉
If you want to set it to a certain property of the item like name, id, etc.
Here is the data class info for "item" for your reference 😉

Spoiler: Video of setup & how it looks in game

I have been trying your script for a while but no success. I get this error:

Screenshot_1352.png


I have put the code as follows:

Screenshot_1353.png


I also did not understand very well what you wanted to tell me with your script or how that code worked. If I understood correctly, the code makes that when I use an item "I put the name in "item.name" " it makes the variable 50 change to... I don't know xD. Maybe it's me who doesn't understand English very well since I'm from Spain.

I don't know if I was understood because I was very brief with my description of what I wanted. What I want to do is that by consuming a "CatCake" object in this case, we change a variable "Object_used" we could call a certain value "1,2,3,4"

So to know which item has used in the first place which object I used according to the variable:

Object_used=1 - CatCake
Item_used=2 - Potion
Item_used=3 - Water

I'm sorry to repeat it again, it's to know if I understand what I meant 😅.
Which kind of "Object" are we talking about?
Aah... Sorry.

A consumable item that makes it change a game variable.
I have been trying your script for a while but no success. I get this error:

View attachment 225603

I have put the code as follows:

View attachment 225604

To fix the error you are getting of "$gameVariable is not defined" make sure you are using the code $gameVariables instead of $gameVariable
make sure to include the "s" on because the variable name for the game variables is $gameVariables
I also did not understand very well what you wanted to tell me with your script or how that code worked. If I understood correctly, the code makes that when I use an item "I put the name in "item.name" " it makes the variable 50 change to... I don't know xD. Maybe it's me who doesn't understand English very well since I'm from Spain.

I don't know if I was understood because I was very brief with my description of what I wanted. What I want to do is that by consuming a "CatCake" object in this case, we change a variable "Object_used" we could call a certain value "1,2,3,4"

So to know which item has used in the first place which object I used according to the variable:

Object_used=1 - CatCake
Item_used=2 - Potion
Item_used=3 - Water


However I'm not really sure what you are trying to do... CatCake will only set the variable to undefined... if you are trying to set the variable to the item name it would be
JavaScript:
$gameVariables.setValue(50, item.name)

if you are trying to set the variable to become the item ID it would be
JavaScript:
$gameVariables.setValue(50, item.id)

if you are trying to set the variable to become the entire item's data object it would be
JavaScript:
$gameVariables.setValue(50, item)

If you only want to set it when using the item "CatCake" it would be something like
JavaScript:
if (item.name === "CatCake") {
  $gameVariables.setValue(50, item.name);
};

Hope that helps?
I'm a bit confused as to why you specifically want a plugin for this...if the only thing you're doing is setting a variable, this is exactly the kind of things common events are good for.

But if you want to go this way, the fixes ct_bolt gave you are good.
To fix the error you are getting of "$gameVariable is not defined" make sure you are using the code $gameVariables instead of $gameVariable
make sure to include the "s" on because the variable name for the game variables is $gameVariables



However I'm not really sure what you are trying to do... CatCake will only set the variable to undefined... if you are trying to set the variable to the item name it would be
JavaScript:
$gameVariables.setValue(50, item.name)

if you are trying to set the variable to become the item ID it would be
JavaScript:
$gameVariables.setValue(50, item.id)

if you are trying to set the variable to become the entire item's data object it would be
JavaScript:
$gameVariables.setValue(50, item)

If you only want to set it when using the item "CatCake" it would be something like
JavaScript:
if (item.name === "CatCake") {
  $gameVariables.setValue(50, item.name);
};

Hope that helps?
Thanks Ct_Volt !! Now I understand your script. It has helped me a lot lately. You're the best!🤣

P.D: Do I have to do something with this post? Delete it or modify it in any way? Because the problem is already solved

I've moved this thread to JS Plugin Requests. Thank you.

MV Support is more for help with the editor, event commands, etc. Plugin-related stuff has its own areas.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

In future you can report your post (e.g. with reason "Solved"). That brings it to the attention of the mods, who can close the thread. 👋

Original thread: https://forums.rpgmakerweb.com/threads/i-need-a-plugin-that-when-using-an-object-changes-the-value-of-a-variable-solved.147408/