MZ Simple turn off item in battle

Hi All,
if it's possible, i want to request a plugin which only have the function to turn off or on item menu in battle via switch, but without any additional feature for MZ.
Or maybe there already something like this? the reason i only request one function because it's will works well with disable menu and to avoid any incompatibility with other script.
Thank you
If you want the item command in battle to be switchable, you'll need a command manager-type plugin.
And that has by definition other effects and functions in the engine.

and if you want to avoid compatibility issues, then you should list which other plugins that needs to be compatible to.
Here's a snippet:

JavaScript:
Window_ActorCommand.prototype.addItemCommand = function() {
    this.addCommand(TextManager.item, "item", $gameSwitches.value(1));
};

Change the 1 to whatever switch number you like.
If the switch is on, the item command is enabled, if it's off it's disabled.
To make it a proper plugin, you'd have to use the plugin manager to read the switch ID from plugin parameters.
But you can just plop game specific code in a javascript file in the plugins directory and hard code things.

A slightly nicer snippet:
JavaScript:
(() => {
const _switch_id = 1;
Window_ActorCommand.prototype.addItemCommand = function() {
    this.addCommand(TextManager.item, "item", $gameSwitches.value(_switch_id));
};
})();
If you want the item command in battle to be switchable, you'll need a command manager-type plugin.
And that has by definition other effects and functions in the engine.

and if you want to avoid compatibility issues, then you should list which other plugins that needs to be compatible to.
i see, for now i can't list any plugin because i haven't used any.



Here's a snippet:

JavaScript:
Window_ActorCommand.prototype.addItemCommand = function() {
    this.addCommand(TextManager.item, "item", $gameSwitches.value(1));
};

Change the 1 to whatever switch number you like.
If the switch is on, the item command is enabled, if it's off it's disabled.
To make it a proper plugin, you'd have to use the plugin manager to read the switch ID from plugin parameters.
But you can just plop game specific code in a javascript file in the plugins directory and hard code things.

A slightly nicer snippet:
JavaScript:
(() => {
const _switch_id = 1;
Window_ActorCommand.prototype.addItemCommand = function() {
    this.addCommand(TextManager.item, "item", $gameSwitches.value(_switch_id));
};
})();

Thank you for the snippet!
I will try to look how to apply this, because looks like i will only use it two times, like when the leader party changed, and enable it when the leader party back.
@Coelocanth

sorry to bother again,

i've test it but i can't made this work, the item still select able like the attachment 😳


i've tried to save the snipped as .js file too and try to active it , and still didn't work
am i did it right? if it need a proper plugin, i guess it's out of my league for now 😳
you CANNOT use that snippet in a script command, it needs to be enabled as a plugin.
so your idea to place it in a js file was the correct one, how did you install that and where did you have problems?
However before placing it in a plugin file, you need to replace the _switch_id with the number of the switch you want to use, and then it would activate or not depending on the value of the switch.
you CANNOT use that snippet in a script command, it needs to be enabled as a plugin.
so your idea to place it in a js file was the correct one, how did you install that and where did you have problems?
However before placing it in a plugin file, you need to replace the _switch_id with the number of the switch you want to use, and then it would activate or not depending on the value of the switch.
OMG Thanks @Andar it works now!
thanks for both of you.

it works in dummy project like the attachment,
but for some reason still didn't work in my project, maybe something is wrong with my switch, i will figure it later. or maybe i will just change the my switch 0024 to 1 in my project.

thank you so much for helping.
switch 0024
there is no switch 0024 in any project, only switch 24.

NEVER use the leading zeros in coding, because that is a signal for using octal numbers, and octal 0024 is decimal 20...
there is no switch 0024 in any project, only switch 24.

NEVER use the leading zeros in coding, because that is a signal for using octal numbers, and octal 0024 is decimal 20...
lol, yeah my bad hahaha.

still it doesn't work in my project, i know my that my number 24 switch is activated since i assign an npc to disappear in autorun,. but when i got the battle after the autorun event ended, the battle item menu still on.

but it's ok, at least i know how it works now 🙂 i will try to find why it doesn't work in my project.

---edit1---
after messing with the dummy, i found out, after enabling the snipped on plugin, it just disable the item command by default, even without turning ON any switch, to make it sure, i put control switch 1 off, and the item command still not available..

also it's still weird because, if it works in dummy, i wonder why didn't work in my game, lol. all my switches should be "ON" from 1-24 right now since i never turned OFF any switches.

---edit2---
maybe i was using it wrong? what i did just save the snipped into .js and active it.

-by default without doing anything and directly did a battle processing, the item command will be not available.
-then i tried to made switch number 1 as : "disable_test_switch", because the default value is 1, so it must be switch 1.
-i switched the number 1 switch to OFF, then did a battle, but the item still not available.
All switches start as OFF in a new game.
The snippet I wrote disables the item command when the switch is OFF, so you need the switch to be ON to allow item use.

If you want to invert it so item use is allowed when the switch is OFF, edit the snippet to put an ! before the $gameSwitches condition.
In javascript (and many other programming languages), an exclamation mark means "NOT".

But here's a plugin wrapped version if that's easier to get going with.
Added parameters to invert the switch sense and set the switch ID.
All switches start as OFF in a new game.
The snippet I wrote disables the item command when the switch is OFF, so you need the switch to be ON to allow item use.

If you want to invert it so item use is allowed when the switch is OFF, edit the snippet to put an ! before the $gameSwitches condition.
In javascript (and many other programming languages), an exclamation mark means "NOT".

But here's a plugin wrapped version if that's easier to get going with.
Added parameters to invert the switch sense and set the switch ID.
I see, so that's why it's started as disabled. thank you for the updated.js, i will try it again later 🙂

Original thread: https://forums.rpgmakerweb.com/threads/simple-turn-off-item-in-battle.127245/