Jump to content

OnUpdateGameTime Event not Working?


xcafe

Recommended Posts

Title says it all, I have a RegisterForSingleUpdateGameTime function set for 24.0 (24 skyrim hours) and an OnUpdateGameTime event, but the event is never being called.

 

 

 

State Studied
    
    Event OnBeginState()
        NotStudied = false
        Debug.Notification("State 'Studied' Entered")
        RegisterForSingleUpdateGameTime(24.0)
    Debug.Notification("Registered for update(24)")
    EndEvent
    
    
    Event OnUpdateGameTime()
        Debug.Notification("OnUpdateGameTime(24) Called")
 Int ListSize = CentralQuest.GSL.GetSize()
Int Index = 0
While Index < ListSize
    Form Entry = CentralQuest.GSL.GetAt(Index)
  If (Entry as Spell)
      PlayerRef.RemoveSpell(Entry as Spell)
     EndIf
  Index += 1
   EndWhile

GoToState("")
EndEvent

EndState

 

 

 

P.S. The debugs after the Register function are going off, but not the one in the Update event.

Link to comment
Share on other sites

xcafe,

 

Try moving that EndState line up so that the OnUpdateGameTime() event is not inside it. If you're using the three state idea for that script then it has to be available in more than one state. And unlike the other events it doesn't need to be protected by the state.

 

 

ReDragon2013,

 

I don't know why you have such a dislike of states. They are a feature Bethesda added to optimize scripts for exactly the sorts of things xcafe is trying to do (i.e. preventing certain actions under certain conditions).

Link to comment
Share on other sites

xcafe,

 

Try moving that EndState line up so that the OnUpdateGameTime() event is not inside it. If you're using the three state idea for that script then it has to be available in more than one state. And unlike the other events it doesn't need to be protected by the state.

 

 

ReDragon2013,

 

I don't know why you have such a dislike of states. They are a feature Bethesda added to optimize scripts for exactly the sorts of things xcafe is trying to do (i.e. preventing certain actions under certain conditions).

I'm not sure I understood what you were suggesting. Did you mean something like this?

State Studied
    
    Event OnBeginState()
        NotStudied = false
        Debug.Notification("State 'Studied' Entered")
        RegisterForSingleUpdateGameTime(24.0)
    Debug.Notification("Registered for update(24)")
    GoToState("")
    EndEvent
    EndState
    
    Event OnUpdateGameTime()
       
 Int ListSize = CentralQuest.GSL.GetSize()
Int Index = 0
While Index < ListSize
    Form Entry = CentralQuest.GSL.GetAt(Index)
  If (Entry as Spell)
      PlayerRef.RemoveSpell(Entry as Spell)
     EndIf
  Index += 1
   EndWhile


EndEvent

Link to comment
Share on other sites

The most likely problem is that the state got changed before the OnUpdateGameTime event happened.

 

But don't move the GotToState("") line! That was supposed to stay inside the OnUpdateGameTime() event. Move the EndState line where you did but put the GoToState("") back.

Link to comment
Share on other sites

The most likely problem is that the state got changed before the OnUpdateGameTime event happened.

 

But don't move the GotToState("") line! That was supposed to stay inside the OnUpdateGameTime() event. Move the EndState line where you did but put the GoToState("") back.

But...then the GoToState("") line will be part of an event that's already in that state?

If I don't put the line in the place that I did, will the onupdate event ever happen?

Link to comment
Share on other sites

There's a chance the state is getting changed somewhere else before the OnUpdateGameTime can complete. You didn't post the entire script so we can't tell for sure. If that's the problem moving OnUpdateGameTime to the top level (outside of any state) will let it do what it needs to do. If that doesn't fix the problem then something else is wrong. The way to find out is to make that change and test it.

Link to comment
Share on other sites

Ok so I think I figured out what the problem is! Apparently waiting actually messes up the registerforupdategametime function, so I'm going to try and reduce it to something that I won't have to wait through to see if that is the problem. In the meantime, is there a way of getting something like this to work?

Scriptname reregisterscript extends ObjectReference
Float fPreviousUpdateFloat fUpdateTime = 1.5
Float fMinimumUpdateTime = 0.1
Int iCounter

Event OnSomeEvent() ;The first time that you register for an update   
fPreviousUpdate = Utility.GetCurrentGameTime()  
RegisterForSingleUpdateGameTime(fUpdateTimer)
EndEvent

Event OnUpdateGameTime()   
    Float fCurrentTime = Utility.GetCurrentGameTime()   
    Float fNumUpdates = (fCurrentTime - fPreviousUpdate) * 24 / fUpdateTimer    
    Int iNumUpdates = Math.Floor(fNumUpdates)   
    If(iNumUpdates > 0) iCounter += 1 * iNumUpdates 
    Else iCounter += 1  
    EndIf   
    fPreviousUpdate = fCurrentTime  
    Float fRemainingTime = fUpdateTime * (1.0 - (fNumUpdates - (iNumUpdates as Float))) 
    If(fRemainingTime > fMinimumUpdateTime) 
        RegisterForSingleUpdateGameTime(fRemainingTime) 
    Else    RegisterForSingleUpdateGameTime(fMinimumUpdateTime) 
        EndIf
EndEvent 

I found it here, http://www.gamesas.com/time-remainder-after-onupdategametime-t371450.html, and tried to compile it, but it brings up a bunch of compiler errors and I know literally nothing about floats so I don't know how to fix them. Here are the errors, for reference:

C:\Program Files (x86)\Steam\steamapps\common\Skyrim\Data\scripts\source\reregisterscript.psc(2,39): required (...)+ loop did not match anything at input '='
C:\Program Files (x86)\Steam\steamapps\common\Skyrim\Data\scripts\source\reregisterscript.psc(2,6): Unknown user flag fUpdateTime
C:\Program Files (x86)\Steam\steamapps\common\Skyrim\Data\scripts\source\reregisterscript.psc(15,24): required (...)+ loop did not match anything at input 'iCounter'
C:\Program Files (x86)\Steam\steamapps\common\Skyrim\Data\scripts\source\reregisterscript.psc(16,9): required (...)+ loop did not match anything at input 'iCounter'
C:\Program Files (x86)\Steam\steamapps\common\Skyrim\Data\scripts\source\reregisterscript.psc(22,12): required (...)+ loop did not match anything at input 'RegisterForSingleUpdateGameTime'

Link to comment
Share on other sites

  • Recently Browsing   0 members

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