Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

View Poll Results: How do YOU style it?
Alternative A 4 19.05%
Alternative B 16 76.19%
Other (if so, please post how) 1 4.76%
Voters: 21. You may not vote on this poll

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-30-2007, 03:21 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
How do YOU style it?

Ive been curious about whats the most common styling with using true/false variables, so I figured Id make a poll about it.



Alternative A:

PHP Code:
if (this.var == true)
if (
this.var == false

Alternative B:

PHP Code:
if (this.var)
if (!
this.var) 

I, personally, go with alternative A.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #2  
Old 01-30-2007, 03:26 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
I actually just style it depending on how I feel like doing it.

But, mostly, I believe I do Alternative B, though sometimes I do stuff like


PHP Code:
if (!(this.var)) 
Reply With Quote
  #3  
Old 01-30-2007, 03:26 AM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
B...

Why check a boolean variable is true and then have the if statement check the result of that?

B just seems more efficient.
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #4  
Old 01-30-2007, 05:01 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by JkWhoSaysNi View Post
B...

Why check a boolean variable is true and then have the if statement check the result of that?

B just seems more efficient.
Ditto.

I also like to do stuff like
PHP Code:
temp.string.pos(substr);
if (~
temp.p)
if (!~
temp.p
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #5  
Old 01-30-2007, 05:11 AM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
Personally I'm a fan of the cutoff look
Reply With Quote
  #6  
Old 01-30-2007, 09:55 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Option B
Reply With Quote
  #7  
Old 01-30-2007, 11:07 AM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
I tend to go with B, especially when the variable name makes sense, such as this.pathIsBlocked.
Reply With Quote
  #8  
Old 01-30-2007, 11:09 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Haha, im totally in a minority here..
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #9  
Old 01-30-2007, 03:50 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by DrakilorP2P View Post
I tend to go with B, especially when the variable name makes sense, such as this.pathIsBlocked.
agreed
__________________
Reply With Quote
  #10  
Old 01-30-2007, 03:58 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Didnt vote for anything because of...

PHP Code:
if (this.var == 1)
if (
this.var != 1
Reply With Quote
  #11  
Old 01-30-2007, 09:45 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
I prefer alternative A, because you find things better and its more comprehensive =]
__________________
What signature? I see no signature?
Reply With Quote
  #12  
Old 01-30-2007, 09:47 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
I normally use (and prefer to use) B, since there is little point in the engine essentially doing (var == true) == true, not sure if it's folded in the bytecode.

I do use A sometimes, though.
__________________
Skyld
Reply With Quote
  #13  
Old 01-30-2007, 10:03 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
I prefer B, I think A comes from C++ where it sometimes looks better when you show that you make a boolean comparison and not some check-for-valid-pointer hack.
A is also slower although the comparions-operation is not really that slow. It looks a little bit weird to compare with true or false though, "if (true==true)"
Reply With Quote
  #14  
Old 01-30-2007, 10:06 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by Stefan View Post
I prefer B, I think A comes from C++ where it sometimes looks better when you show that you make a boolean comparison and not some check-for-valid-pointer hack.
A is also slower although the comparions-operation is not really that slow. It looks a little bit weird to compare with true or false though, "if (true==true)"
That would be a bit wierd, I always use while / if (true); So I suppose I alternate between A and B =]
__________________
What signature? I see no signature?
Reply With Quote
  #15  
Old 01-30-2007, 11:20 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
I prefer A since I like the way it looks.
__________________
Reply With Quote
  #16  
Old 01-31-2007, 08:13 AM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
I prefer method A.

However recently I found myself using method B because there is a bit less to type.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:40 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.