loop-number problem in inventory item command variable

  • 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.

RiCkYB_667

New Member
Feb 11, 2018
5
0
1
40
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_language.skript:
  loop 20 times:
    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%"]

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!
 
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_language.skript:
command /chest:
    trigger:
        open chest with 3 rows named "test" to the player
        loop 20 times:
            set slot loop-value - 1 of player's current inventory to 1 of white stained glass pane named "%loop-value%. location"

on inventory click:
    set {_i} to clicked slot
    if clicked inventory is player's current inventory:
        name of player's current inventory is "test"
        cancel event
        make player execute command "checkval %{_i}+1%" #made it +1 because in the formatting you put -1...
        close player's inventory
 
command /checkval <integer>:
    trigger:
        message "%arg 1%"

If anyone has an example of a TuSKe gui doing this, feel free to send an example.
 
Last edited:
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...
 
Status
Not open for further replies.