#Get name of players item including default name

1 messages · Page 1 of 1 (latest)

junior lily
#

I'm trying to get the name of a players item and then color it including default name like "Netherite Sword" but im stuck on this current stage

    trigger:
        set {_item} to player's held item
        set {_itemname} to name of {_item}
        set {_itemname} to unformatted {_itemname}
        set name of player's tool to "&c%{_itemname}%"```
I made this a couple months ago without needing any addons but now that file is nuked i have to recreate it again and dont remember how
bright drift
#

Yeah, i would set the name variable to name of item ? type of item

junior lily
#

wouldnt that ignore their actual name if its set? ill do an if statement ig then

bright drift
#

The ? Makes it so it only uses the type if the name isnt set

junior lily
bright drift
#

set {_itemname} name of player's tool ? type of player's tool

junior lily
#

i dont know how to read those question marks like how do i implement that inside the script? what do i type in place of the question marks

bright drift
#

nothing

#

Thats the exact line

junior lily
#

cuz copy pasting that without changing returned unknown condition

bright drift
#

?

#

Send

junior lily
#
    trigger:
        set {_item} to player's held item
        set {_itemname} name of player's tool ? type of player's tool
        set {_itemname} to unformatted {_itemname}
        set name of player's tool to "&c%{_itemname}%"```
aint it like this?
#

ok i added "to" right after itemname that worked it

#

so tried it now and it still returns <none> with this script

    trigger:
        set {_item} to player's held item
        set {_itemname} to name of player's tool ? type of player's tool
        set {_itemname} to unformatted {_itemname}
        set name of player's tool to "&c%{_itemname}%"```
bright drift
#

Get rid of the unformatted line

junior lily
#

okay so thank you so much that does it i can get the item name but it returns in a way thats all lowercase and i have no idea what i can use to have their first letters uppercase

bleak ibex
#

Copy of given text in Lowercase, Uppercase, Proper Case, camelCase, PascalCase, Snake_Case, and Kebab-Case

Example
"Oops!" in lowercase # oops!
"oops!" in uppercase # OOPS!
"hellO i'm steve!" in proper case # HellO I'm Steve!
"hellO i'm steve!" in strict proper case # Hello I'm Steve!
"spAwn neW boSs ()" in camel case # spAwnNeWBoSs()
"spAwn neW boSs ()" in strict camel case # spawnNewBoss()
"geneRate ranDom numBer ()" in pascal case # GeneRateRanDomNumBer()
"geneRate ranDom numBer ()" in strict pascal case # GenerateRandomNumber()
"Hello Player!" in snake case # Hello_Player!
"Hello Player!" in lower snake case # hello_player!
"Hello Player!" in upper snake case # HELLO_PLAYER!
"What is your name?" in kebab case # What-is-your-name?
"What is your name?" in lower kebab case # what-is-your-name?
"What is your name?" in upper kebab case # WHAT-IS-YOUR-NAME?
Requirements

Skript 2.2-dev16 (lowercase and uppercase), 2.5 (advanced cases)

junior lily
# bleak ibex

using proper and proper strict case its only capitalizing the Sword while netherite remains lowercase

#

it becomes "netherite Sword"

#

how could i case it like "Netherite Sword"?

vivid matrix
#

strict proper case should do the job

junior lily
bright drift
#

Thats strange

#

Send your code

junior lily
#
    trigger:
        set {_item} to player's held item
        set {_itemname} to name of player's tool ? type of player's tool
        #set {_itemname} to unformatted {_itemname}
        set name of player's tool to uncolored "%{_itemname}%" in strict proper case
        set name of player's tool to "&c%{_itemname}%" in strict proper case
        send "&f:efsun: &d&l» &bEşyanızın ismini başarıyla &cKırmızı &brenge dönüştürdünüz!"```
im also trying to uncolor it before coloring it to red so whatever color it had before could turn to red, no luck though
bright drift
#

I think its making the c in &c capital

#

Try something like this

#
    trigger:
        set {_itemname} to name of player's tool ? type of player's tool
        set {_itemname} to uncolored "%{_itemname}%" in strict proper case
        set name of player's tool to "&c%{_itemname}%"
        send "&f:efsun: &d&l» &bEşyanızın ismini başarıyla &cKırmızı &brenge dönüştürdünüz!"```
junior lily
#

that worked thank you so much, is there any syntax that i can use to check if the tool has a custom name beforehand so i dont proper case their stuff if it has a name?

bright drift
#

Ye, you could do the propper case thing to the type part instead

#
    trigger:
        set {_itemname} to name of player's tool ? "%type of player's tool%" in propper case
        set name of player's tool to "&c%{_itemname}%"
        send "&f:efsun: &d&l» &bEşyanızın ismini başarıyla &cKırmızı &brenge dönüştürdünüz!"```
junior lily
bright drift
#

Might need to add ()

#

For the part after the ?

junior lily
#

Yep, that did it, cheers

#

What did the parantheses exactly do in this case btw?