Access global variable in a script...

Post » Thu Jun 21, 2012 12:04 pm

This is probably a simple syntax thing but I can't find a definitive answer on the wiki.

I have an ObjectReference script and I want it to be able to access a global variable I have defined.

I read that you must use variablename.GetValue() however the CK refuses to compile.

I am still somewhat confused about when I need to define things as Properties.

The example for the above accessing of a global within a script didn't mention you had to declare it as a property or the correct syntax for doing so, but I am assuming that is why it refuses to work.
User avatar
Isabel Ruiz
 
Posts: 3447
Joined: Sat Nov 04, 2006 4:39 am

Post » Thu Jun 21, 2012 10:11 am

You need to declare the variable as a global variable.

GlobalVariable Property MyVar Auto

Then use:

MyVar.Getvalue()

And as far as i know you cannot transfer a ObjectReference that way.

However you can in a quest script property:

MyQuest Property myQuestRef auto
actor CombatTarget

CombatTarget = "what ever way you want"


Then other scripts can get the REF using :

actor CombatTarget

actor CombatTarget = myQuestRef.CombatTarget


Sorry for the gaps in my description but I have done this ONCE and it did not always work (I think because of how the combat actor ref would change and the god dam script lag issues). Anyway I gave up on this and went a different way, but I have wanted to revisit this.

Maybe someone else can explain it better off the top of their head.

This is probably a simple syntax thing but I can't find a definitive answer on the wiki.

I have an ObjectReference script and I want it to be able to access a global variable I have defined.

I read that you must use variablename.GetValue() however the CK refuses to compile.

I am still somewhat confused about when I need to define things as Properties.

The example for the above accessing of a global within a script didn't mention you had to declare it as a property or the correct syntax for doing so, but I am assuming that is why it refuses to work.
User avatar
Catharine Krupinski
 
Posts: 3377
Joined: Sun Aug 12, 2007 3:39 pm

Post » Thu Jun 21, 2012 6:30 pm

Thanks friend.

I see what I was doing wrong now. Total noob mistake! I had defined GlobalVariable Property phiRespawnDay auto at the start of my script, and was trying to do float respawn = phiRespawnDay.GetValue() later in an Event block.

That is all fine, and how it works now. The noob mistake, was that I ALSO defined float respawn at the top, not realizing the declaration within the Event block WAS defining the variable respawn as it was set. So the redundancy was confusing the CK and it wouldn't compile.

The more you know! =P
User avatar
мistrєss
 
Posts: 3168
Joined: Thu Dec 14, 2006 3:13 am


Return to V - Skyrim