Plugin Request: Equipment & Inventory Variables.

Hi everyone!
I would need a plugin to assign the variable when the weapons is in inventory and also in the equipment.
Because i need to give the variables at all weapons in game.
Could you make this script for me?

I have seen the script by LadyBaskerville, That it called "Equipment Variables".

Thanks ☺️

I've moved this thread to Plug-In Requests. Thank you.

Now I feel bad for not thinking of this when you asked me in the other thread, but I only just realized: is there a reason why you can't use the Control Variable event command? It has an option to set a variable to the number of items in the inventory (with/without equipment). You could make a Common Event for setting the variable to the right value (with all the maths you need) and call it every time right before you use that variable.

Unless you need the variable in a context where you can't call a common event/do the calculations with Event Commands - in that case it would be great if you could give some more details on what exactly you want to do.
Now I feel bad for not thinking of this when you asked me in the other thread, but I only just realized: is there a reason why you can't use the Control Variable event command? It has an option to set a variable to the number of items in the inventory (with/without equipment). You could make a Common Event for setting the variable to the right value (with all the maths you need) and call it every time right before you use that variable.

Unless you need the variable in a context where you can't call a common event/do the calculations with Event Commands - in that case it would be great if you could give some more details on what exactly you want to do.

Hi Lady, Thanks for your reply.
Then.. I being not expert, I don't know all the possible solutions, but..
I would like the game every time knew how many weapon my PG has with him. Both for the equipment and for inventory.
This is for make it work much events in this my game.
I hope i was clear to explaining what i would like. Because I do not speak English well eheh
Ah, I think I understand now. So doing it with events would work in theory, but it would be very impractical to check for each weapon in the game how many the player has and add them all? Because if that is the case, I think a script call would work best. Basically, you could tell the program in any event "Count how many weapons (equipped and not equipped) the player has in total and set a variable to that number." Would that work for you? If yes, I can put the script call together for you later today.
Ah, I think I understand now. So doing it with events would work in theory, but it would be very impractical to check for each weapon in the game how many the player has and add them all? Because if that is the case, I think a script call would work best. Basically, you could tell the program in any event "Count how many weapons (equipped and not equipped) the player has in total and set a variable to that number." Would that work for you? If yes, I can put the script call together for you later today.

Oh yes! Would work so.
When i want check the weapons of the Characters in the group (Both only for my principal character then for all character in the group) Just i call the script and it would works?
Exactly. Here's the code; simply copy it into a Script Call event command:
Code:
var weaponCount = 0;
// add weapons in inventory
for (var i = 1; i <= $dataWeapons.length; i++) {
  weaponCount += $gameParty.numItems($dataWeapons[i]);
}
// add weapons in equipment
$gameParty.members().forEach(function(actor) {
  if (actor.equips()[0]) weaponCount++;
  });
// set a game variable to the total number of weapons
$gameVariables.setValue(6, weaponCount); // change the 6 in this line if you need to
This counts the total number of weapons in the party's inventory and in the equipment of all actors in the party. Then it sets a variable to that value - currently it uses variable #6, but you can just change that number in the last line of the script call.

If you don't want to include the equipment of every actor, but only of actor #1 (or a different one, you can change that again), use the following:
Code:
var weaponCount = 0;
// add weapons in inventory
for (var i = 1; i <= $dataWeapons.length; i++) {
  weaponCount += $gameParty.numItems($dataWeapons[i]);
}
// add weapons in equipment
if ($gameActors.actor(1).equips()[0]) weaponCount++; //change here for a different actor id
// set a game variable to the total number of weapons
$gameVariables.setValue(6, weaponCount);// change the 6 in this line if you need to

Let me know if it works; if there are any errors, I'll be back to fix them in a few hours (have to go to work for now).
Exactly. Here's the code; simply copy it into a Script Call event command:
Code:
var weaponCount = 0;
// add weapons in inventory
for (var i = 1; i <= $dataWeapons.length; i++) {
  weaponCount += $gameParty.numItems($dataWeapons[i]);
}
// add weapons in equipment
$gameParty.members().forEach(function(actor) {
  if (actor.equips()[0]) weaponCount++;
  });
// set a game variable to the total number of weapons
$gameVariables.setValue(6, weaponCount); // change the 6 in this line if you need to
This counts the total number of weapons in the party's inventory and in the equipment of all actors in the party. Then it sets a variable to that value - currently it uses variable #6, but you can just change that number in the last line of the script call.

If you don't want to include the equipment of every actor, but only of actor #1 (or a different one, you can change that again), use the following:
Code:
var weaponCount = 0;
// add weapons in inventory
for (var i = 1; i <= $dataWeapons.length; i++) {
  weaponCount += $gameParty.numItems($dataWeapons[i]);
}
// add weapons in equipment
if ($gameActors.actor(1).equips()[0]) weaponCount++; //change here for a different actor id
// set a game variable to the total number of weapons
$gameVariables.setValue(6, weaponCount);// change the 6 in this line if you need to

Let me know if it works; if there are any errors, I'll be back to fix them in a few hours (have to go to work for now).

Omg, i love you!😍
Ok.. hahaha I'm sorry for this my sudden reaction.

Yes, it's work perfectly!

Thank You very much for the help.
At the end of game i insert you on the special thanks in the end credits.
Thank you very much again. 👍☺️☺️☺️👍
Haha, no problem! Glad I could help 🙂

Original thread: https://forums.rpgmakerweb.com/threads/plugin-request-equipment-inventory-variables.88305/