Problem with list variables and “contains”

  • Thread starter Deleted member 6377
  • Start date
  • 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.
D

Deleted member 6377

Using newest version of Skript on MC 1.8.9.

No add-ons. Would like to keep it this way.


This is a very simple, broad version of my command:

code_language.skript:
else if arg 1 is “addrank”:
    if {listvariable::*} contains “%arg-2%”
         message “already rank”
    else:
         add arg 2 to {listvariable::*}
         message “%arg-2% added”
else if arg 1 is “removerank”:
    if {listvariable::*} contains “%arg-2%”:
         remove arg 2 from {listvariable::*}
         message “%arg-2% removed”
    else:
        message “%arg-2% is not a rank!”
else if arg 1 is “clearranks”:
    clear {listvariable::*}
    message “cleared”
else if arg 1 is “listranks”:
    If size of {listvariable::*} < 1:
        message “no ranks!”
    else:
        message “%{listvariable::*}%”

The problem is after I add the rank to {listvariable::*}, when I try to remove it, it says “examplerank1 is not a rank!”. When I use the list command, it clearly shows that it is a command. Also, after I used the remove command, when I add a rank which I already added before, it no longer stops me from doing so. I am pretty positive that the “contains” is the culprit to this problem. The “contains” seems to only be working for the addrank command. After entering the removecommand, it stops working.

If this problem is confusing to understand, I will put a YouTube link here tomorrow.
 
code_language.skript:
function contains(1:object,2:objects) :: boolean:
    loop {_2::*}:
        if loop-value is {_1}:
            return true
    return false
   
   
#Example:
command /test:
    trigger:
        if contains(arg-2,{listvariable::*}) is true:
            message "true"
 
Using newest version of Skript on MC 1.8.9.

No add-ons. Would like to keep it this way.


This is a very simple, broad version of my command:

code_language.skript:
else if arg 1 is “addrank”:
    if {listvariable::*} contains “%arg-2%”
         message “already rank”
    else:
         add arg 2 to {listvariable::*}
         message “%arg-2% added”
else if arg 1 is “removerank”:
    if {listvariable::*} contains “%arg-2%”:
         remove arg 2 from {listvariable::*}
         message “%arg-2% removed”
    else:
        message “%arg-2% is not a rank!”
else if arg 1 is “clearranks”:
    clear {listvariable::*}
    message “cleared”
else if arg 1 is “listranks”:
    If size of {listvariable::*} < 1:
        message “no ranks!”
    else:
        message “%{listvariable::*}%”

The problem is after I add the rank to {listvariable::*}, when I try to remove it, it says “examplerank1 is not a rank!”. When I use the list command, it clearly shows that it is a command. Also, after I used the remove command, when I add a rank which I already added before, it no longer stops me from doing so. I am pretty positive that the “contains” is the culprit to this problem. The “contains” seems to only be working for the addrank command. After entering the removecommand, it stops working.

If this problem is confusing to understand, I will put a YouTube link here tomorrow.

maybe try this if the others didnt work
code_language.skript:
if "%{listvariable::*}%" contains "%arg-2%":
 
When you say "newest version of Skript" do you mean Bensku's dev-36? Because the issue with "contains" checks not working is supposed to be fixed in the latest version.
 
When you say "newest version of Skript" do you mean Bensku's dev-36? Because the issue with "contains" checks not working is supposed to be fixed in the latest version.
Actually, I don’t know. I installed Skript from the official bukkit page 2 months ago. Probably isn’t the newest version anyway, xd.

Would you mind giving me the link to the fork? I’m too lazy to find it right now, sorry.
[doublepost=1531157754,1531157356][/doublepost]
When you say "newest version of Skript" do you mean Bensku's dev-36? Because the issue with "contains" checks not working is supposed to be fixed in the latest version.
Also, I might release this Skript later on SpigotMC, but do the players have to install this “Bensku Dev-36” for my code to work?
 
Yeah, they'll need the latest version to not get the same errors you are getting. But regardless most people in the Skript community use Bensku's fork, it's the de facto primary version of Skript nowadays. The latest versions can always be found here.
 
Status
Not open for further replies.