Comments (2)
Update: figured out a bit more about this
there are issues with logical operators and conditional statements that are kinda probably related to each other
about logical operators:
this code:
asat(@e) {
if('block ~ ~ ~ air' && 'block ~ ~-1~ air' || 'block ^ ^ ^ air' && 'block ^ ^ ^1 air') {
/say huh??
}
}
compiles as
execute as @e at @s if block ~ ~ ~ air if block ~ ~-1~ air if block ^ ^ ^1 air run say huh??
execute as @e at @s if block ^ ^ ^ air run say huh??
when it actually should be
execute as @e at @s if block ~ ~ ~ air if block ~ ~-1~ air run say huh??
execute as @e at @s if block ^ ^ ^ air if block ^ ^ ^1 air run say huh??
from this you can see, that it sorts the operators (cond1 && cond2 || cond3 && cond4
) by their priority (cond1 && cond2 && cond4 || cond3
) when it actually should take the &&
(and
) conditions in one execute
command and ||
(or
) in multiple without sorting them
a possible solution for this would be to not sort the conditions, but apply multiple "passes", so that one pass handles &&
s, then the next one ||
s etc.
now about conditional operators (if/else):
this code:
asat(@e) {
if('block ~ ~ ~ air' && 'block ~ ~-1 ~ air) {
/say cond1
} else {
/say cond2
}
}
compiles as
execute as @e at @s if block ~ ~ ~ air if block ~ ~-1 ~ air run say cond1
execute as @e at @s unless block ~ ~ ~ air unless block ~ ~-1 ~ air run say cond2
when it actually should be
execute as @e at @s if block ~ ~ ~ air if block ~ ~-1 ~ air run say cond1
execute as @e at @s unless block ~ ~ ~ air run say cond2
execute as @e at @s unless block ~ ~-1 ~ air run say cond2
from this you can see, that the else
statement only inverts the conditions, when it also should revert the logical operators, so cond1 && cond2
becomes !cond1 && !cond2
but it actually should become !cond1 || !cond2
hope this update helps you to fix these!
from mcscript.
Thanks for posting this. I often noticed that the boolean parsing is not quite right. And actually made a way better implementation of it in objd. But in fact mcscript was never supposed to do this that way. It should give a slight syntax variation of the minecraft commands and in the process it also inherited the problems with if and unless.
I understand that one might expect this behaving differently, but I honestly have not the time and motivation to rewrite anything to fix this big issue.
from mcscript.
Related Issues (20)
- Support for cross-dimensions HOT 1
- And Argument for pack_format
- All files generate with 2 whitespace characters on the end HOT 1
- A boolean if/else statement doesn't include "entity" in the execute command HOT 1
- MCscript is dangerous?! HOT 2
- Add the extension to open-vsx.org
- Add schedule code blocks HOT 1
- Add some kind of random number generator HOT 2
- Byte order mark causes compilation error HOT 2
- `#file` creates erroneous files in root data pack folder HOT 1
- Cannot put comments inside blocks
- Cannot run modals inside if statements
- Can't do anything (asat error)
- Cannot declare bool without setting it
- Issue with watch and booleans in if HOT 1
- Not Updated With New Commands
- Test
- Syntax Hilighter Non-full working in VSC
- a way of getting the target of parent entity from the child entity
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mcscript.