Duplicated Property Question, Simple Spell Script

Post » Mon Aug 19, 2013 9:53 pm

So I was messing around with a simple script, and I got a result I was not expecting:

Here is the script

Spoiler

Scriptname PLZWORK extends ActiveMagicEffect  {test spell for scripts}Int Property OMZstage AutoEvent OnEffectStart(actor akTarget, actor akCaster)OMZstage = 0Debug.notification("Spell Started. " + OMZstage)RegisterForSingleUpdate(1.0)endEventEvent OnUpdate()OMZstage += 1Debug.notification("Spell Updated. " + OMZstage)RegisterForSingleUpdate(1.0)endEventEvent OnEffectFinish(actor akTarget, actor akCaster)Debug.notification("Spell Finished. " + OMZstage)endEvent 

The script is attached to two separate magic effects on two similar but slightly different concentration spells. I gave myself both spells and started shooting them at a target. I was expecting both spells to increment the same property OMZstage. Instead, when staggering the use of the two spells, I got output like this:

Spell Started. 0

Spell Updated. 1

Spell Updated. 2

Spell Updated. 3

Spell Started. 0

Spell Updated. 4

Spell Updated. 1

Spell Updated. 5

Spell Updated. 2

Spell Updated. 6

Spell Finished. 6

Spell Updated. 3

Spell Updated. 4

Spell Finished. 4

So it looks to me like my property was duplicated. Does this mean that if I have another script that uses the OMZstage property, I will read both values and write to both properties?

Edit: Hmmm, I guess I could check by making a custom scripted shout and using it while running both spells... I feel like this may crash the game though...

User avatar
Anna Kyselova
 
Posts: 3431
Joined: Sun Apr 01, 2007 9:42 am

Post » Mon Aug 19, 2013 8:50 am

Each ActiveMagicEffect script is unique and has its own variables/properties. You can use a GlobalVariable instead if you need to reference the same number.

http://www.creationkit.com/Global

http://www.creationkit.com/GlobalVariable_Script

Use the Mod(float afHowMuch) function to increment the global.

User avatar
Josh Dagreat
 
Posts: 3438
Joined: Fri Oct 19, 2007 3:07 am

Post » Mon Aug 19, 2013 10:16 pm

Hmm, just to make sure I understand, is this a characteristic of activemagiceffect scripts that might not apply to other types? I'm confused because I thought the main difference between properties and variables was that other scripts could read and write into properties, but not into variables, from other scripts.

Also, thanks for the links for global variables, I didn't know about those. Can I create my own global variable or do I need to use the default ones?

User avatar
Tarka
 
Posts: 3430
Joined: Sun Jun 10, 2007 9:22 pm


Return to V - Skyrim