SkriptLang / Skript

Skript is a Spigot plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
https://docs.skriptlang.org
GNU General Public License v3.0
1.03k stars 362 forks source link

'If' statements additions #6605

Open MissingReports opened 3 months ago

MissingReports commented 3 months ago

Suggestion

When making 'or' or 'and' conditions in Skript you do something like this

if all:
    true is true
    false is true
then:

This is great and all until you need an 'or' and an 'and' in one condition, this forces you to make a pyramid of doom or do something similar to this

if any:
    true is false
    true is true:
then:
    set {_execute} to true

if all:
    {_execute} is true
    # other condition
then:

I understand that Skript cannot use 'and' and 'or' for that because lists already use that syntax

set {_list::*} to "hello" or "blah" <-- random choice

if "bob" is "hello" or "bob" <-- supports 'or' because that condition takes a list as input not a single expression

if true is true or true is false <-- you cannot do that

However, Skript doesn't use | or & so that can be used to identify and / or conditions. Example:

if true is false | true is true <-- or statement

if true is true & true is false <-- and statement

And it would be nice if you could directly do "if true:"

function isTrue() :: boolean:
    return true

if isTrue() <-- won't work

if isTrue() is true <-- will work

This is a thing in almost all programming languages because it makes sense, a condition is true or false and false means not to continue execution and true is the opposite

Why?

It will really clean up some code in specific scenarios where you want multiple and / or in conditions

The 'true' thing would just be nice to have since it's really not fun to switch from something like Java to Skript and always forgetting "is true"

Other

No response

Agreement

sovdeeth commented 3 months ago

I'm strongly against adding multiple conditions in one line. However, as a substitute, perhaps the following?

if any:
 a
 b
or/and if all:
 b
 c
then:
 d
sovdeeth commented 3 months ago

As far as the not needing is true thing, duplicate of #2207

MissingReports commented 3 months ago

I'm strongly against adding multiple conditions in one line. However, as a substitute, perhaps the following?

if any:
 a
 b
or if all:
 b
 c
then:
 d

That would work as well but I really don't see why multiple conditions in one line is bad

sovdeeth commented 3 months ago

I'm strongly against adding multiple conditions in one line. However, as a substitute, perhaps the following?

if any:
 a
 b
or if all:
 b
 c
then:
 d

That would work as well but I really don't see why multiple conditions in one line is bad

It's very difficult for the parser to parse (very long reload times)

MissingReports commented 3 months ago

As far as the not needing is true thing, duplicate of #2207

image

sovdeeth commented 3 months ago

As far as the not needing is true thing, duplicate of #2207

image

yes? what do you mean by this?

MissingReports commented 3 months ago

Oh, I thought u said it already exists.

sovdeeth commented 3 months ago

Oh, I thought u said it already exists.

nah, just that there's already an issue requesting it.

Moderocky commented 3 months ago

I'm strongly against adding multiple conditions in one line. However, as a substitute, perhaps the following?

if any:
 a
 b
or/and if all:
 b
 c
then:
 d

I think the mid-way split looks messy and I don't like it. Maybe we could see if there's a nicer way to support this within check/switch.