Multiple "or"s

  • 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

Skript Version (do not put latest): Skript 2.2 (dev36)
Skript Author: Bensku
Minecraft Version: 1.12.2

So I was making a gamemode switch skript, which looked very similar to this, except there were arguments for a language other from English as well.

Full Code:
code_language.skript:
command /gamemode <gamemode>:
    trigger:
        if arg 1 is "survival" or arg 1 is "s" or arg 1 is "0":
            set player's gamemode to survival
            message "Your gamemode has been set to survival." to player
        else if arg 2 is "creative" or arg 1 is "c" or arg 1 is "1":
            set player's gamemode to creative

Errors on Reload:
I am currently not at home or somewhere where I can access the server and see the exact error, but it was about it not understanding the "or" expression. After further reading it turns out, that Skript doesn't support multiple arguments for "or".

Addons using (including versions):
Skellett 1.9.6B

Troubleshooting:
I tried placing the "or" statements into brackets, like below, but they did not work:
if ( ( ( arg 1 is "survival" ) or ( arg 1 is "s" ) ) or ( arg 1 is "0" ) )

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? See: Troubleshooting

So, is there a solution to this, or do I have to use something like this?

code_language.skript:
if arg 1 is "creative" or arg 1 is "c":
    set player's gamemode to creative
else if arg 1 is "1":
    set player's gamemode to creative

It would be nice if this could be avoided.

Any help would be apprichiated :emoji_slight_smile:
 
What you should do is not use 'or arg 1 is' every time you test for an argument

code_language.skript:
if arg 1 is "creative" or "c" or "1":
    set player's gamemode to creative

Full code:
code_language.skript:
command /gamemode <gamemode>:
    trigger:
        if arg 1 is "survival" or "s" or "0":
            set player's gamemode to survival
            message "Your gamemode has been set to survival." to player
        else if arg 2 is "creative" or "c" or "1":
            set player's gamemode to creative
 
if ( ( ( arg 1 is "survival" ) or ( arg 1 is "s" ) ) or ( arg 1 is "0" ) )
+one new programmer :emoji_grinning::emoji_joy::emoji_joy:
JavaScript:
if ((arg-1 == "survival") || (arg-1 == "s") || (arg-1 == "0")) {}
 
What you should do is not use 'or arg 1 is' every time you test for an argument

code_language.skript:
if arg 1 is "creative" or "c" or "1":
    set player's gamemode to creative

Full code:
code_language.skript:
command /gamemode <gamemode>:
    trigger:
        if arg 1 is "survival" or "s" or "0":
            set player's gamemode to survival
            message "Your gamemode has been set to survival." to player
        else if arg 2 is "creative" or "c" or "1":
            set player's gamemode to creative
Doesn't work that way either.
 
@Efnilite its maybe not working because you need it like this ""string1", "string2", "string3" or "string4"" not ""string1" or "string2" or "string3" or "string4"".. so try this:
code_language.skript:
command /gamemode <gamemode>:
    trigger:
        if arg 1 is "survival", "s" or "0":
            set player's gamemode to survival
            message "Your gamemode has been set to survival." to player
        else if arg 2 is "creative", "c" or "1":
            set player's gamemode to creative
But it maybe should work with only "or"s.. but try
 
@Efnilite its maybe not working because you need it like this ""string1", "string2", "string3" or "string4"" not ""string1" or "string2" or "string3" or "string4"".. so try this:
code_language.skript:
command /gamemode <gamemode>:
    trigger:
        if arg 1 is "survival", "s" or "0":
            set player's gamemode to survival
            message "Your gamemode has been set to survival." to player
        else if arg 2 is "creative", "c" or "1":
            set player's gamemode to creative
But it maybe should work with only "or"s.. but try
It works only with "or"s. I tested it and it worked
 
@Efnilite its maybe not working because you need it like this ""string1", "string2", "string3" or "string4"" not ""string1" or "string2" or "string3" or "string4"".. so try this:
code_language.skript:
command /gamemode <gamemode>:
    trigger:
        if arg 1 is "survival", "s" or "0":
            set player's gamemode to survival
            message "Your gamemode has been set to survival." to player
        else if arg 2 is "creative", "c" or "1":
            set player's gamemode to creative
But it maybe should work with only "or"s.. but try
Thanks, that works!
 
Status
Not open for further replies.