Assign command to item in loop

  • 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 community!

    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.

CosmicCakeMC

New Member
Apr 30, 2017
6
0
0
Skript Version: Skript 2.4.1
Skript Author: Bensku
Minecraft Version: 1.9

Code:
command /testmenu:
    trigger:
        wait 2 ticks
        open chest with 3 rows named "Test" to player
        wait 1 tick
        loop {testmenuid} times:
            if {testmenuactive.%loop-number%} is true:
                add 1 to {testmenuidloop.%player%}
                set {testmenucommand.%loop-number%} to loop-number
                wait 1 tick
                format slot {testmenuidloop.%player%} of player with {testmenuitem.%loop-number%} to close then run [execute player command "testcommand %{testmenucommand.%loop-number%}%"]
        set {testmenuidloop.%player%} to -1

This command basically opens a menu and then checks all the {testmenuactive.%number%} inputs to see if the specific item is active, if it is, it will format the next available slot (according to {testmenuidloop}) with that numbers item. It all works fine, but when setting the command that the item is supposed to run when clicked, it sets the %loop-number% variable to the last loop-number inputted, instead of setting it to the loop-number that was active when the slot was formatted.
 
Status
Not open for further replies.