Papyrus - How to set globals?

Post » Mon Jun 18, 2012 2:03 am

Can anyone give me a hint on how to manipulate globals from within a Papyrus script?

I tried the set command that I think usually works in game, but it wont work in Papyrus.

Event OnEquipped(Actor akActor)  if akActor == Game.GetPlayer()	set myGlobal to xxx  endIfendEvent

This throws up compile errors.
User avatar
Benjamin Holz
 
Posts: 3408
Joined: Fri Oct 19, 2007 9:34 pm

Post » Mon Jun 18, 2012 12:57 am

You have to set the Global as a property, then manipulate its value through there.

http://www.creationkit.com/GlobalVariable_Script
User avatar
Nathan Risch
 
Posts: 3313
Joined: Sun Aug 05, 2007 10:15 pm

Post » Mon Jun 18, 2012 4:41 am

You have to add a property with the type GlobalVariable and set that to the global you wish to set.

A shortcut for this is adding a property with the editor ID of the global and using auto fill.
User avatar
Eliza Potter
 
Posts: 3481
Joined: Mon Mar 05, 2007 3:20 am

Post » Sun Jun 17, 2012 4:44 pm

http://www.creationkit.com/Category:Papyrus

There's a lot of stuff that's changed in the scripting language this time around. Off course, I'm still wrapping my head around it myself, but of important note is that you don't use

Set  to 

instead, the syntax is

 = 
User avatar
Mandy Muir
 
Posts: 3307
Joined: Wed Jan 24, 2007 4:38 pm

Post » Sun Jun 17, 2012 2:46 pm

Still having trouble. How do I add Global Properties via the propertys window?

When I try to add one, with a name of
myVar and a value of fCombatMagickaRegenRateMult

It throws up compile errors.
The AutoFill option doesnt become enabled, and I am unsure how to reference the global setting without getting this step to work.

Anyone got an example?
User avatar
Lovingly
 
Posts: 3414
Joined: Fri Sep 15, 2006 6:36 am

Post » Sun Jun 17, 2012 6:35 pm

Looks like GlobalVariable is wrong data type?

I finally got it working so I can use the dropdown, but its not showing fCombatMagickaRegenRateMult

So...
Anyone know how to programatically alter settings?
fCombatMagickaRegenRateMult being the regen rate of magicka in combat.
User avatar
Mike Plumley
 
Posts: 3392
Joined: Wed Sep 05, 2007 10:45 pm

Post » Sun Jun 17, 2012 3:37 pm

You're correct; fCombatMagickaRegenRateMult is a game setting not a global.

You can set it with http://www.creationkit.com/SetINIFloat_-_Utility.
User avatar
Tamika Jett
 
Posts: 3301
Joined: Wed Jun 06, 2007 3:44 am

Post » Sun Jun 17, 2012 8:54 pm

Thank you.
I wouldnt have thought about calling it an INI Setting. Lol
User avatar
Dan Endacott
 
Posts: 3419
Joined: Fri Jul 06, 2007 9:12 am

Post » Sun Jun 17, 2012 3:11 pm

I wouldnt have thought about calling it an INI Setting. Lol
I shouldn't have either... (It doesn't work, does it?)

Try declaring it as a float property instead.
User avatar
Laura-Jayne Lee
 
Posts: 3474
Joined: Sun Jul 02, 2006 4:35 pm

Post » Sun Jun 17, 2012 5:57 pm

Posting your script would help people here figure out what is wrong, but in general, the type of the property for a global variable should be “GlobalVariable”, so it sounds like you have that set up correctly. The “initial value” is only used for things like integers or booleans, so you’ll want to leave that blank. If you want the editor to auto-fill the property for you, then the name of the property needs to match the name of the form you’re interested in, and the form needs to be the right type. Again, going back to your example, if there is a global variable in the editor named “fCombatMagickaRegenRateMult” then you need to make a “GlobalVariable” property with a name of “fCombatMagickaRegenRateMult”, which will look like the following in your script:

GlobalVariable Property fCombatMagickaRegenRateMult auto

Then, once you attach the script to something and go into the properties window, it should auto-fill the property with the desired global variable.
User avatar
JR Cash
 
Posts: 3441
Joined: Tue Oct 02, 2007 12:59 pm


Return to V - Skyrim