1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Function on clicked slot

Discussion in 'Skript' started by lolplomer, Nov 17, 2019.

Thread Status:
Not open for further replies.
  1. lolplomer

    lolplomer New Member

    Joined:
    Oct 18, 2019
    Messages:
    5
    Likes Received:
    0
    How do i make that function remember the clicked item/slot?

    Code (Text):
    1. command /shop-halloween-299 <text>:
    2.     trigger:
    3.         if arg 1 is "enchanter":
    4.             open virtual chest inventory with size 5 named "&aHey" to player
    5.  
    6. on inventory click:
    7.     if name of player's current inventory is "&aHey":
    8.         cancel event
    9.         if clicked item is not enchanted book:
    10.             format gui slot 22 of player with clicked item
    11.             if clicked item is bow:
    12.                 format gui slot 17 of player with enchanted book named "&eExplosive I" to run function enchant(Explosive I)"
    13.  
    14. function enchant(type: String):
    15.     if {_type} is "Explosive I":
    16.         return clicked item
    17.         add lore of clicked item to "&eExplosive I"
    I also dont know what return used for
    --- Double Post Merged, Nov 18, 2019, Original Post Date: Nov 17, 2019 ---
    bump
     
  2. Govindas

    Govindas Active Member

    Joined:
    Feb 5, 2017
    Messages:
    79
    Likes Received:
    5
    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
     
Thread Status:
Not open for further replies.

Share This Page

Loading...