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.

loop-number problem in inventory item command variable

Discussion in 'Skript' started by RiCkYB_667, Mar 26, 2018.

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

    RiCkYB_667 New Member

    Joined:
    Feb 11, 2018
    Messages:
    5
    Likes Received:
    0
    Hi!

    I have an issue which i am not seem to be able to resolve by myself.

    I am filling a virtual inventory using a loop to create a slot selection GUI.
    The loop-value fills the slot name just fine, but the linked command to all slots always ends up using the latest loop-value (in my case 20) no matter which slot i click.

    Code (Skript):
    1.   loop 20 times:
    2.     format slot loop-value - 1 of player with white stained glass pane named "%loop-value%. location" to close then run [make player execute command "{@somecommand} %loop-value%"]
    3.  
    Do you know a way to fix every command linked to the slots on every loop, so when i click slot 3 it uses the loop-value "3" in the command instead of number "20"?

    If the problem description wasn't clear enough, please let me know!

    Thank you for your kind help!
     
  2. AsuDev

    VIP

    Joined:
    Jan 27, 2017
    Messages:
    243
    Likes Received:
    21
    Skquery gui formatting sucks. You should consider using TuSKe or normal SK for that. I have experimented with this before and it never updates the command. It keeps the same one for all of them.

    I have never used TuSKe before so I am going to show you can example of how you can do it with normal SK and Skellet.

    Code (Skript):
    1.  
    2. command /chest:
    3.     trigger:
    4.         open chest with 3 rows named "test" to the player
    5.         loop 20 times:
    6.             set slot loop-value - 1 of player's current inventory to 1 of white stained glass pane named "%loop-value%. location"
    7.  
    8. on inventory click:
    9.     set {_i} to clicked slot
    10.     if clicked inventory is player's current inventory:
    11.         name of player's current inventory is "test"
    12.         cancel event
    13.         make player execute command "checkval %{_i}+1%" #made it +1 because in the formatting you put -1...
    14.         close player's inventory
    15.  
    16. command /checkval <integer>:
    17.     trigger:
    18.         message "%arg 1%"
    19.  
    If anyone has an example of a TuSKe gui doing this, feel free to send an example.
     
    #2 AsuDev, Mar 27, 2018
    Last edited: Mar 27, 2018
    • Agree Agree x 1
  3. RiCkYB_667

    RiCkYB_667 New Member

    Joined:
    Feb 11, 2018
    Messages:
    5
    Likes Received:
    0
    Great idea, thank you very much! I will give it a try today and will post my solution if i manage to find it out. I might try to go for a function...
     
Thread Status:
Not open for further replies.

Share This Page

Loading...