Need help with loop through list

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

LMKgaming

Member
Mar 13, 2025
21
1
3
I have these code
code_language.skript:
on load:

    set {autoCraftBlocks::*} to "packed_ice", "blue_glazed_terracotta", "deepslate_lapis_ore", "lapis_ore" and "deepslate_diamond_ore"

    set {listRank::*} to "default", "elite-soldier", "general", "senior-general", "captain", "elite-captain" and "sergeant"

    delete {autoCrafting::*}

command /cleartct:

    trigger:

        delete {autoCrafting::*}

command /tctinfo [<text>]:

    trigger:

        set {_playerRank} to the value of the placeholder "luckperms_primary_group_name" for the player

        send "Here: %{autoCrafting::emoji_stuck_out_tongue:acked_ice::elite-soldier::*}%"

        if arg-1 is not set:

            loop {autoCrafting::*}:

                send "%loop-index-1% %loop-value-1%" to player

                loop {autoCrafting::%{loop-value-1}%::*}:

                    send "%loop-index-2% %loop-value-2%" to player

                    loop {autoCrafting::%{loop-value-1}%::%{loop-value-2}%::*}:

                        send "rank: %loop-value-2%, block: %loop-value-1%, id: %loop-value-3%" to player

        else:

            if size of {autoCrafting::%{arg-1}%::*} is 0:

                send "empty" to player

            else:

                loop {autoCrafting::%{arg-1}%::*}:

                    send "%arg-1%: %loop-value%" to player

command /tuchetao [<text>]:

    trigger:

        loop {autoCraftBlocks::*}:

            loop {listRank::*}:

                set {autoCrafting::%loop-value-1%} to loop-value-1

                set {autoCrafting::%loop-value-1%::%loop-value-2%} to loop-value-2

        set {_playerRank} to the value of the placeholder "luckperms_primary_group_name" for the player

        if {listRank::*} contains {_playerRank}:

            send "%{_playerRank}%" to player

        if arg-1 is not set:

            loop {autoCraftBlocks::*}:

                if {autoCrafting::%{loop-value}%::%{_playerRank}%::*} contains player's uuid:

                    send "remove %player%" to player

                    remove player's uuid from {autoCrafting::%{loop-value}%::%{_playerRank}%::*}

                else:

                    send "add %player%" to player

                    add player's uuid to {autoCrafting::%{loop-value}%::%{_playerRank}%::*}

        else if {autoCraftBlocks::*} contains arg-1:

            if {autoCrafting::%{arg-1}%::%{_playerRank}%::*} contains player's uuid:

                remove player's uuid from {autoCrafting::%{arg-1}%::%{_playerRank}%::*}

            else:

                add player's uuid to {autoCrafting::%{arg-1}%::%{_playerRank}%::*}
After i type /tuchetao and /tctinfo it should log me for a list user id in each rank and each block can autocrafting but it not log anything
I use
skript-2.10.1, skBee-3.9.1, skript-placeholder-1.7.0, skRayFall-1.9.28
 
Last edited:
Hey, can you paste the code in the code format, becuase its impossible to find something in this code.
 
I cant really understand what are you trying to do here. Can you like explain to me in details what is not working and how should it work?
 
I cant really understand what are you trying to do here. Can you like explain to me in details what is not working and how should it work?
OK
IDEA: I want to make a command /tuchetao to auto compress the item in player's inventory. I also set the cooldown for each rank when use this command.
WHAT I MADE: I have command /tuchetao which when player use it, i store the player's uuid in list which structure as autoCrafting::<block>::<rank>::*
PROBLEM: I make command /tctlist to show if i added successfully by loop into autoCrafting list, but it only run and show in chat command send "%loop-index-1% %loop-value-1%" to player without run the second and third loop inside it.
 
What do you mean by compress the item in player's inventory? I see you that you made a lot of loops for no reason, like you are looping a list that doesnt even exist in your code before - thats why it doesnt send the second and third loop.
Your code has a lot of mistakes so I can either help you personally if you add me on discord: danrub (I would choose the discord because of the communication, but its up to you)
or you can explain me here in deatils what you mean by compressing, etc.. Because the code is needs to be fully changed
 
What do you mean by compress the item in player's inventory? I see you that you made a lot of loops for no reason, like you are looping a list that doesnt even exist in your code before - thats why it doesnt send the second and third loop.
Your code has a lot of mistakes so I can either help you personally if you add me on discord: danrub
or you can explain me here in deatils what you mean by compressing, etc.. Because the code is needs to be fully changed
I see.
For example with packed_ice, i want:
- When player use command /tuchetao, the below description will work:
+ When player have 64 packed_ice, remove it and give player 1 compress_packed_ice (custom item make by item edit)
+ When player have 64 compress_packed_ice, remove it and give player 1 compress_packed_ice(tier 2)
+ So on with tier 3 (last tier)
- For each rank, time to make compression above are is different
 
Hm, okay get it now, since i dont know the times for your ranks im unable to do it, but there is a code I made in a rush so you can see an inspiration of how you can do it. Basically this is only for the Packed Ice you can go on and add all of these blocks. Also I assumed that Packed Ice, Compressed Packed Ice and Compressed Packed Ice (tier 2) will be one block with different names - I just made a while loop that is going through the inventory of player and checking for the certain items, if player doesnt have the item it stops.
ITS NOT TESTED
Code:
command /tuchetao [<text>]:
    trigger:
        loop {autoCraftBlocks::*}:
            set {autocraftingblocks::%uuid of player%} to true
            while {autocraftingblocks::%uuid of player%} = true:
                set {_item::%uuid of loop-player%} to loop-value parsed as item
                if player has 64 of {_item::%uuid of loop-player%} named "Packed Ice":
                    remove 64 of {_item::%uuid of loop-player%} named "Packed Ice" from player
                    give 1 of {_item::%uuid of loop-player%} named "Compressed Packed Ice" to player
                if player has 64 of {_item::%uuid of loop-player%} named "Compressed Packed Ice":
                    remove 64 of {_item::%uuid of loop-player%} named "Compressed Packed Ice" from player
                    give 1 of {_item::%uuid of loop-player%} named "Compressed Packed Ice (Tier 2)" to player
                if player has 64 of {_item::%uuid of loop-player%} named "Compressed Packed Ice (Tier 2)":
                    remove 64 of {_item::%uuid of loop-player%} named "Compressed Packed Ice (Tier 2)" from player
                    give 1 of {_item::%uuid of loop-player%} named "Compressed Packed Ice (Tier 3)" to player
                else:
                    delete {autocraftingblocks::%uuid of player%}
        delete {autocraftingblocks::%uuid of player%}