Solved list variables

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

loadka95

Active Member
Feb 24, 2017
78
6
8
The problem is: when the list variable {itdisabled::*} is empty and I add an item to it, its just works fine
but if I add more item into it, it doesn't work anymore it's just adding the item to the variable over and over, and not checking if its in the variable


code_language.skript:
command /it [<text>] [<item>]:
    trigger:
        if arg 1 is "add":
            if arg 2 is not set:
                message "{@it}/it help"
            else:
                if {itdisabled::*} contains arg 2:
                    message "&a%arg 2% &7already disabled."
                else:
                    add arg 2 to {itdisabled::*}
                    message "&a%arg 2% &7disabled."
 
The contains never worked well with the list variables you have to loop through the variable and then check if the loop-value is equal to the second argument.
 
The contains never worked well with the list variables you have to loop through the variable and then check if the loop-value is equal to the second argument.

but how can i add my item into the variable if its not in there already, with this method? (i dont use loops too often)
code_language.skript:
              loop {itdisabled::*}:
                    if loop-value is arg 2:
                        message "&a%arg 2% &7already disabled."
                    else:
                        add arg 2 to {itdisabled::*}     #this not works perfectly
 
You'll have to do it like:
code_language.skript:
loop {itdisabled::*}:
    if loop-value is arg-2:
        send "%arg-2% is already diasabled."
        set {_check} to true
        exit loop
{_check} isn't set
add arg-2 to {itdisabled::*}
But as you can see, the code does't seems that efficient and that's why I would do:
code_language.skript:
[command /it [<text>] [<item>]:
    trigger:
        if arg 1 is "add":
            if arg 2 is not set:
                message "{@it}/it help"
            else:
                if {itdisabled::%arg-2%} is set:
                    message "&a%arg 2% &7already disabled."
              else:
                    set {itdisabled::%arg-2%} to true
                    message "&a%arg-2% &7disabled."
 
Last edited by a moderator:
  • Like
Reactions: loadka95
Status
Not open for further replies.