Inverness |
08-17-2008 01:54 PM |
Quote:
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:
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.
|