MZ Item removed from inventory based on variable value?

Is it possible to remove (-1) automatically an item whose ID number matches the value of a variable?
This should be the correct script call:

$gameParty.loseItem($dataItems[X], Y);

Replace X with "$gameVariables.value(number)"
Replace Y with the amount, in this case 1

Original thread: https://forums.rpgmakerweb.com/threads/item-removed-from-inventory-based-on-variable-value.152733/