Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #46  
Old 03-31-2007, 01:44 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 Angel_Light View Post
Yes this has happened to me too *sneeze*TheFox*sneezes* I just used the Servers style command

/style Type Name

Like when Fox made a weapon I couldnt read I did

/Style weapon -FoxTest

it's not "my" style but it organizes the code.
Simple yet effective
__________________
What signature? I see no signature?
Reply With Quote
  #47  
Old 03-31-2007, 02:02 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 Chandler View Post
I'd do this:
PHP Code:
public function Hurt(hurtDamageattackersAccounthurtGani)
  if (
this.clientr.hp && !this.clientr.dead && !level.nopk && !this.client.nopk)
  {
  
this.clientr.hp -= abs(temp.hurtDamage);  
  if (
temp.hurtGani
    
this.setAni("hurt""");
  
clientr.lastattacker temp.attackersAccount;
  if (
this.clientr.hp <= 0
    
this.doDeath(temp.attackersAccount);
  
this.showHp(7);
  }
public function 
doDeath(attackersAccount)
  {
  
this.clientr.dead true;
  
this.clientr.hp 0;
  
this.Kill(temp.attackersAccount); 
  } 
Ugh, that makes my eyes bleed. Your brackets should be inline with the block, not with the contents. You've missed out a load of brackets anyway, and you've mixed all sorts of conditional checks which are totally unrelated to each other in one line. :/ Bleugh.
__________________
Skyld
Reply With Quote
  #48  
Old 03-31-2007, 02:12 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
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
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Skyld View Post
Ugh, that makes my eyes bleed. Your brackets should be inline with the block, not with the contents. You've missed out a load of brackets anyway, and you've mixed all sorts of conditional checks which are totally unrelated to each other in one line. :/ Bleugh.
I second that..
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #49  
Old 03-31-2007, 02:24 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Rapidwolve View Post
I recently have been practicing better organization and clean coding in my scripts, heres a snippet.

PHP Code:
public function Hurt(damageattackerhurtani){
  
temp.conditionsok = ((this.clientr.hp && this.clientr.dead == false && level.nopk == false && this.client.nopk == false) ? true false);
   if (
temp.conditionsok){
       if (
temp.damage => this.clientr.hp) {
        
this.clientr.hp 0;
        
this.Kill(temp.attacker); 
        
this.showHp(7);
        return;
       }
       if (
temp.hurtanithis.setani("hurt"null);
          
clientr.lastattacker temp.attacker;
          
this.clientr.hp -= abs(temp.damage);
          
this.showHp(7);
    }
    return;

Looks nice, but personally I prefer
PHP Code:
if (temp.hurtani == true
instead of
PHP Code:
if (temp.hurtani
and I'd recommend braces for everything anyway.

Hachi ... I'd be scared to see your scripting.
__________________
Reply With Quote
  #50  
Old 03-31-2007, 07:34 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Quote:
Originally Posted by Gambet View Post
Yeah, your old method of not styling at all and scripting like this:

PHP Code:
function onCreated(){
player.chat="Rapid's styling sucks major wang";
setTimer(1);
}

function 
onTimeOut(){
this.yourstylingoldstylingsucks;;
chat="You grouped everything together without any spacing";
echo(
"And it was very annoying to read");
setTimer(1);


Or something like that....



It was very annoying and barely legible.

I never styled like that x.x
Reply With Quote
  #51  
Old 03-31-2007, 07:37 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Quote:
Originally Posted by Skyld View Post
Ugh, that makes my eyes bleed. Your brackets should be inline with the block, not with the contents. You've missed out a load of brackets anyway, and you've mixed all sorts of conditional checks which are totally unrelated to each other in one line. :/ Bleugh.
*****.
Reply With Quote
  #52  
Old 03-31-2007, 08:26 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
Someone (Well, a couple) told me to change my styling so...

PHP Code:
public function Hurt(damageattackerhurtani) {
  
temp.conditionsok = ((this.clientr.hp && this.clientr.dead == false && level.nopk == false && this.client.nopk == false) ? true false);
  if (
temp.conditionsok) {

    if (
temp.damage => this.clientr.hp) {
      
this.clientr.hp 0;
      
this.Kill(temp.attacker); 
      
this.showHp(7);
      return 
NULL;
    }
    if (
temp.hurtani)
      
this.setani("hurt"NULL);

    
this.clientr.lastattacker temp.attacker;
    
this.clientr.hp -= abs(temp.damage);
    
this.showHp(7);
    return 
NULL;
  }

(Based of RW's script)
__________________
Reply With Quote
  #53  
Old 03-31-2007, 08:31 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
I don't care what people think of my styling it's makes scripting easier for me and allows ME to read it better/quicker. But when ever I do post a snippet I usually do use the /style.
__________________
Deep into the Darkness peering...
Reply With Quote
  #54  
Old 03-31-2007, 09:42 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Chompy View Post
Someone (Well, a couple) told me to change my styling so...

PHP Code:
public function Hurt(damageattackerhurtani) {
  
temp.conditionsok = ((this.clientr.hp && this.clientr.dead == false && level.nopk == false && this.client.nopk == false) ? true false);
  if (
temp.conditionsok) {

    if (
temp.damage => this.clientr.hp) {
      
this.clientr.hp 0;
      
this.Kill(temp.attacker); 
      
this.showHp(7);
      return 
NULL;
    }
    if (
temp.hurtani)
      
this.setani("hurt"NULL);

    
this.clientr.lastattacker temp.attacker;
    
this.clientr.hp -= abs(temp.damage);
    
this.showHp(7);
    return 
NULL;
  }

(Based of RW's script)
I've never seen of return NULL. Any different from return false;?

--

There's more to scripting than you reading it. It needs to be legible for others too.
__________________
Reply With Quote
  #55  
Old 03-31-2007, 09:43 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 cbkbud View Post
I've never seen of return NULL. Any different from return false;?
return NULL; is just to clear out that it is not returning to a function nor returning a value.
__________________

Last edited by Chompy; 03-31-2007 at 09:57 PM..
Reply With Quote
  #56  
Old 03-31-2007, 09:56 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by cbkbud View Post
Looks nice, but personally I prefer
PHP Code:
if (temp.hurtani == true
instead of
PHP Code:
if (temp.hurtani
and I'd recommend braces for everything anyway.

Hachi ... I'd be scared to see your scripting.
What? if(something == true)? ::hits::
__________________
Reply With Quote
  #57  
Old 03-31-2007, 09:59 PM
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
checking "if (var == true)" is redundant unless you're not sure on the type of the variable.
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #58  
Old 04-01-2007, 12:58 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by JkWhoSaysNi View Post
checking "if (var == true)" is redundant unless you're not sure on the type of the variable.
Works fine ... to me it seems simpler.

if ( var == 1 )

better?
__________________
Reply With Quote
  #59  
Old 04-01-2007, 01:00 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
if (var) is simpler and more efficient.

when you do if (var == true) the interpreter is basically doing 2 checks.
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #60  
Old 04-01-2007, 03:14 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I see. I'll try to get used to that, though I suppose it doesn't matter that much now that I see it
__________________
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 11:19 AM.


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