#Checking for lore doesn't pass

1 messages · Page 1 of 1 (latest)

sacred zealot
#
    send "&9&l🔰"
    send lore of player's helmet to player
    if lore of player's helmet contains "&9&l🔰":
        send "yes" to player
        set {_lore::*} to lore of player's helmet
        replace all "&9&l🔰" in {_lore::*} with ""
        loop {_lore::*}:
            send loop-value to player```

why is the if statement not passing?
#

the lore contains it but doesn't pass it

crisp vine
#

lore returns a list

#

contains will check each entry of that list and see if any of them are 1:1 exact

sacred zealot
#

is there a difference between contains and has?

crisp vine
#

in order to get a partial match check you need to first loop each lore line, then check if loop-value contains "the partial match"

crisp vine
#

if i had to guess its a skript synonym

sacred zealot
#

yeah that's what I thought. I did plan to loop the value to grab the number. But I can see how I have to loop every number to then grab it

crisp vine
#

similar to > and greater than

#

if your goal here is to use lore to determine item stats you'd be better off using nbt

#

its a lot faster to fetch and access

#

set float tag "armor" of custom nbt of <item> to 1.5

sacred zealot
#

using lore still makes it easier to make items with and not have to go back to my code for every item.

#

especially when my friends make the items and don't have access to code

crisp vine
#

just make a registry function

#
function registerItem(i: item, name: text, armor: number, etc...):
    set float tag "armor" of custom nbt of {_i} to {_armor}
    ...
    return {_i}```
#

can also save the item in a variable instead of returning it

#

up to you

sacred zealot
#

so you're basically saying

I should make a command to register items with stats
It will stay as a item entry if I set it as a variable
and I will be able to easily check for the tag when I need to

crisp vine
#

yeah

#

make it a function, then you can have a command call the function like /register iron_sword "&fSword" 15 10 or something

#

you'd want a way to delete them too but that wouldn't be too hard

#

can use the name of the item as an index, like set {-database::%{_index}%} to {_i}

#

{_index} being uncolored {_name} in lowercase

thorny lynx
#

you want to add NBT to the item rather than checking the lore, because lore is a text and youd have to do a bunch of work to isolate the digits and then parse as a number. NBT tags are simply easier

sacred zealot
#

It's easier to use itemedit with items and then run them through a function rather than make the item solely based on item type name and lore
I would think of just doing "/register [<defense>] [<health>] [<attack>]" and grabbing the players tool to register it would work better for our favor.

#

and maybe add it to a list so we can add it to a item gui if we want for every custom item in the server

crisp vine
#

yeah only issue is migrating it or if the variables get wiped

#

then you're a bit chalked

sacred zealot
#

backups still exist

#

I'll use the lore temporarily until before alpha for my server releases

#

because I would have to make a whole system for that

#

it'll make it a lot easier to make items with stats with it. So I will definitely implement it

sacred zealot