Switch cases throw an exception when using scoreboard:selector values
Closed this issue · 5 comments
Describe the bug
When using a scoreboard value (using the scoreboard:selector
syntax) as a variable in a switch case, the compiler will throw a syntax exception saying the colon is an unexpected token.
To Reproduce
- Use a
scoreboard:selector
value in a switch case and try to compile the project.
Screenshots
Desktop
- Windows 10
This is intended behavior. I'll see what I can do but WingedSeal has already said that you should just copy the variable over with $temporary = test_objective:value
.
Oh is it? Because the documentation on the website says using the scoreboard:selector
syntax is allowed.
To quote:
"Switch Case will run commands according to the value of given variable/objective:selector."
That's not to say you're wrong! But one or the other should be corrected, preferably the ability to use the o:s
syntax. I think the $variable
syntax can be really helpful, but the ability to allocate variables to specific scoreboards for organization purposes is substantial imo.
WingedSeal said that was a documentation error.
Granted, that was 5 months ago, and I'd like to change the behavior, but I can't really override his decisions. (It might also run into technical complications as objective:selector
is 3 tokens and $variable
is only 1.)
Update: I managed to figure it out, it was actually simpler than I expected.
I was actually just about to reply when I saw the comment lol awesome! I appreciate it, it really helps to have variables be grouped by scoreboards for debugging purposes when testing in-game, but it wouldn't have been the end of the world if it had to rely on a quick variable declaration to get it to work.
I do think it will be more intuitive to include it, tho.