Skip to content

Instantly share code, notes, and snippets.

@Blueyescat
Last active October 25, 2021 00:06
Show Gist options
  • Save Blueyescat/74f479569486032a55b29de90afd6172 to your computer and use it in GitHub Desktop.
Save Blueyescat/74f479569486032a55b29de90afd6172 to your computer and use it in GitHub Desktop.
A script that registers AND/OR statements and Check expression to Skript.

⬇️ The script is at below ⬇️

This script registers AND/OR statements and Check expression to Skript using skript-mirror.

Doesn't mean to work exactly, but looks like it works. You will need to use brackets at many cases.

Thanks Pikachu for help on usage of the parse section.

Examples

if (1 is 1 AND 2 is 2 AND 3 is 3) OR 5 is 3:

send "%check (2 is 5 OR 5 is 5)%"

if !check (1 is 1):

check if {warnings::%player's uuid%} is greater than 4 AND player is not op:
  ban the player

Syntaxes

AND Expression (Returns boolean)

Separator: AND - && - &

<Condition> <Separator> <Condition>
%boolean% <Separator> <Condition>
<Condition> <Separator> %boolean%
%boolean% <Separator> %boolean%

OR Expression (Returns boolean)

Separator: OR - || - |

<Condition> <Separator> <Condition>
%boolean% <Separator> <Condition>
<Condition> <Separator> %boolean%
%boolean% <Separator> %boolean%

Check Expression (Returns boolean)

check [if] (<condition>)

Not Boolean Expression (Returns boolean)

If you enter true, it returns false.

(!|not )%boolean%

Check Condition

%boolean%
[(check [if]|[the] condition)] %boolean%
[(check [if]|[the] condition)] %boolean% [[if it] (is positive|is negative)
[(check [if]|[the] condition)] %boolean% [[if it] (is(n't| not) positive|is(n't| not) negative)
[(check [if]|[the] condition)] %boolean% [[if it] ((is positive|is(n't| not) negative)|1¦(is negative|is(n't| not) positive))]
import:
ch.njol.skript.lang.Condition
local expression parsed condition %strings%:
get:
return Condition.parse((first element of expression-1) and "Can't understand this condition: %first element of expression-1%")
expression (1¦%-boolean%|2¦<(.+)>)< (?:AND|&&?) >(3¦%-boolean%|4¦<(.+)>):
return type: boolean
parse:
if parse mark is 6:
set {_condition1} to parsed condition regex-1
set {_condition2} to parsed condition regex-3
if {_condition1} and {_condition2} are set:
continue
else if parse mark is 5:
set {_condition2} to parsed condition regex-2
if {_condition2} are set:
continue
else if parse mark is 1:
set {_condition1} to parsed condition regex-1
if {_condition1} is set:
continue
get:
if parse mark is 6:
if {_condition1}.check(event) and {_condition2}.check(event) are true:
return true
else if parse mark is 5:
if expression-1 and {_condition2}.check(event) are true:
return true
else if parse mark is 1:
if {_condition1}.check(event) and expression-2 are true:
return true
else if parse mark is 2:
if expression-1 and expression-2 are true:
return true
return false
expression (1¦%-boolean%|2¦<(.+)>)< (?:OR|\|\|?) >(3¦%-boolean%|4¦<(.+)>):
return type: boolean
parse:
if parse mark is 6:
set {_condition1} to Condition.parse((first element of regex-1) and "Can't understand this condition: %regex-1%")
set {_condition2} to Condition.parse((first element of regex-3) and "Can't understand this condition: %regex-3%")
if {_condition1} and {_condition2} are set:
continue
else if parse mark is 5:
set {_condition2} to Condition.parse((first element of regex-2) and "Can't understand this condition: %regex-2%")
if {_condition2} are set:
continue
else if parse mark is 1:
set {_condition1} to Condition.parse((first element of regex-1) and "Can't understand this condition: %regex-1%")
if {_condition1} is set:
continue
get:
if parse mark is 6:
if {_condition1}.check(event) is true:
return true
if {_condition2}.check(event) is true:
return true
else if parse mark is 5:
if expression-1 is true:
return true
if {_condition2}.check(event) is true:
return true
else if parse mark is 1:
if {_condition1}.check(event) is true:
return true
if expression-2 is true:
return true
else if parse mark is 2:
if expression-1 is true:
return true
if expression-2 is true:
return true
return false
expression (!|not )%boolean%:
return type: boolean
get:
if expression-1 is true:
return false
return true
condition [(check [if]|[the] condition)] %boolean% [[if it] ((is positive|is(n't| not) negative)|1¦(is negative|is(n't| not) positive))]:
check:
if parse mark is 1:
negate the condition
if expression-1 is true:
continue
expression check [if] \(<(.+)>\):
return type: boolean
parse:
set {_condition} to parsed condition regex-1
if {_condition} is set:
continue
get:
if {_condition}.check(event) is true:
return true
return false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment