Using Global Variable for a smitting condition

Post » Wed Jun 29, 2016 9:05 pm

Hi everyone,



My videocard has crashed so I am taking the time off to work on a mod...I'll be back in Skyrim in August (why not earlier...don't ask)



Ok I would like the player to be able to craft a given sword only if he has the perk and he/she has red a recipe of the given sword. So as some of you suggested already I am using a global variable as well as a on activate event.


Basically the sript below will be attached to a piece of parchment where the crafting formula is written. Then that will set the Global Variable to (let's say 1) and in the crafting condition I would be able to add a condition, this global varibale set to 1.


My only problem is tha I am not familiar woth papyrus so I need you to tell me if I am right or wrong:



MAAtmorianswordGV is my Global Variable (will probably make is a SHORT


Upon reading/activating the parchment the player will get a message


I am assuming that the default values of the global variable is 0 (not sure I am right tell me...)



Scriptname MAAtmorianSwordRecipeScript extends ObjectReference


Event OnActivate(ObjectReference akActionRef)

GlobalVariable Property MAAtmorianSwordGV auto; access the global variable MAAtmorianSwordGV
MAAtmorianSwordGV.SetValue(1); set the global variable MAAtmorianSwordGV to 1
Debug.MessageBox("I've learn how to forge a Replica of the Royal Atmorian Sword. I can forge it if I already own the steel Perk")

EndEvent

So will this script works?



Thanks for your help


User avatar
Marnesia Steele
 
Posts: 3398
Joined: Thu Aug 09, 2007 10:11 pm

Post » Wed Jun 29, 2016 8:11 pm

Assuming your recipe is sitting in the game world where the player can pick it up that should work. If it's in a container somewhere the player would have to drop it then pick it up again. (If it does start in a container there's the OnContainerChanged event you can use.)

User avatar
mollypop
 
Posts: 3420
Joined: Fri Jan 05, 2007 1:47 am

Post » Thu Jun 30, 2016 3:36 am

You need to define properties outside of your functions/events, and then make sure to fill them with the CK. The default global value should also be settable by the CK. Also, I'd recommend using an actual message than a debug function, but that's not too big of a deal...

User avatar
Rude Gurl
 
Posts: 3425
Joined: Wed Aug 08, 2007 9:17 am

Post » Wed Jun 29, 2016 2:52 pm

Thanks a lot guys



As usual really helpful



Here is the corrected script. In order to use an actual message and not a debug function, should I use the following:


I've learn how to forge a Replica etc.Show () ?



Scriptname MAAtmorianSwordRecipeScript extends ObjectReference
GlobalVariable Property MAAtmorianSwordGV auto; access the global variable MAAtmorianSwordGV
Event OnActivate(ObjectReference akActionRef)
MAAtmorianSwordGV.SetValue(1); set the global variable MAAtmorianSwordGV to 1
Debug.MessageBox("I've learn how to forge a Replica of the Royal Atmorian Sword. I can forge it if I already own the steel Perk")
EndEvent

Thanks again

User avatar
Izzy Coleman
 
Posts: 3336
Joined: Tue Jun 20, 2006 3:34 am

Post » Thu Jun 30, 2016 12:55 am

Yes, to use a proper message instead of the debug you just need to create the message in the CK. Add a property for it in the script (Message Property MAAtmorianSwordMSGBX Auto), fill it in the CK, and call it with "MAAtmorianSwordMSGBX.Show()".

User avatar
Jessie Rae Brouillette
 
Posts: 3469
Joined: Mon Dec 11, 2006 9:50 am

Post » Thu Jun 30, 2016 3:51 am

Ok that's clear thanks



Thank you all



I love this board...

User avatar
suniti
 
Posts: 3176
Joined: Mon Sep 25, 2006 4:22 pm


Return to V - Skyrim