View Single Post
  #2  
Old 03-21-2006, 10:17 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
Quote:
Originally Posted by Yen
Lately, I've been getting lazy and using 'if (condition) return;' instead of piling up the if (condition) { if (condition) { if (condition) { } } }
Is there any harm that can be caused by doing this?

For example..
PHP Code:
function onActionDamage(dmg,from,fromguild) {
  if (
player.guild == fromguild && player.guild.length() > 0) return;
  if (
player.account == from) return;
  if (
client.allies.index(from) >= 0) return;
  
client.hp -= dmg;

Instead of..
PHP Code:
function onActionDamage(dmg,from,fromguild) {
  if (
player.guild != fromguild || player.guild.length <= 0) {
    if (
player.account != from) {
      if (
client.allies.index(from) == -1) {
        
client.hp -= dmg;
      }
    }
  }

No harm at all, although, it doesn't end the script - it just stops the current function from being executed further.
__________________
Skyld
Reply With Quote