Example:
Requires:
- SkStuff
- SkQuery
Code:
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 "%{_}%"