#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)
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
Oh okay then I'll just use it for displaying lore stuff. Thank you! ๐ซ
How would I add it to a specific item? ๐ค
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 ๐ญ
you remove lore by setting empty array
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
seems fine to me