• Hey! Register here to create your account, engage with the community, and talk about what is new!

If Player : Item Lore Equals

sapfii

Staff Manager
Administrator
Joined
Jan 12, 2021
Messages
21
Reaction score
5
As the title suggests, this would detect if an item has a specific lore
An example being if I wanted to make a custom enchantment, I could just

PlayerEvent : PlayerDamagePlayer
IfPlayer : IsHolding{
IfPlayer : ItemLoreEquals("Poison III"){
PlayerAction(Victim) : GiveEffect(Poison, 999:999, 2)
}
}

instead of the more tedious route of

PlayerEvent : PlayerDamagePlayer/Entity
IfPlayer : IsHolding{
PlayerAction(Victim) : GiveEffect(Poison, 999:999, 2)
}
IfPlayer : IsHolding{
PlayerAction(Victim) : GiveEffect(Poison, 999:999, 2)
}
}

this would save space AND time, and I would really love to see this in-game

Thanks,
Cam'Ron
 

Attachments

  • 2021-01-12_15.00.01.png
    2021-01-12_15.00.01.png
    681.8 KB · Views: 8

Erobus

New member
Joined
Sep 14, 2020
Messages
11
Reaction score
2
well I think you can just use already existing variable actions for that.
for example
ifplayer: ifholding {
getItemLore (varname, main-hand-item 'attacker')
IfVariable: ListIndexEquals (varname, lore line index, text){
action,}}
does require only 1 more Codeblock
you can also use IfVariable: ListContains (varname, text){} to search through the entire list

or feel free to use /support request, they will help you to get the most easy way ^^
 

Vulcano

Forum adept
Overlord
Joined
Sep 11, 2020
Messages
251
Reaction score
65
Erobus gave a great way to do it! The use cases do not justify this being added, as you can just use item tags.
 

S4nders

New member
Joined
Oct 7, 2020
Messages
11
Reaction score
19
Here's an easier, more efficient way.
Don't use the lore of your item in code (it will only be a visual representation), and have the mechanism handled by Custom Item Tags instead.

Here's how you can use custom item tags in your case.
Type this command on your items that have Poison III: /item tag add poison_enchant 3
This will add an item tag with the name poison_enchant and the number value 3.
You can always check the custom tags on an item using /item tag list.

Now, on the player damage player event:
If Variable: Item Has Tag (Held item game value, Text: "poison_enchant") {

_ Set Variable: Get Item Tag (Local Variable: "enchantLevel", Held item game value, Text: "poison_enchant")

_ Set Variable: Set Potion Effect Amplifier (Local Variable: "potion", Poison potion, Local Variable: "enchantLevel")

_ [Victim] Player Action: Give Effect (Local Variable: "potion")

}

Now, instead of having to add an If Statement for each poison level, this If Statement will handle every poison level for you. It uses the number value of the poison_enchant item tag.

You can apply this same logic to any of your custom enchantments. For example, if you have a Healing enchantment, you can check if the held item has the healing_enchant item tag, get the number value of the healing_enchant, and use number this in a Heal action.
 

sapfii

Staff Manager
Administrator
Joined
Jan 12, 2021
Messages
21
Reaction score
5
Here's an easier, more efficient way.
Don't use the lore of your item in code (it will only be a visual representation), and have the mechanism handled by Custom Item Tags instead.

Here's how you can use custom item tags in your case.
Type this command on your items that have Poison III: /item tag add poison_enchant 3
This will add an item tag with the name poison_enchant and the number value 3.
You can always check the custom tags on an item using /item tag list.

Now, on the player damage player event:
If Variable: Item Has Tag (Held item game value, Text: "poison_enchant") {

_ Set Variable: Get Item Tag (Local Variable: "enchantLevel", Held item game value, Text: "poison_enchant")

_ Set Variable: Set Potion Effect Amplifier (Local Variable: "potion", Poison potion, Local Variable: "enchantLevel")

_ [Victim] Player Action: Give Effect (Local Variable: "potion")

}
Now, instead of having to add an If Statement for each poison level, this If Statement will handle every poison level for you. It uses the number value of the poison_enchant item tag.

You can apply this same logic to any of your custom enchantments. For example, if you have a Healing enchantment, you can check if the held item has the healing_enchant item tag, get the number value of the healing_enchant, and use number this in a Heal action.
Thanks for the information! I'm an old-ish DF player from around 2017 so my brain is used to doing things like they were back then lol
 
Top Bottom