Anvil lore change help

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Natulilakk

Member
Feb 3, 2024
4
1
3
im trying to make when you have 2 of the same lore in a anvil (Treasure Huter I + Treasure Huter I will become Treasure Huter II)

on anvil prepare:
if slot 0 of event-inventory is a netherite shovel:
if lore of slot 0 of event-inventory contains "&eTreasure Hunter I":
if slot 1 of event-inventory is a netherite shovel:
if lore of slot 1 of event-inventory contains "&eTreasure Hunter I":
if slot 2 of event-inventory is a netherite shovel:
if lore of slot 2 of event-inventory contains "&eTreasure Hunter I":
set {_itemlore} to slot 2 of event-inventory
set lore at line 1 of {_itemlore} to "TEXT"
play sound "entity.experience_orb.pickup" at volume 1 at pitch 1 at location(721, 83, 1090)
 
im trying to make when you have 2 of the same lore in a anvil (Treasure Huter I + Treasure Huter I will become Treasure Huter II)

on anvil prepare:
if slot 0 of event-inventory is a netherite shovel:
if lore of slot 0 of event-inventory contains "&eTreasure Hunter I":
if slot 1 of event-inventory is a netherite shovel:
if lore of slot 1 of event-inventory contains "&eTreasure Hunter I":
if slot 2 of event-inventory is a netherite shovel:
if lore of slot 2 of event-inventory contains "&eTreasure Hunter I":
set {_itemlore} to slot 2 of event-inventory
set lore at line 1 of {_itemlore} to "TEXT"
play sound "entity.experience_orb.pickup" at volume 1 at pitch 1 at location(721, 83, 1090)
Quite a few issues with your code. For the biggest issue, you don't have to check every single slot for the same item super long. You can set it as a separate variable. Also, since two pieces of your code check for the same item, you can check both slots at the same time. Finally, there's a much more simple way to set the lore. See the changes I made in the code I provided below. Longer code does not mean good code, thus why I shortened your code to 8 lines whilst still having it do its intended purpose (It also has no errors to my knowledge, not tested in game though):
Code:
on load:
    set {nshovel} to netherite shovel with lore "&eTreasure Hunter I" # Separately sets the target item to shorten next few lines
on anvil prepare:
    slot 0 and 1 of event-inventory is {nshovel} # We check both slot 0 and 1 at the same time to limit lines
    if slot 2 of event-inventory is {nshovel}:
        set {_i} to event-item # Sets {_i} to the target item
        set line 1 of lore of {_i} to "&eTreasure Hunter II" # Manually changes the item using the previously set variable
        play sound "entity.experience_orb.pickup" at volume 1 at pitch 1 at location(721, 83, 1090)
 
It does not really work
 

Attachments

  • 1707059772027.png
    1707059772027.png
    20.5 KB · Views: 154
unfortaly i dont really get it why it wont change the lore from Treasure Hunter I to Treasure Hunter II
 
Yas i did it and all i needed to do was

Code:
on inventory click:
    if player's current inventory's type is anvil inventory:
        if slot 2 of event-inventory's lore is "&eTreasure Hunter I":
            clear lore of item
            set lore of item to "&eTreasure Hunter II"
 
  • Like
Reactions: Luke_Sky_Walker