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
  #31  
Old 03-30-2007, 11:46 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
Ah, no wonder I had that array problem that time, oh well, it can be easily be fixed.
PHP Code:
function onCreated() {
  
temp.rawr 0;
  
rawr 3;
  echo(
"1:" rawr);
  echo(
"2:" temp.rawr);

Returns 3 in both cases, problem solved.

Edit:
It doesn't look pretty anymore though
__________________
Reply With Quote
  #32  
Old 03-30-2007, 11:52 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 Inverness View Post
Ah, no wonder I had that array problem that time, oh well, it can be easily be fixed.
PHP Code:
function onCreated() {
  
temp.rawr 0;
  
rawr 3;
  echo(
"1:" rawr);
  echo(
"2:" temp.rawr);

Returns 3 in both cases, problem solved.

Edit:
It doesn't look pretty anymore though
I'm not sure why you are trying to manage the variables anyway. The engine's meant to do that for you, and if your functions are structured sensibly, it should be obvious which variable names you are using.
__________________
Skyld
Reply With Quote
  #33  
Old 03-30-2007, 11:53 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
Uh, I do this for the simple fact that I'm damn tired of typing temp. before every variable name, no other reason. I also like it better without temp., its more pretty like that. Also shortens the code in the long run.
__________________
Reply With Quote
  #34  
Old 03-30-2007, 11:54 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Skyld View Post
I'm not sure why you are trying to manage the variables anyway. The engine's meant to do that for you, and if your functions are structured sensibly, it should be obvious which variable names you are using.
I think it's more of a styling thing. So he doesn't have to write temp. all of the time.

EDIT:
Ding Ding Ding!
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #35  
Old 03-30-2007, 11:54 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 Inverness View Post
Uh, I do this for the simple fact that I'm damn tired of typing temp. before every variable name, no other reason. I also like it better without temp., its more pretty like that.
Hm, in my opinion, it is better to always prefix variables. That way, there is no confusion as to which scope you are working in.

I try to write my scripts for people who have to work with them as well as for myself.
__________________
Skyld
Reply With Quote
  #36  
Old 03-30-2007, 11:55 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
Quote:
Originally Posted by Skyld View Post
Hm, in my opinion, it is better to always prefix variables. That way, there is no confusion as to which scope you are working in.

I try to write my scripts for people who have to work with them as well as for myself.
For myself, I only do this no-prefixing thing for temp variables, like how local variables in Java usually go without a prefix. So there is no confusion for myself. But also, all the temp variables are declared at the beginning so you know them already.

Edit:
I would like it if un-prefixed variables defaulted to temp. rather than a global if no previous temp. or this. variables were found.
__________________
Reply With Quote
  #37  
Old 03-30-2007, 11:59 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 Inverness View Post
For myself, I only do this no-prefixing thing for temp variables, like how local variables in Java usually go without a prefix. So there is no confusion for myself. But also, all the temp variables are declared at the beginning so you know them already.
My point is not so much whether it's solely clear to you, but also to other people who are reading the script who might not be as good at scripting as you or I. A lot of people have difficulty getting their heads around variable declarations, and even more people have difficulty identifying differences between scopes. If everything temporary is prefixed, there's no confusion. If you list things as temp. and then don't use temp. in the rest of the function, that seems slightly misleading. :|

There's more to styling than whether it looks pretty or not; it's about catering for other people who may wish to edit the script or read it. It's for that reason that we prefer people to style scripts before posting asking for help with them here.
__________________
Skyld
Reply With Quote
  #38  
Old 03-31-2007, 12:02 AM
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
You have a good point.
Though on Aeon, Napo and myself are the only major scripters and hes easily skilled enough to not be confused in any way.
Though I suppose when I release some of my stuff to public I will restyle it...
However until then nobody needs to be lookin' at my stuff :P

/sign for un-prefixed variables going temp and not global.
__________________
Reply With Quote
  #39  
Old 03-31-2007, 03:39 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
Clean coding looks prettier anyway
__________________
Reply With Quote
  #40  
Old 03-31-2007, 05:46 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
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;

Reply With Quote
  #41  
Old 03-31-2007, 07:53 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
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.

Reply With Quote
  #42  
Old 03-31-2007, 08:07 AM
Bl0nkt Bl0nkt is offline
Era Developer
Bl0nkt's Avatar
Join Date: Mar 2005
Location: Pennsylvania
Posts: 1,589
Bl0nkt will become famous soon enough
Send a message via AIM to Bl0nkt
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.

Looks fine to me
Reply With Quote
  #43  
Old 03-31-2007, 08:32 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Quote:
Originally Posted by Bl0nkt View Post
Looks fine to me
You wonder why scripters hate looking at your scripts Hachi?

__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #44  
Old 03-31-2007, 08:51 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
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); 
  } 
Reply With Quote
  #45  
Old 03-31-2007, 09:08 AM
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
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.
__________________
Deep into the Darkness peering...
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 12:25 PM.


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