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!