Page 1 of 3

Logic and (&&) is unsupported?

Posted: 06 May 2017, 20:47
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?

Re: Logic and (&&) is unsupported?

Posted: 07 May 2017, 09:18
by ezze
I am fairly sure there are no boolean operators in the MW scripting language.
See also this guide.

Re: Logic and (&&) is unsupported?

Posted: 07 May 2017, 14:31
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.

Re: Logic and (&&) is unsupported?

Posted: 07 May 2017, 14:40
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...

Re: Logic and (&&) is unsupported?

Posted: 07 May 2017, 16:13
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.

Re: Logic and (&&) is unsupported?

Posted: 08 May 2017, 00:55
by KelvinShadewing
Even then, why doesn't OpenMW support them? Seems kind of essential to me.

Re: Logic and (&&) is unsupported?

Posted: 08 May 2017, 03:04
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 } }

Re: Logic and (&&) is unsupported?

Posted: 08 May 2017, 17:09
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".

Re: Logic and (&&) is unsupported?

Posted: 08 May 2017, 17:12
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.

Re: Logic and (&&) is unsupported?

Posted: 23 Jan 2018, 01:12
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.