sandstone-mc / sandstone

Sandstone | Next Generation Framework for Minecraft
https://sandstone.dev/
MIT License
173 stars 16 forks source link

Sandstone if statements within loops lead to say() compiling incorrectly #94

Closed astrealRBLX closed 3 years ago

astrealRBLX commented 3 years ago
for (let i = 0; i < 5; i++) {
  say('some string') // compiles incorrectly
  kill('@e[tag=xjfjsdf]') // compiles correctly
  setblock(abs(0, 100, 0), 'minecraft:air') // compiles correctly
  _.if(someVariable.equalTo(1), () => { // arbitrary if statement

  })
}

compiles into

say "some string"
kill @e[tag=xjfjsdf]
setblock 0 100 0 minecraft:air
run say "some string"
kill @e[tag=xjfjsdf]
setblock 0 100 0 minecraft:air
run say "some string"
kill @e[tag=xjfjsdf]
setblock 0 100 0 minecraft:air
run say "some string"
kill @e[tag=xjfjsdf]
setblock 0 100 0 minecraft:air
run say "some string"
kill @e[tag=xjfjsdf]
setblock 0 100 0 minecraft:air

The first say() compiles correctly but the following ones are prefixed with run which doesn't work. I only tested kill() and setblock() besides say() but they both appeared to compile correctly.

ncfumction commented 3 years ago

The reason is that your if doesn't produce any command while sandstone expects commands so it assumes the next say is the callback commands. Probably should throw an error though.

TheMrZZ commented 3 years ago

Fixed in latest version v1.13.3.