TheWanderer001 Posted March 26, 2019 Share Posted March 26, 2019 (edited) 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 1Scriptname TIF__062E8C48 Extends TopicInfo Hidden;BEGIN FRAGMENT Fragment_0Function 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 EndIfEndEvent MiscObject Property Gold001 Auto GlobalVariable Property TWMHGHStage Auto Quest Property TWMHQ02 Auto Float Property OldTime = 0.0 AutoFloat Property NewTime = 0.0 Auto Edited March 28, 2019 by The-Wanderer Link to comment Share on other sites More sharing options...
TheWanderer001 Posted March 27, 2019 Author Share Posted March 27, 2019 Okay it now seems that far from working 9 out of 10 time... the "Event OnUpdateGameTime()" is now never called at all.I put a 'Debug.Notification("here") as the first line of that event it never displays. ??? Link to comment Share on other sites More sharing options...
TheWanderer001 Posted March 28, 2019 Author Share Posted March 28, 2019 (edited) 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 2Scriptname TIF__062E8C48 Extends TopicInfo Hidden ;BEGIN FRAGMENT Fragment_1Function 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 CODEEndFunction;END FRAGMENT;END FRAGMENT CODE - Do not edit anything between this and the begin comment MiscObject Property Gold001 AutoGlobalVariable Property TWMHGHStage Auto Event OnUpdateGameTime() Debug.Notification("Time up...") TWMHGHStage.SetValueInt( 3 ) UnregisterForUpdateGameTime() ; don't know if this is need.EndEvent I've replacedRegisterForUpdateGameTime()withregisterForSingleUpdateGameTime()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 March 28, 2019 by The-Wanderer Link to comment Share on other sites More sharing options...
Ghaunadaur Posted March 28, 2019 Share Posted March 28, 2019 Events can't be used within fragment scripts. This needs to be in a seperate script, attached to your quest, and called from the dialogue script. Link to comment Share on other sites More sharing options...
TheWanderer001 Posted March 28, 2019 Author Share Posted March 28, 2019 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 iteverything 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 2Scriptname TIF__062E8C48 Extends TopicInfo Hidden ;BEGIN FRAGMENT Fragment_1Function 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 More sharing options...
Ghaunadaur Posted March 28, 2019 Share Posted March 28, 2019 (edited) 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 March 28, 2019 by Ghaunadaur Link to comment Share on other sites More sharing options...
TheWanderer001 Posted March 28, 2019 Author Share Posted March 28, 2019 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 More sharing options...
Recommended Posts