WingedSeal / jmc

A compiler for JMC (JavaScript-like Minecraft Function), a mcfunction extension language for making Minecraft Datapack
https://jmc.wingedseal.com
MIT License
64 stars 10 forks source link

Switch cases throw an exception when using scoreboard:selector values #48

Closed w00tyd00d closed 1 year ago

w00tyd00d commented 1 year ago

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

  1. Use a scoreboard:selector value in a switch case and try to compile the project.

Screenshots

image image

Desktop

Nico314159 commented 1 year ago

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.

w00tyd00d commented 1 year ago

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.

Nico314159 commented 1 year ago

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.)

Nico314159 commented 1 year ago

Update: I managed to figure it out, it was actually simpler than I expected.

w00tyd00d commented 1 year ago

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.