Thread: Npc to Npc
View Single Post
  #33  
Old 02-16-2011, 01:42 AM
kingcj kingcj is offline
Registered User
kingcj's Avatar
Join Date: Apr 2006
Location: TN
Posts: 114
kingcj will become famous soon enough
Send a message via MSN to kingcj
Bump (sorta)
This is what I am working with, and everything works Except calling the function from the SwitchDB to the door.

This is the Switch Database

PHP Code:
function onCreated() {
  
SwitchDB = this;
  
this.switches = new TStaticVar();
  
this.doors = new TStaticVar();
  
this.connections = new TStaticVar(); 
  
this.connections.switch_a = "door_a";
}

public function 
addSwitch(temp.sname, temp.sobj) {
  
this.switches.(@temp.sname) = temp.sobj;
  echo(
"added touch "@temp.sname);
}

public function 
addDoor(temp.dname, temp.obj) {
  
this.doors.(@temp.dname) = temp.obj;
  echo(
"added door " @temp.dname);
}

public function 
switchHit(temp.switchName) {
  echo(@ 
temp.switchName);
   
temp.doorName = this.connections.(@temp.switchName); 
  
temp.door = this.doors.(@temp.doorName);   
  echo(@
temp.doorName);
  
temp.door.doorOpen();   
} 
The Switch

PHP Code:
function onCreated() {
  
SwitchDB = findnpc("SwitchDB");
  
SwitchDB.addSwitch("switch_a", this);
  
setshape(1,32,32);
}

function 
onPlayerTouchsMe() {
  
SwitchDB.switchHit("switch_a");
  
this.chat = "touched!";
  
sleep(1);
  
this.chat = "";
} 
And the door

PHP Code:
function onCreated() {
  
SwitchDB = findnpc("SwitchDB");
  
SwitchDB.addDoor("door_a", this);
}


public function 
doorOpen() {
  
this.hide();
  
sleep(3);
  
this.show();
} 
I've placed the public function in both the door and switchDB but doesn't work any which way i place it. Any help would be appreciated.
__________________
Zie

"It is not necessary to change. Survival is not mandatory." - W. Edwards Deming
Reply With Quote