papyrus global variables

Post » Tue Jun 19, 2012 3:19 am

Sorry, I can't get the global variable stuff.

Here is my script (from a coming skinning and others new skill system)
 Scriptname FRON_onDeath Extends Actor {This script fire in the on death event of animals, to check the skinning skill}import utilityimport GlobalVariablebool ranOnceint critical_failure = 5int failure = 13int success = 20int xp_gainedglobalVariable Property fron_skinning_experience autoEvent onActivate(ObjectReference akActionRef) if (ranOnce == FALSE)  int random = RandomInt(1,8)  random *= 2  if random <= critical_failure  ;echec critique   xp_gained = RandomInt(1,6)*2     debug.messageBox("Vous avez fait un échec critique. Vous avez gagné " + xp_gained as string + "xps.")  elseif random > critical_failure && random <= failure  ;echec   xp_gained = RandomInt(1,6)     debug.messageBox("Vous avez fait un échec. Vous avez gagné " + xp_gained as string + "xps.")  elseif random > failure && random <= success  ;réussite simple   xp_gained = RandomInt(1,6)     debug.messageBox("Vous avez fait une réussite. Vous avez gagné " + xp_gained as string + "xps.")     else  ;réussite critique    xp_gained = RandomInt(1,3)     debug.messageBox("Vous avez fait une réussite critique. Vous avez gagné " + xp_gained as string + "xps.")         endif    int tempSkinningLevel = fron_skinning_experience.getValueInt() debug.messageBox("experience actuelle en skinning est de "+ tempSkinningLevel as string) tempSkinningLevel = xp_gained + tempSkinningLevel debug.messageBox("experience totale avec le bonus de "+ xp_gained as string + "xp est de " + tempSkinningLevel as string ) fron_skinning_experience.setValueInt(tempSkinningLevel) debug.messageBox("Your new skinning level is " + fron_skinning_experience as string + " XPs.")      ranOnce = TRUE endifendEvent 
The above script compiles fine.
What I simply want is the skinning skill experience integer to be stored, so that it grows steadily as the player skins stuffs. And it will be a basis for me to create other stuffs of course...
User avatar
NIloufar Emporio
 
Posts: 3366
Joined: Tue Dec 19, 2006 6:18 pm

Post » Mon Jun 18, 2012 9:51 pm

You need to use a http://www.creationkit.com/Variables_and_Properties.

Add this to the top of your script:
GlobalVariable property MyGlobal auto 

(change MyGlobal to the global variable in question you intend to access)

Then, compile your script. In the CK, go to the object that this script is attached to. There, you can select Properties. Click the property name you defined in the script, select Edit, and select the Global Variable you want this property to "point" to. Your script should then be able to access the Global.
User avatar
Euan
 
Posts: 3376
Joined: Mon May 14, 2007 3:34 pm

Post » Mon Jun 18, 2012 6:57 pm

Dude, It WORKS. I have been trying for ages. Consider yourself my hero :-)
User avatar
Leanne Molloy
 
Posts: 3342
Joined: Sat Sep 02, 2006 1:09 am


Return to V - Skyrim

cron