Jump to content

Help needed for problem with a timer script.


Recommended Posts

SOLVED.

 

 

I have scripted a timer it works 9 out of 10 times but every now and then it hits the problem and never ends.

Does anyone know how to fix it ?

 

 

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname TIF__062E8C48 Extends TopicInfo Hidden

;BEGIN FRAGMENT Fragment_0
Function Fragment_0(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor

 

;BEGIN CODE
TWMHGHStage.SetValueInt( 2 )
OldTime = Utility.GetCurrentGameTime()
RegisterForUpdateGameTime(12.0) ; Before we can use onUpdateGameTime() we must register.
;Debug.Notification("Wait started....")

;END CODE

 

EndFunction
;END FRAGMENT

 

Event OnUpdateGameTime() ;because of how we registered, this event occurs every 12 hour of game time

If TWMHGHStage.GetValueInt() == 2
NewTime = Utility.GetCurrentGameTime()

 

If newtime > oldtime + 2 ; Wait for 2 days
TWMHGHStage.SetValueInt( 3 )
;Debug.Notification("Wait endded.")
UnregisterForUpdateGameTime() ; when we're done with it, make sure to unregister

 

Else
;Debug.Notification("Still waiting.")
RegisterForUpdateGameTime(12.0) ; Before we can use onUpdateGameTime() we must register.

 

Endif
Else
;Should never get here but.... just in case
UnregisterForUpdateGameTime() ; when we're done with it, make sure to unregister

 

EndIf
EndEvent

 

MiscObject Property Gold001 Auto

 

GlobalVariable Property TWMHGHStage Auto

 

Quest Property TWMHQ02 Auto

 

Float Property OldTime = 0.0 Auto
Float Property NewTime = 0.0 Auto

 

 

Edited by The-Wanderer
Link to comment
Share on other sites

I have change the script as follows, but still it does not work???

 

 

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 2
Scriptname TIF__062E8C48 Extends TopicInfo Hidden

 

;BEGIN FRAGMENT Fragment_1
Function Fragment_1(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor

;BEGIN CODE
TWMHGHStage.SetValueInt( 2 )
registerForSingleUpdateGameTime(24.0) ; *2) removed to reduce test time

Debug.Notification("Wait started... ")
;END CODE

EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

 

MiscObject Property Gold001 Auto
GlobalVariable Property TWMHGHStage Auto

 

Event OnUpdateGameTime()

Debug.Notification("Time up...")
TWMHGHStage.SetValueInt( 3 )
UnregisterForUpdateGameTime() ; don't know if this is need.
EndEvent

 

 

 

I've replaced

RegisterForUpdateGameTime()

with

registerForSingleUpdateGameTime()

But there is still a problem....

 

Debug.Notification("Wait started... ") is displayed but...

Debug.Notification("Time up...") never gets displayed

 

Has anyone any idea why OnUpdateGameTime() is never called.

This script is attached to an actors Players Dialogue.

 

.

Edited by The-Wanderer
Link to comment
Share on other sites

Thanks for input :)

 

I removed the event from the fragment script and added a new script to the quest under the scripts tap with just the Event in it
everything compiled and properties updated...
but still the OnUpdateGameTime() is not firing.

 

What I have in the fragment is...

 

-=-=-=-=-=-=-=-=-=-=-
;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 2
Scriptname TIF__062E8C48 Extends TopicInfo Hidden

 

;BEGIN FRAGMENT Fragment_1
Function Fragment_1(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor

 

;BEGIN CODE
TWMHGHStage.SetValueInt( 2 )
Debug.Notification("Wait started... ")
registerForSingleUpdateGameTime(24.0)
;END CODE

 

EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

 

-=-=-=-=-=-=-=-=-=-=-

 

In the new script all I have is this...

 

-=-=-=-=-=-=-=-=-=-=-

 

Scriptname TWTimerScript extends Quest

 

GlobalVariable Property TWMHGHStage Auto

 

Event OnUpdateGameTime()

TWMHGHStage.SetValueInt( 3 )
Debug.Notification("Wait over.")

EndEvent

-=-=-=-=-=-=-=-=-=-=-

 

What have I got wrong ???

Link to comment
Share on other sites

With that script you will register the fragment script for update, but needs to be on the quest script.
For that, you can add a function to the quest script like this:

Function StartRegister()
RegisterForSingleUpdateGameTime(24.0)
EndFunction

Then call the function from the fragment script

(GetOwningQuest() as TWTimerScript).StartRegister()


Also possible to use states for that purpose.
See: GotoState, OnBeginState

Edited by Ghaunadaur
Link to comment
Share on other sites

Thanks that works :)

Simple once you know.

 

I may have to look into states at some point but for now I'll give those a miss I don't really need them for the mod I'm working on...

this timer problem is the only dialogue that is a bit more than just plain dialogue with a few stage/objective settings

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...