/script run & invoke returns incorrect "success count"
sodiboo opened this issue ยท 1 comments
Description
The /script run
and /script invoke
commands will always return 1, even if that script snippet shows a syntax error when ran by a player
Here's a video showing this issue
Steps to reproduce and expected/actual result
- /script run print(1+1
- shows an error indicating the command was not successful
- /script run run('script run print(1+1')
- runs the command above (which doesn't compile) from a scarpet script
- does not print anything (because it never ran)
- does not give any indication of any kind of error to the script
Expected result: 0, to indicate the command was unsuccessful (success rate 0)
Actual result: 1, which usually means the command was successful (success rate 1)
Code Analysis
It seems the /script run
command will always return 1 no matter what,
fabric-carpet/src/main/java/carpet/commands/ScriptCommand.java
Lines 437 to 446 in 13f0b23
i suggest to make the handleCall function return a bool as to whether the expression actually ran
fabric-carpet/src/main/java/carpet/commands/ScriptCommand.java
Lines 380 to 385 in 13f0b23
or if there was a CarpetExpressionException
it would return false
fabric-carpet/src/main/java/carpet/commands/ScriptCommand.java
Lines 399 to 404 in 13f0b23
and then change the /script run
command to return that bool, as an int (see first code snippet)
Same thing goes for /script invoke
fabric-carpet/src/main/java/carpet/commands/ScriptCommand.java
Lines 408 to 411 in 13f0b23
fabric-carpet/src/main/java/carpet/commands/ScriptCommand.java
Lines 430 to 435 in 13f0b23