#how do I get the first item of id inside of players inventory?

4 messages · Page 1 of 1 (latest)

torn widget
#

more specifically I need to get the first item of any of the ids inside of reinforcements, get the value and also the item,
so I can decrease the count by one. (from the players inventory)

let REINFORCEMENTS = {
  'reinforcing:iron_reinforcement': 25,
  'reinforcing:gold_reinforcement': 50,
  'reinforcing:diamond_reinforcement': 100,
  'reinforcing:netherite_reinforcement': 500
};

BlockEvents.rightClicked(event => {
  let { player } = event;
    
});
dusk coralBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

torn widget
#

glup

torn widget
#
  for (let [itemId, value] of Object.entries(REINFORCEMENTS)) {
    let stack = player.inventory.items.find(i => i && i.id === itemId);
    if (stack) {
      stack.count -= 1;
      return value;
    }
  }