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!

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

Skript Vanilla GUIs

Discussion in 'Tutorials' started by Runakai1, Mar 20, 2019.

  1. Runakai1

    Runakai1 Well-Known Member

    Joined:
    Apr 27, 2018
    Messages:
    324
    Likes Received:
    16
    Hello! I've recently had to send an example of how to use Vanilla Guis all the time because SkQuery Guis, if not handled correctly, were buggy. It still is better to use TuSKe or how I am going to show you Vanilla Skript Guis.

    What do you need?
    To open the inventory you need Skript 2.0.
    To actually use the on inventory click event you'll need 2.2

    You will not need any addons for this! You can implement Skellett in here by replacing "event-slot" with "clicked item" and "index of event-slot" with "clicked slot"

    Code (Skript):
    1.  
    2. on inventory click:
    3.     send "%event-item%" #0 air, 5 clay, 18 brown mushrooms named ""
    4.     send "%event-slot%" # inventory slot X of player
    5.     send "%event-inventory%" # inventory of player
    6.     send "%event-click type%" # left mouse button, middle mouse button,
    7.     send "%index of event-slot%" # 0-9
    8.     send "%name of event-inventory%" #coloured name
    9.  
    Those are pretty much all the expressions you will need.
    https://docs.skunity.com/syntax/search/on inventory click
    Event-Values:
    - event-world
    - event-player
    - event-itemstack (This one does not work, regardless of how else I write that, it's "event-item")
    - event-inventory action
    - event-inventory
    - event-slot
    - event-click type

    the "event" is optional. You can use %world%, %player%, etc.

    What do they return?

    event-world returns the name of the world the event-player currently is at.
    The event-player is the player who clicks in the inventory
    event-inventory action will return how much of an item stack you picked up or placed.
    ( pickup all (the itemstack), pickup 1, place half, etc.. )
    -event-inventory will return the inventory of the player
    -event-slot will actually return the item of the clicked slot. "Inventory slot X of player"
    -event-item will return the item stack. 0 air, 5 clay, 18 brown mushrooms named "test" etc...
    -event-click type will return the click type, left mouse button, middle mouse button, left mouse button with shift etc..
    - index of event-slot will actually return the clicked slot. "9" e.g

    What else could be practical:
    How do you check if the clicked slot contains an item?
    by simply doing:
    Code (Skript):
    1. event-slot != air:
    If the picture doesn't appear:
    https://imgur.com/a/8L5J0Xp
    [​IMG]

    How do you do all that in an actual script?
    Here's an example:

    Code (Skript):
    1.  
    2. command testgui:
    3.     trigger:
    4.         open chest inventory with 3 rows named "Test" to player
    5.         loop 27 times:
    6.             set slot (loop-number -1) of player' current inventory to stone named "This is a Stone" with lore "Stonelore" and "Stonelore2"
    7.  
    8. on inventory click:
    9.     event-inventory != player's inventory:
    10.         name of player' current inventory = "Test":
    11.             event-slot = stone:
    12.                 index of event-slot = 0:
    13.                     name of event-slot = "This is a Stone":
    14.                         event-click type = left mouse button:
    15.                             cancel event
    On 1.8 you will have to do
    Code (Skript):
    1.  
    2.         set {_item} to stone named "Hello"
    3.         set lore of {_item} to "Lore1||Lore2||Lore3"
    4.         set slot 0 of player's current inventory to {_item}
    since lores are a bit buggy. Or at least it does not work for everyone. The "||" will need SkQuery to create new lines of a lore.
    on 1.9+ you can simply do
    Code (Skript):
    1. set slot 0 of player's current inventory to stone named "Hello" with lore "Lore1", "Lore2", "Lore3"
     
    #1 Runakai1, Mar 20, 2019
    Last edited: Mar 21, 2019
  2. m

    Joined:
    Mar 21, 2019
    Messages:
    1
    Likes Received:
    0
    Have a try with Online Compiler app you can get your problem solved and also virtual assistance is also available
     
    #2 michaelmckinney, Mar 26, 2019
    Last edited: Mar 27, 2019
Loading...