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
  #1  
Old 11-28-2007, 11:59 PM
Nabru Nabru is offline
100 IFP and runnin'
Nabru's Avatar
Join Date: Aug 2005
Location: Wisconsin
Posts: 440
Nabru will become famous soon enough
Send a message via ICQ to Nabru
Comprehension of classes

Hi, most of you knew me as a decent scripter, but after 2 years of playing WoW I forgot most of my knowledge of GS2. Something I never did understand was classes and how to utilize them. I know in C++ classes can be used for a multitude of useful things, I'm wondering if the same thing applies with GScript?

For example: Can I call a class(join(X); )

and then later in the script use a string or command set in that class without error? If this currently doesn't exist I think it'd be an awesome idea..
__________________
~Urban
Reply With Quote
  #2  
Old 11-29-2007, 12:32 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
I think of Graal classes as include functions.

Class: bob
PHP Code:
function bob()
  return 
"Hi! I'm Bob!"
Weapon: Jane
PHP Code:
function onCreated()
{
  
this.join("bob");
  
temp.statement bob();
  echo(
temp.statement);

Reply With Quote
  #3  
Old 11-29-2007, 12:37 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Classes in GScript are probably more closely related to header files in C++ (or object files, even); join is somewhat like #include (or your linker).
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #4  
Old 11-29-2007, 12:41 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Yeah, classes are more like objects in C++, as far as I know.
Classes in Graal are very much like inserting the code of a class into any other script. You can also unjoin (so to speak) classes by using the leave() command. Also, onCreated() in the class is separate from onCreated() in the script you join a class to. onCreated() in a class is called when the class is joined.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #5  
Old 11-29-2007, 01:10 AM
Nabru Nabru is offline
100 IFP and runnin'
Nabru's Avatar
Join Date: Aug 2005
Location: Wisconsin
Posts: 440
Nabru will become famous soon enough
Send a message via ICQ to Nabru
Just the type of responses I was looking for, thanks guys
__________________
~Urban
Reply With Quote
  #6  
Old 11-29-2007, 01:44 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Angel_Light View Post
also, little common sense, classes must be joined serverside.
Uhm.
No. o_o
When you join something serverside it only uses the serverside portion of the class, and vice versa.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #7  
Old 11-29-2007, 01:48 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 Angel_Light View Post
also, little common sense, classes must be joined serverside.
Wrong. It's a good idea to, but when you have a player class, it needs to be joined clientside.

You can't join clientside, then use functions serverside, but it does work vica-versa. I always join serverside, except for player functions.

Classes are a way to make a standard object, or a stand script. For example, for a staff block you might want to make a class so that you can just putnpc2, then join the class, rather then putting in the whole script. And this way, if you need to change something, you can.

Another way to use classes are to provide functions.

Class foo
PHP Code:
function onCreated()
{
  echo( 
"moo" );

Script in level MYLEVELDONTTOUCH.nw
PHP Code:
join"foo" ); 
Will echo "moo" in RC.

EDIT:
Also you said
Quote:
When you join something serverside it only uses the serverside portion of the class, and vice versa.
That's incorrect. When you join serverside, you get serverside & clientside functions, but when you join clientside you only get clientside functions.
__________________
Reply With Quote
  #8  
Old 11-29-2007, 03:00 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by cbkbud View Post
Stuff
Also wrong. You can join serverside and clientside just fine. And player classes generally ARE joined serverside. o.O
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #9  
Old 11-29-2007, 03: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
Quote:
Originally Posted by Angel_Light View Post
also, little common sense, classes must be joined serverside.
No, clientside classes are supported fully now.

And when joining serverside, you only get the clientside functions if that object has an instance of it clientside, like weapons or npcs in levels. Though players don't appear to work like that, from what little I experimented at least.
__________________
Reply With Quote
  #10  
Old 11-29-2007, 03:08 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Inverness View Post
No, clientside classes are supported fully now.

And when joining serverside, you only get the clientside functions if that object has an instance of it clientside, like weapons or npcs in levels. Though players don't appear to work like that, from what little I experimented at least.
Er, yeah my bad. But in clientside, the serverside portion of a class won't work when joined.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #11  
Old 11-29-2007, 04:12 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by cbkbud View Post
Wrong. It's a good idea to, but when you have a player class, it needs to be joined clientside.
Or not? I join classes during the player login event and that's serverside
Reply With Quote
  #12  
Old 11-29-2007, 04:46 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
Sorry, I was unclear.

I mean that for a player class with clientside functions, it needs to be joined clientside.

I join my player classes serverside in the control-npc script, but for the clientside functions, you have to join clientside.

Sorry if I was unclear.
__________________
Reply With Quote
  #13  
Old 11-29-2007, 05:04 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by cbkbud View Post
Sorry, I was unclear.

I mean that for a player class with clientside functions, it needs to be joined clientside.

I join my player classes serverside in the control-npc script, but for the clientside functions, you have to join clientside.

Sorry if I was unclear.
I'm pretty sure you don't have to join on both ends, but I guess it would be good practice to do that anyways.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #14  
Old 11-29-2007, 05:06 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 coreys View Post
I'm pretty sure you don't have to join on both ends...
You don't for normal classes, but when joining to a player you do.

For other classes, always join serverside.
__________________
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 08:23 AM.


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