View Single Post
  #2  
Old 03-29-2011, 08:58 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by PhilSmith View Post
[New Version]
Don't be afraid of using } else if {. It is best to be explicit about how your program 'branches' than force whoever is reading it to think about it themselves.

For example, temp.foundPlayers.size()==1 and temp.foundPlayers.size()<1 both clearly can never be true at the same time, but you should always make that clear just in case the conditions are not so clearly disjoint like they are here.


Also, temp.foundPlayers.destroy(); at the start of a function makes no sense. temp.foundPlayers won't even exist then. If you are going to use it as an array, it is best to create one at that point: temp.foundPlayers = {};


Regarding the filter thing, it's just an interesting note. Most people don't program like that in GS2, but I think more people should. The less code you write, the less that can go wrong.

If you're curious about it, let me know what you tried and I can hopefully tell you what went wrong.
Reply With Quote