The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: pacdiggity on June 12, 2011, 02:48:56 AM

Title: [VX] && or and?
Post by: pacdiggity on June 12, 2011, 02:48:56 AM
I've been looking through a number of scripts recently, and noticed that the most revered and more experienced scripters use && where and could be used. I know that there's a bug in XP for and, but is it the same for VX or is it just personal preference?
Do they even do different things?
Title: Re: [VX] && or and?
Post by: cozziekuns on June 12, 2011, 04:39:58 AM
"and does the same as &&, but is a lower priority operator."

Taken straight from the RPGVX help file. I'm not sure about their exact priorities though. They're pretty much interchangeable.
Title: Re: [VX] && or and?
Post by: LoganF on June 12, 2011, 04:39:58 AM
I generally use && for it (similarly I use || for or), but that's because I come from a C++ background where it's used like that. But there's not too much difference between the two as far as I know, so it's probably just preference. (Edit: except for the priorities as Cozzie says).

I don't know much about RMXP though, only VX, so whether there are any issues that have remained in things like && and 'and' I have no idea.
Title: Re: [VX] && or and?
Post by: pacdiggity on June 12, 2011, 04:51:31 AM
Righto, so I guess it's mainly a preference thing. I prefer and.
@cozzie, it's so easy to miss things in the help file, isn't it?
Title: Re: [VX] && or and?
Post by: IMP1 on June 12, 2011, 11:24:24 AM
a = true && false
=> false # a is false
a = true and false
=> false # a is true

&& for me makes more sense, and if I want to use 'and', I'll use && with some parentheses.
Title: Re: [VX] && or and?
Post by: ForeverZero on June 12, 2011, 04:56:38 PM
::
[]
**
-(unary)  +(unary)  !  ~
*  /  %
+  -
<< >>
&
|  ^
> >=  < <=
<=> ==  === !=  =~  !~
&&
||
..  ...
?:(conditional operator)
=(+=, -= ... )
not
and or


Its is safer to use a "&&" to avoid the statement from being interpreted wrong, though I personally use () in such situations anyway just to make the code a little more over-viewable.