Logic and (&&) is unsupported?

Post about your mods, learn about OpenMW mod compatibility, check for problematic mods, discuss issues, and give us feedback about your experience with modded OpenMW.
User avatar
KelvinShadewing
Posts: 12
Joined: 12 Mar 2015, 14:24
Contact:

Logic and (&&) is unsupported?

Post by KelvinShadewing »

So I tried to load a mod recently, and got a compile error. When I opened it in OpenMW-CS, it gave me "syntax error (&)" on a line that was checking if a variable was between two values. Is there some alternative to this? Why isn't && supported?
ezze
Posts: 513
Joined: 21 Nov 2013, 13:20

Re: Logic and (&&) is unsupported?

Post by ezze »

I am fairly sure there are no boolean operators in the MW scripting language.
See also this guide.
User avatar
AnyOldName3
Posts: 2668
Joined: 26 Nov 2015, 03:25

Re: Logic and (&&) is unsupported?

Post by AnyOldName3 »

I think they even had to be added via F4SE for Fallout 4, so it's not unlikely that Bethesda would have deemed them unnecessary as far back as Morrowind.
User avatar
jirka642
Posts: 117
Joined: 23 Aug 2014, 11:39
Location: Czech Republic
Contact:

Re: Logic and (&&) is unsupported?

Post by jirka642 »

MW scripts don't support boolean operators, but vanilla engine somehow ignores them without throwing error. That's probably why some mods use them without knowing that they don't work...
User avatar
akortunov
Posts: 899
Joined: 13 Mar 2017, 13:49
Location: Samara, Russian Federation

Re: Logic and (&&) is unsupported?

Post by akortunov »

vanilla engine somehow ignores them
It seems vanilla engine treats "&&" and second command as valid extra string arguments in first command. These values are not ignored - there are just elements of arguments array, unused by command.
User avatar
KelvinShadewing
Posts: 12
Joined: 12 Mar 2015, 14:24
Contact:

Re: Logic and (&&) is unsupported?

Post by KelvinShadewing »

Even then, why doesn't OpenMW support them? Seems kind of essential to me.
User avatar
Jyby
Posts: 408
Joined: 10 Dec 2013, 04:16

Re: Logic and (&&) is unsupported?

Post by Jyby »

KelvinShadewing wrote:Even then, why doesn't OpenMW support them? Seems kind of essential to me.
Are they? You can do almost anything with if, else if, else and negation operators. Albeit code duplication.

Code: Select all

// and
if(1 && 2) { foo }

if(1) { if(2) { foo } }

// or
if(1 || 2) { foo }

if(1) { foo }
else { if(2) { foo } }

// xor
if(1 XOR 2) { foo }

If(1) { if(!2) { foo } }
if(2) { if(!1) { foo } }
jmelesky
Posts: 47
Joined: 02 Mar 2017, 20:52

Re: Logic and (&&) is unsupported?

Post by jmelesky »

Jyby wrote: Are they? You can do almost anything with if, else if, else and negation operators. Albeit code duplication.
I agree they aren't essential, but boy howdy would they be a great improvement to the scripting language. So would string variables.

... which brings us back into the question of whether to improve the scripting language or enable a different scripting language (python? lua? something else?). I'm pretty sure that usually ends with a "not till post-1.0".
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Logic and (&&) is unsupported?

Post by Zini »

Exactly. Of course we will get logic operators after 1.0. Probably almost immediately after 1.0. I do consider them essential (even if there is usually a workaround) and adding them is very easy.
User avatar
KelvinShadewing
Posts: 12
Joined: 12 Mar 2015, 14:24
Contact:

Re: Logic and (&&) is unsupported?

Post by KelvinShadewing »

jmelesky wrote: 08 May 2017, 17:09
Jyby wrote: Are they? You can do almost anything with if, else if, else and negation operators. Albeit code duplication.
I agree they aren't essential, but boy howdy would they be a great improvement to the scripting language. So would string variables.

... which brings us back into the question of whether to improve the scripting language or enable a different scripting language (python? lua? something else?). I'm pretty sure that usually ends with a "not till post-1.0".
I'd love to see Squirrel added. It's a great C-like language that doesn't get enough love.
Post Reply