Chestplate slot behaves differently than regular slot

  • 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 comminuty!

    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!

Omanoctoa

Member
Feb 4, 2025
16
1
3
Hey there!
I am having trouble with getting the chestplate slot to behave similarly to a regular slot when using "cursor slot" expressions.

code snippet:
Code:
on inventory click:
    if index of event-slot is player's chestplate: #Chestplate slot check
        event-item's name = "&bLight of the &6&lDivine"
        send "divine" to player
        set {_divine} to 1
    else if event-item is 1 of netherite chestplate: #Any other slot check (using this IF statement first causes it to read the chestplate slot, in part).
        event-item's name = "&bLight of the &6&lDivine"
        send "divine2" to player
        set {_divine} to 1

    if {_divine} = 1: #If the player clicks a chestplate with golden carrots, remove the carrots and change the chestplate's lore.
        if player is alive:
            set {_slot} to index of event-slot
            set {_carrots} to amount of cursor slot of player
            send "divine3" to player
            cursor slot of player is {_carrots} of golden carrot # PROBLEM HERE???
            cancel event
            set cursor slot of player to air
            send "%{_carrots}% carrots added" to player
            add ({_carrots} * 30) to {divine::%player%} #Each GOLDEN CARROT grants 30s of energy
            send "Charged %{divine::%player%}%" to player
#            give player 1 of {item::LightoftheDivine} #DEBUG, gives you an upgrade in return!
            set line 6 of lore of slot {_slot} of player to "&8Charge Time: &7%TimeInSeconds({divine::%player%})%"



Right now, golden carrots disappear and energy is added properly only if I drop the carrots onto the chestplate while it is in a regular slot. If the chestplate is in the armor slot, nothing happens. If I click the chestplate itself (without carrots) both will properly send the "divine /2 /3" messages, but nothing else happens with the equipped slot. I can change the lore of the chestplate if it is not in the chestplate-slot, or specifically affect the chestplate slot by replacing "slot {_slot} of player" with "player's chestplate". However I cannot make it respond the same way to both instances regardless where the player has the chestplate (equipped or just in their inventory). Am i missing something?

Using Skript and SkBee only, please do not suggest an Addon :emoji_slight_smile:
 
Hey there!
I am having trouble with getting the chestplate slot to behave similarly to a regular slot when using "cursor slot" expressions.

code snippet:
Code:
on inventory click:
    if index of event-slot is player's chestplate: #Chestplate slot check
        event-item's name = "&bLight of the &6&lDivine"
        send "divine" to player
        set {_divine} to 1
    else if event-item is 1 of netherite chestplate: #Any other slot check (using this IF statement first causes it to read the chestplate slot, in part).
        event-item's name = "&bLight of the &6&lDivine"
        send "divine2" to player
        set {_divine} to 1

    if {_divine} = 1: #If the player clicks a chestplate with golden carrots, remove the carrots and change the chestplate's lore.
        if player is alive:
            set {_slot} to index of event-slot
            set {_carrots} to amount of cursor slot of player
            send "divine3" to player
            cursor slot of player is {_carrots} of golden carrot # PROBLEM HERE???
            cancel event
            set cursor slot of player to air
            send "%{_carrots}% carrots added" to player
            add ({_carrots} * 30) to {divine::%player%} #Each GOLDEN CARROT grants 30s of energy
            send "Charged %{divine::%player%}%" to player
#            give player 1 of {item::LightoftheDivine} #DEBUG, gives you an upgrade in return!
            set line 6 of lore of slot {_slot} of player to "&8Charge Time: &7%TimeInSeconds({divine::%player%})%"



Right now, golden carrots disappear and energy is added properly only if I drop the carrots onto the chestplate while it is in a regular slot. If the chestplate is in the armor slot, nothing happens. If I click the chestplate itself (without carrots) both will properly send the "divine /2 /3" messages, but nothing else happens with the equipped slot. I can change the lore of the chestplate if it is not in the chestplate-slot, or specifically affect the chestplate slot by replacing "slot {_slot} of player" with "player's chestplate". However I cannot make it respond the same way to both instances regardless where the player has the chestplate (equipped or just in their inventory). Am i missing something?

