View Single Post
  #4  
Old 12-27-2012, 08:28 PM
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 sssssssssss View Post
Ok cool that was it. Can you give me a brief explanation of making variables objects and why?
The this. prefix always refers to the current object scope. When you're in a GUI "new" block (or similar, such as "with"), you're outside of the script scope. The thiso. prefix can always be used to get back to the script scope.

PHP Code:
// script of NPC Test
function onCreated() {
  
this.foo "bar";
  echo(
this.foo); // echoes "bar"
  
echo(Test.foo); // echoes "bar"
  
  
with (findPlayer("cbk1994")) {
    echo(
this.foo); // probably echoes 0 since this won't exist
    
echo(thiso.foo); // echoes "bar"
  
}

Looks like the addControl is being used correctly to me but depending on what you're trying to do it may or may not be correct. In general I would move the addControl line up to inside the control definition and just do Dialog_Control.addControl(this);
__________________
Reply With Quote