Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-04-2008, 09:06 AM
The_Kez The_Kez is offline
N-Pulse Asst. Manager
The_Kez's Avatar
Join Date: Dec 2007
Posts: 106
The_Kez is on a distinguished road
Send a message via MSN to The_Kez
Questions about classes

My understanding about classes is that when you join a class to an object, the 'this' object in the class becomes the object you joined the class to. So if you joined a class to a player, obviously 'this' would be this player who triggered the class function to be called.
I'm wondering if the 'this' rule of classes applies to all other objects aside from the player. So that if you join a class to a level NPC, 'this' would be the NPC the class is joined to.
One would wonder how I've gone this long without clarifying this basic idea about classes, but here I am :P

My more specific question stems from the same general question about classes. I want to join a class to my GUIs to reduce the clutter in some of my system weapons. I want to add functions to my GUIs (for example Inventory.toggle()) but I'm having a hard time getting my functions to call.
My idea to do this would be:

PHP Code:
//#CLIENTSIDE
function DrawWindow() {
new 
GuiWindowCtrl"TestWindow" ) {
  
this.join"testwindowfunctions" );
  
//window attributes
}
}
function 
onKeyPressedcd ky ) {
  if ( 
ky == "Q" TestWindow.Toggle();
  if ( !
TestWindow.Toggle() ) DrawWindow();

Which would trigger:

PHP Code:
//#CLIENTSIDE
public function Toggle() {
  echo( 
"Object: " this );
  if ( 
this.visible this.destroy();
  else return 
false;

I have a script similar to this running in an inventory window, but I can't seem to call the class.

Don't know if this is a very practical way of doing things. Mainly I'm just looking for some clarifications about this stuff. And if anyone has any better ideas on how organize the GUI scripts that is always welcome too. =)

UPDATE:
The above script probably wouldn't work because the function is called before the class ever has a chance to be joined to the object. How can I join the class to the object to do something like that if the class is supposed to be triggering the window to be created in the first place?

Last edited by The_Kez; 08-04-2008 at 09:59 AM.. Reason: Update
Reply With Quote
 


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:17 PM.


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