Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Triggering weapons (https://forums.graalonline.com/forums/showthread.php?t=73760)

cbk1994 04-30-2007 03:56 AM

Triggering weapons
 
Anyone know whats wrong with this?
PHP Code:

//#CLIENTSIDE
function onCreatedNULL )
{
  
setTimer0.05 );
}
function 
onTimeOutNULL )
{
  if ( 
keydown2getkeycode"d" ), false ) )
  {
    if ( 
this.kpress == false )
    {
      
doTriggerWeaponNULL );
    }
    
this.kpress true;
  }
  else
  {
    
this.kpress false;
  }
  
setTimer0.05 );
}
function 
doTriggerWeaponNULL )
{
  
temp.findWeaponplayer.weapons[selectedweapon].name );
  
temp.i.onWeaponFired();


GraalScript: Function Weapon Weapons/Basic Sword.onWeaponFired not found in script of Weapon -Player/Trigger

is the error I get in F2 log. Please help :C

JkWhoSaysNi 04-30-2007 03:58 AM

Is onWeaponFired() public in the weapon NPC?

cbk1994 04-30-2007 03:59 AM

Weapons/Basic Sword
PHP Code:

join"functions_weapon" );
//#CLIENTSIDE
function onCreatedNULL )
{
  
this.item_type "weapon";
  
this.item_name "Basic Sword";
  
this.item_var "basicsword";
  
  
this.sword_damage 10;
  
this.sword_freezetime .5;
  
this.sword_gani_idle "idle";
  
this.sword_gani_walk "walk";
  
this.sword_gani_attack "sword";
  
this.sword_image "sword2.png";


in the class

PHP Code:

[...]
//#CLIENTSIDE
[...]
function 
onWeaponFiredNULL )
{
  
equipWeaponNULL );



JkWhoSaysNi 04-30-2007 04:02 AM

change it to:

PHP Code:

public function onWeaponFiredNULL )
{
  
equipWeaponNULL );


Is there any reason for passing NULL to the function?

Rapidwolve 04-30-2007 04:05 AM

Quote:

Originally Posted by JkWhoSaysNi (Post 1304467)
Is there any reason for passing NULL to the function?

I was thinking the same.

cbk1994 04-30-2007 04:26 AM

Makes it look better

Deadly_Killer 04-30-2007 04:48 AM

Quote:

Originally Posted by cbkbud (Post 1304476)
Makes it look better

It looks retarded, to be perfectly honest with you.

It seems like a lot of useless space, and is a horrible habit if you plan to go into other languages such as C/C++/C# due to functions needing to take specific parameters.

cbk1994 04-30-2007 04:57 AM

Quote:

Originally Posted by Deadly_Killer (Post 1304481)
It looks retarded, to be perfectly honest with you.

It seems like a lot of useless space, and is a horrible habit if you plan to go into other languages such as C/C++/C# due to functions needing to take specific parameters.

You sound retarded, to be perfectly honest with you.

Please read my post on Clean Coding: Common Sense, and you will find that everyone has their own scripting style, and that if it's okay with them, it works. I've already stated my mind on people who say that lines of code matter, and that space matters. You can't waste space because I can put as many of those as I want.

I can already script in C++, so get off of my ass.

Deadly_Killer 04-30-2007 05:02 AM

Quote:

Originally Posted by cbkbud (Post 1304482)
You sound retarded, to be perfectly honest with you.

Please read my post on Clean Coding: Common Sense, and you will find that everyone has their own scripting style, and that if it's okay with them, it works. I've already stated my mind on people who say that lines of code matter, and that space matters. You can't waste space because I can put as many of those as I want.

I can already script in C++, so get off of my ass.

1) C++ is not a 'script'.
2) I won't argue with you, it seems like a waste of time.

Tigairius 04-30-2007 05:44 AM

Quote:

Originally Posted by JkWhoSaysNi (Post 1304467)
Is there any reason for passing NULL to the function?

Yeah, seriously..? The script looks retarded, it's inefficient, the spacing between... everything is very bad looking, you're putting things where they don't need to be, and in my opinion, that script is terrible. I have done some bad scripting in my day, but nothing amounts to the poor quality of that specific script.

ff7chocoboknight 04-30-2007 08:07 AM

Ok When Did This Thread Have Anything To Do With Attacking Eachother About How Ppl Script? I Mean Really Ppl, Lets All Argue About The Way He Scripts Instead Of Helping Him!!

Chandler 04-30-2007 08:26 AM

You need to use public function,
public function onWeaponFired
should fix it.

Nice code btw, :)

Novo 04-30-2007 08:43 AM

Don't bite me.

Do this:

weapon.trigger("WeaponFired", params );

This'll trigger onWeaponFired, but if it doesn't exist, it doesn't do anything.

Another is to make onWeaponFired a public function and doing:
weapon.onWeaponFired();

cbk1994 04-30-2007 01:44 PM

Quote:

Originally Posted by Tigairius (Post 1304495)
Yeah, seriously..? The script looks retarded, it's inefficient, the spacing between... everything is very bad looking, you're putting things where they don't need to be, and in my opinion, that script is terrible. I have done some bad scripting in my day, but nothing amounts to the poor quality of that specific script.

Quote:

Originally Posted by cbk1994
Please read my post on Clean Coding: Common Sense, and you will find that everyone has their own scripting style, and that if it's okay with them, it works. I've already stated my mind on people who say that lines of code matter, and that space matters. You can't waste space because I can put as many of those as I want.

Thank you Novo and Chandler for being nice about respecting other people's code, and for the suggestions. The weapon.trigger is working perfectly.

Would a moderator please lock this topic, it has no more purpose and I don't want an even bigger arguement.

zokemon 04-30-2007 03:11 PM

I agree the NULL may be a little useless and does get rather in the way in my opinion but I don't see his script as looking horribly structured o_o

He likes to space his stuff out alot... So?

Personnaly, when I get into immensly long scripts, styling is important yes but any script style (as long as it is still organized and consistant) mean nothing as the script just a big haze :) (Have to remember where certain functions are defined in the script and such)

JkWhoSaysNi 04-30-2007 03:21 PM

I'm pretty sure that having function whatever(NULL) will not read by the graal in the way you want it to be. The compiler will think that the function takes an argument... then you send NULL to it. All it will do is slightly reduce the efficiency of the script.

Skyld 04-30-2007 04:55 PM

Well, function onCreated(NULL) means that any parameter given will attempt to be written to a null reference. All it is doing is fooling the engine, and it should not be there. That space is reserved for parameter lists only, and should not be filled with non-functional things.

cbk1994 05-01-2007 01:19 AM

Quote:

Originally Posted by Skyld (Post 1304583)
Well, function onCreated(NULL) means that any parameter given will attempt to be written to a null reference. All it is doing is fooling the engine, and it should not be there. That space is reserved for parameter lists only, and should not be filled with non-functional things.

Thank you for clearing that up Skyld, I will certainly stop. Would you please lock this topic, because the purpose of this topic was to fix my script, which has been done. I never asked for anyone to comment on my styling.

Thanks.


All times are GMT +2. The time now is 10:24 AM.

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