armoha / euddraft

System for pluginizing eudplib codes.
Other
30 stars 4 forks source link

Bug on modifying current upgrade level #151

Open armoha opened 2 days ago

armoha commented 2 days ago

image-12

  once(t.time >= 3) {
      const upg = Upgrade("Protoss Ground Weapons");
      upg[P1] = 1;
      simpleprint("111111");
  } 

GGRush: Hi Armo, nothing happens Unable to write

GGrush-SCMapper commented 2 days ago

bug: Upgrade("Protoss Ground Weapons")[player] need to add parenthese: (Upgrade("Protoss Ground Weapons"))[player] Is this a problem?Is there a problem with the order of operations?

GGrush-SCMapper commented 2 days ago

also: if we have a function func() return a, b bug: func()[0] or func()[1] when I write (func())[0], correct

GGrush-SCMapper commented 2 days ago

also: const x = a + b << c; euddraft will calculate a+b first, and then (a+b)<<c when I write a+ (b<<c) , correct It seems that euddraft did not prioritize shift operations over addition and subtraction operations

armoha commented 2 days ago

bug: Upgrade("Protoss Ground Weapons")[player] need to add parenthese: (Upgrade("Protoss Ground Weapons"))[player] Is this a problem?Is there a problem with the order of operations?

There's ambiguous syntax in epScript between return value selection and array literal. See https://github.com/armoha/euddraft/issues/114

also: const x = a + b << c; euddraft will calculate a+b first, and then (a+b)<<c when I write a+ (b<<c) , correct It seems that euddraft did not prioritize shift operations over addition and subtraction operations

It follows the bad tradition of C language. For now, always use parentheses if you think it is confusing. See https://www.foonathan.net/2017/07/operator-precedence/ for details on this topic:

The C programming language - and thus many derived languages - has a great example of “bad precedence” that annoys me anytime I use it. The precedence of the binary bitwise operators (&, |, …) is lower than that of the comparison operators (== or ‘<`).