[scripting] Clearing global variables every day?

Post » Fri Oct 04, 2013 8:35 am

I need help with a script. Here's what I need it to do.

1. It needs to run on a specific quest attached to my custom follower. I've added it in the script tab in the quest. Do I need to do anything else?

2. It needs to run once a day every day. Not sure how to do this?

3. Does it have to fire on an event? Can't it just always run?

Something like:

If (GameDaysPassed.GetValue() == 1)     ; clear the comment counter	     aaViconiaBanditComment.SetValue(0)EndIf

I'm REALLY bad with Skyrim scripting so please forgive me. Any help appreciated. I don't want to have to add this logic to every stage because I have 82 of them!

User avatar
JD bernal
 
Posts: 3450
Joined: Sun Sep 02, 2007 8:10 am

Post » Fri Oct 04, 2013 3:19 am

I think this would work:

Spoiler
GlobalVariable Property GameHour Auto ;Should be possible to auto-fillGlobalVariable Property myGlobalVariable Auto ;The globalvariable you want to resetFloat Property fValue Auto ;The value you want to reset toFloat Property fTargetTime Auto ;The time of day you want the reset to occur at (0.0-23.99)Event OnInit()	ScheduleUpdate()EndEventEvent OnUpdateGameTime()	myGlobalVariable.SetValue(fValue)	ScheduleUpdate()EndEventFunction ScheduleUpdate()	Float fTimeDifference = fTargetTime - GameHour.GetValue()	If(fTimeDifference > 0.0)		RegisterForSingleUpdateGameTime(fTimeDifference)	ElseIf(fTimeDifference == 0.0)		OnUpdateGameTime()	Else		RegisterForSingleUpdateGameTime((fTimeDifference + 24.0))	EndIfEndFunction

This should be able to handle the scenario where the player sleeps or waits, which causes the OnUpdateGameTime event to fire when the player stops sleeping or waiting instead of the time it was originally set to fire according to the value that was used to register for an OnUpdateGameTime event.

EDIT: Here's an array based version if you have a lot of global variables that you want to reset with one instance of the script.

Spoiler
GlobalVariable Property GameHour Auto ;Should be possible to auto-fillGlobalVariable[] Property myGlobalVariables Auto ;The globalvariables you want to resetFloat[] Property fValues Auto ;The values you want to reset toFloat Property fTargetTime Auto ;The time of day you want the reset to occur at (0.0-23.99)Event OnInit()	;Get the ball rolling	ScheduleUpdate()EndEventEvent OnUpdateGameTime()	Int i	While(i < myGlobalVariables.Length)		myGlobalVariables[i].SetValue(fValues[i])		i += 1	EndWhile	ScheduleUpdate()EndEventFunction ScheduleUpdate()	Float fTimeDifference = fTargetTime - fCurrentTime	If(fTimeDifference > 0.0)		RegisterForSingleUpdateGameTime(fTimeDifference)	ElseIf(fTimeDifference == 0.0)		OnUpdateGameTime()	Else		RegisterForSingleUpdateGameTime((fTimeDifference + 24.0))	EndIfEndFunction 
User avatar
Blessed DIVA
 
Posts: 3408
Joined: Thu Jul 13, 2006 12:09 am


Return to V - Skyrim