Jump to content

Getting a reference to the script caller


Noggog

Recommended Posts

So, if I have a script that is attached to a creature. Is there a "this" functionality that will let me get a reference to the creature that called the script?

 

For example.. how would I do a simple script that would kill the creature that called the script?

Link to comment
Share on other sites

This or Getself are one and the same. Both will return a reference to the creature (or whatever object) to which the script is attached ("creature that called the script" is not the best way to put it, btw)

 

So, a script like this does the work:

 

Scn MyScript
Ref refMe
Begin gamemode
   Set refMe to GetSelf
   If <whatever conditions you may have>
       refMe.Kill
   endif
end

 

But it just happens that if you do not provide a reference for a function, the function applies to the object that has the script.

So, this would suffice:

 

Scn MyScript
Begin gamemode
   If <whatever conditions you may have>
       Kill
   endif
end

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...