Passing Properties between scripts

Post » Wed Jun 20, 2012 9:58 pm

Ok I am having difficulty passing variables between my scripts and getting values that actually work that I can do something with. I am trying to pass values from my Quest Script to my Active Magic Effects script and while they both compile correctly I do not get any results that I expect. The Quest is configured correctly and is advancing as it should and I even get my debug message from the quest script that shows the script SHOULD be working that reads "Player Has Gained the Hasten Dead Bonus" but I'm not able to pass or recieve my property values from one script to the other. Currently my scripts look like this.


This is my Quest Script that should be assigning the variables and hopefully passing them along or at least be storing them so my other script can retrieve them. Ive tried playing around with Globalvariable instead of Int but that didn't seem to be of any help unless I just did it incorrectly.
Scriptname PsiNecromancyQuestScript extends Quest  Int Property PsiUpkeepcharge  autoInt Property PsiHasHastenDead autoInt Property PsiHastenDeadHealthBonus autoQuest Property PsiNecromancyQuest AutoFloat CheckonceAEvent OnInit()	PsiUpkeepcharge = 30	while PsiNecromancyQuest.Getstage() < 10000			  If PsiNecromancyQuest.GetStage() == 150			If CheckonceA == 0				PsiHasHastenDead = 1								   PsiHastenDeadHealthBonus = 40				Debug.Messagebox("Player Has Gained the Hasten Dead Bonus")		   		 CheckonceA = 1.0			Endif		Endif	EndWhileEndEvent

Trying to retrieve my Quest Properties into my Active Magic Effects Script here.. But not having any luck
Scriptname PsiSummonScript extends activemagiceffect  PsiNecromancyQuestScript Property PsiNecromancyQuest Autofloat Checkonce1Event OnEffectStart(Actor Target, Actor Caster)	if Checkonce1 == 0		Game.GetPlayer().ModActorValue("Magicka", - PsiNecromancyQuest.PsiUpkeepcharge)		Checkonce1 = 1.0			Debug.Messagebox("Player Charged Magicka Upkeep!")		if PsiNecromancyQuest.PsiHasHastenDead == 1			Target.ModAv("Health", PsiNecromancyQuest.PsiHastenDeadHealthBonus)				Debug.Messagebox("The Summon Has been buffed!")		Endif	EndifEndEventEvent OnEffectFinish(Actor Target, Actor Caster)	Game.GetPlayer().ModActorValue("Magicka", PsiNecromancyQuest.PsiUpkeepcharge)	Checkonce1 = 0		   Debug.Messagebox("Player No longer Charged Magicka Upkeep!")		if PsiNecromancyQuest.PsiHasHastenDead == 1			Target.ModAv("Health", - PsiNecromancyQuest.PsiHastenDeadHealthBonus)		EndifEndEvent

So I'm guessing either what I want to do is not possible or obviously there is something here I'm just not getting right. Would greatly appreciate some help!

--[[User:PsiSoldier|PsiSoldier]] 21:02, 21 April 2012 (EDT)
User avatar
Alyna
 
Posts: 3412
Joined: Wed Aug 30, 2006 4:54 am

Post » Wed Jun 20, 2012 8:29 pm

Did you set the "PsiNecromancyQuest" property in your active magic effect script?
User avatar
Cassie Boyle
 
Posts: 3468
Joined: Sun Nov 05, 2006 9:33 am

Post » Thu Jun 21, 2012 12:16 am

@ PSI, Aha, you did create a thread :)
(I just responded on the http://www.creationkit.com/Talk:Variables_and_Properties#Getting_Properties_From_Any_Other_Script.)

As I said there, I think the problem is that the OnInit() block is not completing, and thus blocking other scripts from accessing the properties.

I can't remember where I picked up the habit, but I keep initialisation blocks minimal. Just set flags, variables, register for events etc, then get out.
The continuously endless while loop would be better suited to an OnUpdate block, with a condition that ends when it no longer needs to poll.
See how to use RegisterForSingleUpdate() this way in the Notes of the http://www.creationkit.com/OnUpdate_-_Form() page.
User avatar
Nitol Ahmed
 
Posts: 3321
Joined: Thu May 03, 2007 7:35 am

Post » Wed Jun 20, 2012 10:58 pm

you may also want to consider not naming your quest script property the same as your quest. i know it seems like it shouldn't matter, but the CK can be finnicky about property naming, especially when the name matches an editor ID of something else
User avatar
michael flanigan
 
Posts: 3449
Joined: Thu Jun 14, 2007 2:33 pm

Post » Wed Jun 20, 2012 7:08 pm

Ok this is odd Ive changed the Quest script to register for updates and now most things seem to be working, I get all my debug messages and it is subtracting the 30 Magicka from the player for upkeep and giving it back when the summon dies but it is not applying the Health buff to my summoned Skeleton. I'm hoping it's just a simple problem with my code for modding the Actor Value for my summon. Maybe I need to put a script on the Summoned creatures themselves to mod their values?

I suppose now that I'm registering for updates I can get rid of my while statement and only use If statements and that might help things too. But i'll do that in a bit. Either way I don't think thats my problem right this second.

Anyways here is my new code for the Questscript that appears to be working. I may go back in a bit and rename the Quest Script something a little different like Amethyst suggested but its all working except modding my summons AVs like it is supposed to be.

Thanks for the help all! Now I feel like I'm making better progress for sure!

Scriptname PsiNecromancyQuestScript extends Quest  Int Property PsiUpkeepcharge  autoInt Property PsiHasHastenDead autoInt Property PsiHastenDeadHealthBonus autoQuest Property PsiNecromancyQuest AutoFloat CheckonceAEvent OnInit()	RegisterForUpdate(5)	Debug.Messagebox("Registered")EndEventEvent Onupdate()	PsiUpkeepcharge = 30	while PsiNecromancyQuest.Getstage() < 10000		   If PsiNecromancyQuest.GetStage() == 150			If CheckonceA == 0				PsiHasHastenDead = 1						  PsiHastenDeadHealthBonus = 40				Debug.Messagebox("Player Has Gained the Hasten Dead Bonus")		   	   CheckonceA = 1.0			Endif		Endif	EndWhile	UnregisterForUpdate()  ; when we're done with it, make sure to unregister	Debug.Trace("Got what we needed, so stop polling!")EndEvent 
User avatar
Kelvin Diaz
 
Posts: 3214
Joined: Mon May 14, 2007 5:16 pm

Post » Wed Jun 20, 2012 7:44 pm

Well I have everything working except for the Health buff for the Summoned Mob. If anyone can help me out with why my script to Mod the Actor value isn't working I'd appreciate it.. I dont know if it works to just to do

						Target.ModAv("Health", PsiNecromancyQuest.PsiHastenDeadHealthBonus)

or if I need to setup an alias and run it that way. or if it just should be something other than Target. Ive tried both ModAv and ModActorValue and neither work. Ive also tried just putting a plain number in place of PsiNecromancyQuest.PsiHastenDeadHealthBonus But that didn't work either. So I'm guessing that it is some sort of problem with my syntax not pointing correctly to my summoned mob.

Would it make a difference to create a script for the actual Summoned Actor itself and put the ModAV on that script? Ive tried playing around with

if (Game.GetPlayer().HasPerk(PsiHastenDead))


But it didnt work, But then again I was inside an ActiveMagicEffect script and not an Actor script so I'm sure that was why it wasn't working for me then, That was before I understood you could only call certain functions from certain types of scripts. But Ive only been playing around with the creation kit for a few days now anyways so I'm still learning...

Anyways I'd appreciate any help!
User avatar
Calum Campbell
 
Posts: 3574
Joined: Tue Jul 10, 2007 7:55 am


Return to V - Skyrim