Refer to a reference using "this" or "me"

Post » Wed May 02, 2012 10:32 am

I want to place a script on an actor but not know specifically which reference it will be running on while in game.

For example I may have the following actors:

raider01
raider02
raider03

All of which have a script running on them "raiderScript". I want to use their reference to do stuff like moveTo and addItem but I don't want to create a seperate script for each raider.

Is it possible to do something like:

this.moveTo
me.moveTo

Or find out what reference the script is running on so I can store it in a ref variable?
User avatar
Rachael Williams
 
Posts: 3373
Joined: Tue Aug 01, 2006 6:43 pm

Post » Wed May 02, 2012 1:26 pm

If the script is on the actor, you don't need its reference to add items or moveto or anything else. Functions will execute with the actor reference implied.

However, if you need the reference for another script, like a quest script or something, then you need to use GetSelf (This) to set the quest variable. BUT, this function returns 0 for actors that have not been placed in the editor (random spawns).

There are a couple other advanced ways to get actor references for scripts that are not on the actor if you need it.
User avatar
Tessa Mullins
 
Posts: 3354
Joined: Mon Oct 22, 2007 5:17 am

Post » Wed May 02, 2012 6:36 pm

If the script is on the actor, you don't need its reference to add items or moveto or anything else. Functions will execute with the actor reference implied.

However, if you need the reference for another script, like a quest script or something, then you need to use GetSelf (This) to set the quest variable. BUT, this function returns 0 for actors that have not been placed in the editor (random spawns).

There are a couple other advanced ways to get actor references for scripts that are not on the actor if you need it.

OK cool I will give it a go.
User avatar
Carolyne Bolt
 
Posts: 3401
Joined: Mon Jul 10, 2006 4:56 am


Return to Fallout 3