May be a silly question but....

Post » Thu Apr 25, 2013 7:21 am

I am wondering if Papyrus scripts attached to things are instantiated or just used.

For example, if I have a magicEffect, with a script attached to it, and the script keeps track of something, counting onHit() events for example, via a 'int counter' variable. If I apply this magicEffect to 5 different actors, does each actor have an 'instance' of my script, and their own independent 'counter' variable? Or do I need to define a list of Actors[5] and counter[5] in my script to keep track of this independently for each?

Thanks!
User avatar
Auguste Bartholdi
 
Posts: 3521
Joined: Tue Jun 13, 2006 11:20 am

Post » Wed Apr 24, 2013 11:01 pm

Each script on an object is it's on instance. So the same script attached to two different objects will behave independently of each other :)
User avatar
Reanan-Marie Olsen
 
Posts: 3386
Joined: Thu Mar 01, 2007 6:12 am

Post » Thu Apr 25, 2013 10:38 am

Each script on an object is it's on instance. So the same script attached to two different objects will behave independently of each other :smile:

Wonderful. Thanks!
User avatar
Bigze Stacks
 
Posts: 3309
Joined: Sun May 20, 2007 5:07 pm

Post » Thu Apr 25, 2013 6:53 am

And a few more questions, please....

1. For this same magicEffect, I presume that any variables I use in the script (not properties) will be destroyed with the object, presumably after onEffectFinish()?

2. If I want to store how information pertaining to different factions, like how many members of each faction I have killed, what is a good way of doing this in my script. I can make a formList of factions, but unless it is guaranteed never to change in size, I cannot make an array to match it in my script, as dynamic arrays are not supported.

3. Can another script be instantiated in a script? If I want to use a separate script as a simple data container, what is the best script object to inherit from, and can it be instantiated within the script itself? If it can be instantiated, how can it be destroyed - will setting to 'None' do so?

Thanks again.
User avatar
Hearts
 
Posts: 3306
Joined: Sat Oct 20, 2007 1:26 am


Return to V - Skyrim