View Single Post
  #8  
Old 08-17-2008, 01:54 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by [email protected] View Post
However, you'd need to remove the 'this.level.chair' to replace it with 'level.chat'
No you don't. And I assume you meant level.chair. In an NPC, this.level.chair is the same as level.chair because static (built-in) variables can be accessed with or without the this. prefix.
Quote:
Originally Posted by [email protected] View Post
and also make the 'onActionShock' a public function
No you don't, it only needs to be public if you're calling it. You can trigger events even if they're not public.

Function Call: this.level.chair.onActionShock();
Calling a function means its on the same thread so that function must complete before the script can continue to next statement. To call a function in a different object it needs to be public.

Event Trigger: this.level.chair.trigger("ActionShock", null);
Triggering an event means its on a different thread, so it means the script that triggered it will continue to next statement while the onActionShock executes at the same time. An event does not need to be public to trigger it because the trigger function is public and that is the function you are using.
__________________
Reply With Quote