Function on clicked 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!

Status
Not open for further replies.

lolplomer

New Member
Oct 18, 2019
5
0
1
30
How do i make that function remember the clicked item/slot?

Code:
command /shop-halloween-299 <text>:
    trigger:
        if arg 1 is "enchanter":
            open virtual chest inventory with size 5 named "&aHey" to player

on inventory click:
    if name of player's current inventory is "&aHey":
        cancel event
        if clicked item is not enchanted book:
            format gui slot 22 of player with clicked item
            if clicked item is bow:
                format gui slot 17 of player with enchanted book named "&eExplosive I" to run function enchant(Explosive I)"

function enchant(type: String):
    if {_type} is "Explosive I":
        return clicked item
        add lore of clicked item to "&eExplosive I"

I also dont know what return used for
[doublepost=1574085398,1573970700][/doublepost]bump
 
you can return objects with "return", so like
function divideBy(var: number, divider: number) :: number:
set {_var} to {_var}/{_divider}
return {_var}

then you use it like this:
set {_var} to 10
set {_var} to divideBy({_var}, 10)
#{_var} will be 1 here

to be able to return in a function, you must add ":: <type>:" to end of it, also function cannot continue after it has returned something, so do not add any code after a return
 
Status
Not open for further replies.