Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge conditions and expressions #3838

Conversation

TPGamesNL
Copy link
Member

Description

This PR makes all conditions boolean expressions, and all boolean expressions can be used as conditions (mostly).

Examples
set {_a} to true
if {_a}: # passes

Boolean operations:

set {_a} to true
set {_b} to true
if {_a} and {_b}: # passes
set {_a} to true
set {_b} to false
if {_a} and {_b}: # fails
set {_a} to true
set {_b} to false
if {_a} or {_b}: # passes

if player can fly and player is alive:

But:

set {_a} to 1
# set {_b} to 1
if {_a} is set and {_b} is not set: 

does not pass, because it is parsed as if (({_a} is set) and {_b}) is not set, where ({_a} is set) and {_b} is a boolean 'and' operation with the condition and the variable. If you use parentheses, if ({_a} is set) and ({_b} is not set):

Also
set {_a} to {_b} is set
set {_x} to player is online

Only limitation is that inline conditions can't be expressions, for example:

set {_b} to false
{_b} # would exit the current section

doesn't parse, but I'm not even sure if having that would be beneficial.


Target Minecraft Versions: any
Requirements: none
Related Issues: #2207

@TPGamesNL TPGamesNL added 2.6 feature Pull request adding a new feature. labels Mar 20, 2021
@Mwexim
Copy link
Contributor

Mwexim commented Apr 1, 2021

Lovely changes! Something that had to be done, possibly way earlier.

I’ll give you this link. It is a PR of mine where I fix the parsing issue that still remains (the fact that boolean operators and list literals clash with each other).

Do what you want with it, I’ll leave it here for convenience.

Also, you might want to look at how skript-parser handles conditional expressions. They aren’t allowed in normal syntaxes, unless the type has a ‘=‘ prefix.
For example:

  • ‘=boolean’ will allow boolean expressions and conditional expressions
  • ‘boolean’ will only allow boolean expressions

This might be a more clean approach. Conditional expressions can then be called by using something like ‘check if {var} is set’, for example.

@AyhamAl-Ali AyhamAl-Ali mentioned this pull request Apr 24, 2021
@TPGamesNL TPGamesNL marked this pull request as draft June 10, 2021 06:26
@TPGamesNL TPGamesNL mentioned this pull request Jun 10, 2021
@Nicofisi
Copy link
Member

Hey! What's the status of this?

@TPGamesNL
Copy link
Member Author

@Nicofisi There's no progress on this, I've been busy with other stuff and this has lost my attention. I'm also still unsure over the design, for example if all %boolean% (or %object%) should allow conditions by default (and without extra syntax) and if all conditions should be expressions by default. But that is for if I ever pick this up again.

@TheLimeGlass TheLimeGlass added the 2.8 Targeting a 2.8.X version release label Jan 3, 2023
@Moderocky Moderocky force-pushed the master branch 2 times, most recently from bd134d0 to 3f08853 Compare September 16, 2023 16:59
@sovdeeth sovdeeth removed the 2.8 Targeting a 2.8.X version release label Dec 30, 2023
@APickledWalrus
Copy link
Member

Closing in favor of #6748

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Pull request adding a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants