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 01-24-2010, 07:00 PM
thatdwarf thatdwarf is offline
Former UN Dev Admin
Join Date: Nov 2005
Posts: 42
thatdwarf is on a distinguished road
Weapon -> Class

Hey everybody,

I'm having a bit of a tough time here. I've tried seperating the GUI initialization lines from my weapon script and placed them in a class.

Here's the general layout:

Weapon Script:
PHP Code:
/*
   class functions:
      createGUI() - public function that holds the GUI creation lines
      toggle(status) - public function that shows/hides the GUI windows
*/

//#CLIENTSIDE
this.join("gui_design");

function 
onCreated() {
  
this.on false;
  
createGUI();
  
toggle(this.on);
}

function 
onWeaponFired() {
  
this.on = !this.on;
  
player.chat = (this.on) ? "On":"Off";
  
toggle(this.on);

Class Script
PHP Code:
//#CLIENTSIDE
public function toggle(status) {
  if(
status) {
    
Menu.show();
    
Stats.show();
  }else{
    
Menu.hide();
    
Stats.hide();
  }
}

public function 
createGUI() {
  
//GUI Lines Here

I also have each button calling an appropriate function using thiso.catchevent(). Should those functions also be public?

The problem that I am having is if the player has just logged on and tries to turn on the NPC, the status switches, but the GUI does not hide/show. If I hit "Apply" on the script window, it works.

This is obviously very inconvenient, and indicates something is wrong. Any suggestions?


I also plan on using a TStaticVar, defined in another class, to allow changes to the GUI to be extremely easy. But I'm having trouble passing the TStaticVar inbetween scripts.


Thanks in advance!
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 06:57 AM.


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