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

Post » Fri Jan 14, 2011 1:38 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
Nicole Coucopoulos
 
Posts: 3484
Joined: Fri Feb 23, 2007 4:09 am

Post » Fri Jan 14, 2011 1:37 am

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
Siidney
 
Posts: 3378
Joined: Fri Mar 23, 2007 11:54 pm

Post » Fri Jan 14, 2011 7:56 am

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
ImmaTakeYour
 
Posts: 3383
Joined: Mon Sep 03, 2007 12:45 pm


Return to Fallout 3