cromcrom Posted February 14, 2012 Share Posted February 14, 2012 Hi all, I am in the process of adding some new skills to skyrim. I am currently working on all the basics of the system, learning papyrus as I go.I am doing fine, but I have a global variable problem. How can I store a variable overall ? I want to keep trace of the skinning experience of the player, so I tried this:Scriptname FRON_onDeath Extends Actor {This script fire in the on death event of animals, to check the skinning skill} import utility bool ranOnce int critical_failure = 5 int failure = 13 int success = 20 int xp_gained Int Property fron_skill_skinning Auto {This is the total number of skill points} Event 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 fron_skill_skinning += xp_gained debug.messageBox("Your new skinning level is " + fron_skill_skinning as string + " XPs.") ranOnce = TRUE endif endEvent but it does not store the fron_skill_skinning as I thought it would. I have an other question:According to you, what would be the best way to show the players skills ? I thought that maybe a weightless undroppable "skill book" could do, what do you think ? Thanks in advance. Link to comment Share on other sites More sharing options...
Cipscis Posted February 14, 2012 Share Posted February 14, 2012 For a global variable, I might suggest making a new GlobalVariable form. Cipscis Link to comment Share on other sites More sharing options...
Darkvalkyr Posted February 14, 2012 Share Posted February 14, 2012 fron_skill_skinning += xp_gained debug.messageBox("Your new skinning level is " + fron_skill_skinning as string + " XPs.") I think it might be because you said fron_skill_skinning as string might be the problem. Is fron_skill_skinning a Global variable? I see it's defined as an intiger property here. If it isn't a global variable, I don't think you can write that int into messagebox. You need to make a GlobalVar, then give it that property. Gotta go, I'll be right back to edit this further. Link to comment Share on other sites More sharing options...
cromcrom Posted February 15, 2012 Author Share Posted February 15, 2012 (edited) TX for answers.I am a self taught scripter, and beginner, so please, be as precise as possible, I would love snippets of code actually :-)Everything (well, not much really, but long stories start with a word :-) ) works as intended, except that the various "xp gains" from multiple onActivate do not stack together.You need to make a GlobalVar, then give it that property. I read about these "SetValueInt" and "GetValueInt" in the globalVariable subject on the wiki, but I very simply don't know how to us them in this matter .How to do this please ? Edited February 15, 2012 by cromcrom Link to comment Share on other sites More sharing options...
Darkvalkyr Posted February 15, 2012 Share Posted February 15, 2012 Alright, I got a bit of time so lemme see if I can come with an answer on how I did it. :) First, you need to create a GlobalVariable in the Global list in the Object box. (EG. CharacterHealthGlobal)Then, in your quest, you need to add text allowance. This is done in the Quest Data tab on the lower right box, add your GlobalVariable.Then in the script of the quest, you need to define a GlobalVariable property pointing to that GlobalVariable:eg:GlobalVariable Property CharacterHealthGlobalProperty auto make sure it points to your CharacterHealthGlobal. Then in the script when you want it to store the value...say in this example you want the script to take an actor's health, and get it into the GlobalVariable and then display it in a message box DisplayHealth (which should be linked to the quest as well): GlobalVariable Property CharacterHealthGlobalProperty Auto Message Property DisplayHealth Auto int CurrentHealth Function GetCharacterHealth (Actor TargetActor) CurrentHealth = TargetActor.GetAV("Health") as int CharacterHealthGlobalProperty.SetValueInt(CurrentHealth) UpdateCurrentInstanceGlobal(CharacterHealthGlobalProperty) DisplayHealth.Show() And in DisplayHealth, it should be:Character Health = <Global=CharacterHealthGlobal> That SHOULD do it when you call your function. I am NOT entirely sure if this will work without issue, but I had this in my script and it worked. UpdateCurrentInstanceGlobal should be done every time after you use a .SetValueInt for a Global Variable's property. Hope this works! Cheers,DV Link to comment Share on other sites More sharing options...
cromcrom Posted February 15, 2012 Author Share Posted February 15, 2012 Whether it works or not, thanks a lot for your time.I will give it a try, although I am amazed at how complicated it eems to create a Global variable, whereas in other languages, it only requires a sign or letter to define such a variable... TX anyways, I will give a try to this :-) Link to comment Share on other sites More sharing options...
Darkvalkyr Posted February 15, 2012 Share Posted February 15, 2012 Using a Global Variable in a message's the hard part. Whenever you want to replace text with a Global Variable, it's pretty frustrating. :/ Link to comment Share on other sites More sharing options...
cromcrom Posted February 15, 2012 Author Share Posted February 15, 2012 (edited) Is it because it turns the int into a string ? I tried for hours the global variable stuff, that there is no simple way to define and use global variables beside the quest bullshits makes me really sick.... Edited February 15, 2012 by cromcrom Link to comment Share on other sites More sharing options...
Darkvalkyr Posted February 15, 2012 Share Posted February 15, 2012 (edited) From what I understand, debug messages don't register Global Variable inputs like Message Boxes. I don't know for certain though. Sorry it's giving you a hard time. :< When trying to understand Global Variables, the quest FreeFormRiften04 has been invaluable though - it uses text replacement for Global Variables, so if you look at that you might get some idea. I find looking at quests already in the game to tell me quite handy. Edited February 15, 2012 by Darkvalkyr Link to comment Share on other sites More sharing options...
Recommended Posts