How to get an integer variable from another script?

Post » Mon Jun 29, 2015 7:39 pm

I've tried reading CK Wiki but I can't make head nor tail of it..

can someone explain to me in simple terms how to get an integer variable value from a vanilla script?

Basically its like this

ScriptName VanillaScriptA extends Quest conditional

Int property ValueA = 1 Auto Hidden

;

; end of script

ScriptName MyScriptB extends Quest

; get Int ValueA from VanillaScriptA

; do stuff with it

I've tried every example in the wiki but nothing works, can someone give me a working example of how to do this? From what I understand it should be simple but nothing in the http://www.creationkit.com/Variables_and_Properties will compile and I've no idea why. Its driving me nuts. :confused:

User avatar
Breanna Van Dijk
 
Posts: 3384
Joined: Mon Mar 12, 2007 2:18 pm

Post » Mon Jun 29, 2015 6:42 pm

Hi Blackjack Davy,

Variables within scripts can't be accessed externally, but functions and properties can. In order for the compiler to realise that the function or property exists, you need to specify that you're looking at the object with the script attached as the type defined in its script. So in this case, that would look something like this:

VanillaScriptA Property QuestWithVar Auto; ...QuestWithVar.ValueA
If you're getting access to that object by returning it as a less specific type, like Quest, then you'll need to cast it to the correct type first:

Quest MyQuest; Fill MyQuest variable somehowVanillaScriptA QuestWithVar = MyQuest as VanillaScriptA; ...QuestWithVar.ValueA
I wrote a tutorial about accessing properties and functions externally some time ago, if that would also be helpful: http://cipscis.com/skyrim/tutorials/externalaccess.aspx

Cipscis
User avatar
Dagan Wilkin
 
Posts: 3352
Joined: Fri Apr 27, 2007 4:20 am

Post » Mon Jun 29, 2015 2:09 pm

Hi :smile:

Yes I understand the first part of that, but the as statement indicates a Cast Reference and thats not something I can grasp either. lol.

Yes thank you I've had a read through of that multiple times already. :wink:

Ok I tried both examples but neither would compile

no viable alternative at input 'MyQuest'

required (...)+ loop did not match anything at input 'as'

Unknown user flag MyQuest

:(

User avatar
Jamie Moysey
 
Posts: 3452
Joined: Sun May 13, 2007 6:31 am

Post » Mon Jun 29, 2015 3:46 pm

It helps when you post the exact scripts you have :smile:.

So for example... if this is your first script:

Scriptname VanillaScriptA extends Questint Property ValueA = 1 Auto Hidden

Your second script would be something like:

Scriptname MyScriptB extends QuestVanillaScriptA Property kQuest AutoFunction SomeFunction()    int iValue = http://forums.bethsoft.com/topic/1524760-how-to-get-an-integer-variable-from-another-script/kQuest.ValueA    ;do stuffendFunction

We make a property to your first script, which I named "kQuest". You can name it whatever you want though, as long as it makes sense to you. Properties are then dot operator "."

User avatar
Syaza Ramali
 
Posts: 3466
Joined: Wed Jan 24, 2007 10:46 am

Post » Mon Jun 29, 2015 8:35 am

Sorry, that's because complex initialisation (anything more complex than passing in a literal value when initialising a variable) can only happen inside functions. So if the VanillaScriptA QuestWithVar = MyQuest as VanillaScriptA line is inside a function or an event like http://www.creationkit.com/OnInit then it should work.

Cipscis
User avatar
Naazhe Perezz
 
Posts: 3393
Joined: Sat Aug 19, 2006 6:14 am


Return to V - Skyrim