How to Get Globals?

Post » Sun Jun 17, 2012 1:20 pm

Can someone please help me out here, because I am really not with it tonight, it seems...

How do I call a Global Variable?


I tried this (the example from the wiki)
int timeOfDay = TimeOfDayGlobalProperty.GetValue()

And I got a message about type mis-match errors, and TimeofDayGlobalProperty being undefined.

What I want to do is check the GameHour setting...

Thanks for any help.
User avatar
Laura-Jayne Lee
 
Posts: 3474
Joined: Sun Jul 02, 2006 4:35 pm

Post » Sun Jun 17, 2012 1:40 pm

Globals are proper forms now, available in the object tree, and forms can no longer be accessed directly by editorID in scripts. Instead, you'll need to make a Global type property, and assign its value to the global you want to access.

If I remember correctly, naming your global the same as the form you want to assign to it will result in that form being assigned as its value by default.

Cipscis
User avatar
Katie Pollard
 
Posts: 3460
Joined: Thu Nov 09, 2006 11:23 pm

Post » Mon Jun 18, 2012 1:35 am

Globals are proper forms now, available in the object tree, and forms can no longer be accessed directly by editorID in scripts. Instead, you'll need to make a Global type property, and assign its value to the global you want to access.

If I remember correctly, naming your global the same as the form you want to assign to it will result in that form being assigned as its value by default.

Cipscis

Thank-you for the response.

I think I understand what you are saying-- but is there any chance you would be able to demonstrate an example of what I would need to write to get this to work?
I am with you at the start that Globals are forms-- I can see them fine-- but i lose you about Global Type Properties...

Thanks again for any help :)
User avatar
Elina
 
Posts: 3411
Joined: Wed Jun 21, 2006 10:09 pm

Post » Mon Jun 18, 2012 2:13 am

Something like this, in your script:
Global property MyGlobalName auto...myVar = MyGlobalName.GetValue()

Cipscis
User avatar
bimsy
 
Posts: 3541
Joined: Wed Oct 11, 2006 3:04 pm

Post » Sun Jun 17, 2012 3:34 pm

Thank-you :)
User avatar
Krista Belle Davis
 
Posts: 3405
Joined: Tue Aug 22, 2006 3:00 am

Post » Mon Jun 18, 2012 1:22 am

*coughs*

if TimeOfDay >= 06.00 && <= 00.00
CDMVampireRef.DamageHealth()
endif

Did I get that right? :wink:

Alternatively, BurnToDust()
User avatar
how solid
 
Posts: 3434
Joined: Mon Apr 23, 2007 5:27 am

Post » Mon Jun 18, 2012 2:51 am

Not quite - you'll need to change that first line to something like this:
if TimeOfDay >= 6 && TimeOfDay <= 0
The rest is probable fine.

P.S. Please use code tags when posting code. Like this, but with square brackets instead of curly ones:{code}Code goes here{/code}

Cipscis
User avatar
Tracy Byworth
 
Posts: 3403
Joined: Sun Jul 02, 2006 10:09 pm

Post » Sun Jun 17, 2012 9:16 pm

*coughs*

if TimeOfDay >= 06.00 && <= 00.00
CDMVampireRef.DamageHealth()
endif

Did I get that right? :wink:

Alternatively, BurnToDust()

You're definitely on the track of what I am thinking ;)

Although I am going to have to leave it for tonight... my head is just not with it, it seems :/ I've been here an hour, and not even figured out the basis :(
User avatar
Terry
 
Posts: 3368
Joined: Mon Jul 09, 2007 1:21 am

Post » Sun Jun 17, 2012 11:52 pm

Can someone please help me out here, because I am really not with it tonight, it seems...

How do I call a Global Variable?


I tried this (the example from the wiki)
int timeOfDay = TimeOfDayGlobalProperty.GetValue()

And I got a message about type mis-match errors, and TimeofDayGlobalProperty being undefined.

What I want to do is check the GameHour setting...

Thanks for any help.

you sure time is an integer value ? thats why it is type mis-match
User avatar
XPidgex Jefferson
 
Posts: 3398
Joined: Fri Sep 08, 2006 4:39 pm

Post » Sun Jun 17, 2012 8:18 pm

you sure time is an integer value ? thats why it is type mis-match

I thought that, but that's the example from the page; but I think I am just misunderstanding it, anyway... :S
User avatar
Nicole Coucopoulos
 
Posts: 3484
Joined: Fri Feb 23, 2007 4:09 am

Post » Sun Jun 17, 2012 9:29 pm

maybe try

DateTime TimeOfDay = TimeOfDayGlobalProperty.Getvalue();orTimeOfDay = new  TimeOfDayGlobalProperty;TimeOfDay = TimeOfDayGlobalProperty.Getvalue();
User avatar
Myles
 
Posts: 3341
Joined: Sun Oct 21, 2007 12:52 pm

Post » Sun Jun 17, 2012 10:31 am

DateTime isn't a valid default type, and there "new" keyword is used for arrays.

I recommend taking a look at the wiki's http://www.creationkit.com/Category:Papyrus. There's some really good stuff in there already.

Cipscis
User avatar
Setal Vara
 
Posts: 3390
Joined: Thu Nov 16, 2006 1:24 pm

Post » Sun Jun 17, 2012 11:24 am

you sure time is an integer value ? thats why it is type mis-match
A developer just fixed this on the wiki. Perhaps they were watching ;)

Cipscis
User avatar
M!KkI
 
Posts: 3401
Joined: Sun Jul 16, 2006 7:50 am

Post » Sun Jun 17, 2012 4:12 pm

I thought that, but that's the example from the page; but I think I am just misunderstanding it, anyway... :S

Unfortunately the wiki page example had a small bug – the http://www.creationkit.com/GetValue_-_GlobalVariable function returns a float, not an int (You can see that in the “Syntax” part of the page). I’ve gone ahead and fixed up the wiki page example already, but what you’ll want is the following:

float timeOfDay = TimeOfDayGlobalProperty.GetValue()

If you really want an integer and don’t mind losing the floating-point part of the global variable (probably not the best idea with time of day, but you might want it for something else), you can either cast the result to an int, or use the http://www.creationkit.com/GetValueInt_-_GlobalVariable function instead – both of which trim the value of the global to the nearest whole number.

; Castingint myGlobalValue = http://forums.bethsoft.com/topic/1343528-how-to-get-globals/MyGlobal.GetValue() as int; GetValueIntInt myGlobalValue2 = MyGlobal.GetValueInt()

Also, for ease of use, you can use the http://www.creationkit.com/GlobalVariable_Script#Properties on globals to get or set the floating point value with less typing:

float timeOfDay = TimeOfDayGlobalProperty.value

Note that all of the above examples assume you’ve pointed the property at the correct global in the editor wherever you’ve attached the script.

A developer just fixed this on the wiki. Perhaps they were watching :wink:

Cipscis
:ninja:
User avatar
Kevin S
 
Posts: 3457
Joined: Sat Aug 11, 2007 12:50 pm

Post » Sun Jun 17, 2012 7:34 pm

A developer just fixed this on the wiki. Perhaps they were watching :wink:
Cipscis

Look like single values are stored in int or float, boolen for true and false and thats all there is :P
Dunno about arrays need to browse some more :run:
User avatar
Chavala
 
Posts: 3355
Joined: Sun Jun 25, 2006 5:28 am


Return to V - Skyrim