Using Skript and SkBee only, please do not suggest an Addon :emoji_slight_smile:
It looks like you're missing a statement to check the slot number (You need to specify an armor slot I think) for when the item is clicked. Also, make sure the {_divine} is being properly set after checking the slot.
 
It looks like you're missing a statement to check the slot number (You need to specify an armor slot I think) for when the item is clicked. Also, make sure the {_divine} is being properly set after checking the slot.
Thanks for the pointers, but can you be more specific? Where am I missing the armor slot check? I've been trying to make this work for a few days with different checks, and I've tried different means to get it to check the slots. It still registers my clicks (if I take the chestplate out of the slot and place it back in, it works) but it doesn't respond the same way as a chestplate anywhere else in my inventory.
 
It looks like you're missing a statement to check the slot number (You need to specify an armor slot I think) for when the item is clicked. Also, make sure the {_divine} is being properly set after checking the slot.
Still not solved. Not sure where to add the slot check, it works anywhere in my inventory except the chestplate slot.
 
not 100% sure this works but it might work


Code:
on inventory click:
    if clicked slot is player's chestplate: #Chestplate slot check
        if name of event-item is "&bLight of the &6&lDivine":
            send "divine" to player
            set {_divine} to 1
    else if event-item is 1 of netherite chestplate: #Any other slot check
        if name of event-item is "&bLight of the &6&lDivine":
            send "divine2" to player
            set {_divine} to 1

    if {_divine} is set:
        if player is alive:
            set {_slot} to index of event-slot
            set {_carrots} to number of carrot in the player's inventory
            if cursor slot of player is {_carrots} of golden carrot:
                send "divine3" to player
                cancel event
                set cursor slot of player to air
                send "%{_carrots}% carrots added" to player
                add ({_carrots} * 30) to {divine::%player%}
                send "Charged %{divine::%player%}%" to player
                set {_lore::*} to lore of slot {_slot} of player
                set {_lore::6} to "&8Charge Time: &7%TimeInSeconds({divine::%player%})%"
                set lore of slot {_slot} of player to {_lore::*}
 
not 100% sure this works but it might work


Code:
on inventory click:
    if clicked slot is player's chestplate: #Chestplate slot check
        if name of event-item is "&bLight of the &6&lDivine":
            send "divine" to player
            set {_divine} to 1
    else if event-item is 1 of netherite chestplate: #Any other slot check
        if name of event-item is "&bLight of the &6&lDivine":
            send "divine2" to player
            set {_divine} to 1

    if {_divine} is set:
        if player is alive:
            set {_slot} to index of event-slot
            set {_carrots} to number of carrot in the player's inventory
            if cursor slot of player is {_carrots} of golden carrot:
                send "divine3" to player
                cancel event
                set cursor slot of player to air
                send "%{_carrots}% carrots added" to player
                add ({_carrots} * 30) to {divine::%player%}
                send "Charged %{divine::%player%}%" to player
                set {_lore::*} to lore of slot {_slot} of player
                set {_lore::6} to "&8Charge Time: &7%TimeInSeconds({divine::%player%})%"
                set lore of slot {_slot} of player to {_lore::*}
Thanks for your help Meggy!
I like this method, but sadly it still fails to apply the carrots or the lore if the chestplate is in the chestplate slot (it does nothing). Works as expected if it is anywhere else in the inv though.
 
oh if it is in the chestplate slot that is different, when clicking on it somewhere else it "swaps" the item but the chestplate slot cannot do that with the carrot. I believe.
 
Ohhh ok that makes sense. Because carrots can't be placed in the chestplate slot so they can't be "swapped".
Thanks for your help!