#How do I add lore to an item and how do I detect I the player is holding an item with specific lore?

1 messages ยท Page 1 of 1 (latest)

crystal helm
#

itemStack.setLore()

#

takes string array or RawMessage array

#

itemStack.getLore() returns string array
iremStack.getRawLore() returns RawMessage array

#

although i personally dont recommed using lore text to store and get forms of data, its way too fragile for that

fossil obsidian
fossil obsidian
crystal helm
#

hmm?

#

can you elaborate

fossil obsidian
#

Like maybe I want to add it to an item test:item how would I add the lore to that specific item?

#

Also removing lore.
Sorry my Internet tweaking right now ๐Ÿ˜ญ

crystal helm
#

you remove lore by setting empty array

#

also you just get an item with that identifier and use that method

fossil obsidian
#

Ahh that makes sense

#

Thanks!

fossil obsidian
# crystal helm also you just get an item with that identifier and use that method

It's been a while since I played with scripts so I've confused myself ๐Ÿ˜…

import { itemStack, world, system } from "@minecraft/server";

system.runInterval(() => {
  for (const player of world.getPlayers()) {
    const inventory = player.getComponent("inventory").container;
    for(let i = 0; i < inventory.size; i++) {
      const item = inventory.getItem(i);
      if (item.typeId == "test:item" && item.getLore().length == 0) {
        item.setLore(["Lore!"]);
      }
    }
  }
})

I'm not sure how itemStack comes in