Add item with variable

Hi, I would like to know if it would be possible to add an object based on one variable and the quantity based on another variable, I am trying to do it through the script call

$ gameParty.gainItem ($ dataItems [itemId], n);

But I don't know how to add in variable 1 in "itemId" and in variable 2 in "n". Would it be possible to do this?

I work with the RPG Maker MV in case that changes anything.

Thanks in advance.
Try this in a Script command:
JavaScript:
var itemId = $gameVariables.value(1);
var count = $gameVariables.value(2);
$gameParty.gainItem($dataItems[itemId], count);
🙂
$gameVariables.value() is the reference you want.

JavaScript:
$gameParty.gainItem($dataItems[$gameVariables.value(1)], $gameVariables.value(2));

edit: caethyril in before me by seconds with a slightly different variant! 😀
Good, thank you very much caethyril and Rubescen both options work.
Greetings and thanks.

Original thread: https://forums.rpgmakerweb.com/threads/add-item-with-variable.122829/