Format Slot - NBT Edition (SkStuff)

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

Duetro

Active Member
Jan 26, 2017
138
51
28
22
Example:
2017-05-26_14-13-56.gif


code_language.skript:
command /xxxx:
    trigger:
        open chest with 3 rows named "test" to player
        formatSlot(player's current inventory, 10, 1, (diamond named "&b&lDIAMOND"), "broadcast ""Skript is awesome!""")


Requires:
- SkStuff
- SkQuery


Code:
code_language.skript:
function formatSlot(inv: inventory, slot: integer, amount: integer, item: item, action: text = ""):
    if {cfs.p} isn't set:
        set {cfs.p} to random 4 char string from `a-zA-Z0-9`

    set slot {_slot} of {_inv} to {_amount} of {_item}
    if {_action} isn't "":
        replace all """" in {_action} with "|q?%{-cfs.p}%|"
        replace all "," in {_action} with "|c?%{-cfs.p}%|"
        replace all "%%" in {_action} with "|p?%{-cfs.p}%|"
        
        add "{SkriptClickEvent:%{_action}%}" to nbt of slot {_slot} of {_inv}

on drop:
    "%nbt of event-item%" contains "SkriptClickEvent"
    cancel event
on inventory click:
    set {_} to tag "SkriptClickEvent" of (nbt of slot clicked slot of player's current inventory)
    {_} is set
    cancel event
    replace all "|q?%{-cfs.p}%|" in {_} with """"
    replace all "|c?%{-cfs.p}%|" in {_} with ","
    replace all "|p?%{-cfs.p}%|" in {_} with "%%"
    evaluate "%{_}%"