Difference between revisions of "GetSecondsPassed"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>DragoonWraith
(note about GameDaysPassed - anyone care to check if this was true in Oblivion?)
imported>Geckbot
m (Robot: Automated text replacement (-\[\[Category:(.*?)\(GECK 1.0\)\]\] +Category:\1(GECK 1.1)))
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Link to TES4 Construction Set Wiki: [http://cs.elderscrolls.com/constwiki/index.php/GetSecondsPassed GetSecondsPassed].
{{Function
|origin = GECK1
|name = GetSecondsPassed
|summary = Returns the number of real life seconds that have passed since this function was last called by the calling script.


In Fallout 3, [[:Category:Time Functions|GameDaysPassed]] is a float with enough precision to accurately measure the passage of seconds, which can be used as an alternative to GetSeconds Passed. Consider:
|returnVal = seconds
<pre>float MyTimer
|returnType = float
|example = <pre>float timer


begin GameMode
begin gamemode
    if GameDaysPassed < MyTimer
  if timer < 5
        return
      set timer to timer + GetSecondsPassed
    else
  else
      ; Do stuff.
      ;5 seconds have passed, do something special
 
      set timer to 0
      ; Reset the timer to 5 seconds (24 hours of 60 minutes of 60 seconds in a day).
  endif
        set MyTimer to GameDaysPassed + (1.0 / 24.0 / 60.0 / 60.0) * 5.0
    endif
end</pre>
end</pre>
This is the same as this:
}}
<pre>float MyTimer


begin GameMode
==Notes==
  ; Keep track of time.
    set MyTimer to MyTimer - GetSecondsPassed


    if MyTimer > 0
*[[SetGlobalTimeMultiplier]] will affect the return value of this function in the same way it affects the speed of the game.
        return
*Each script has its own independent tracking of when GetSecondsPassed was last called.
    else
*Calling this function multiple times in the same script in the same frame will return the same values for each call.
      ; Do stuff.
*This function is unreliable in a ScriptEffect during sleep/wait/fast travel. Use [[ScriptEffectElapsedSeconds]] instead.
 
      ; Reset the timer to 5 seconds.
        set MyTimer to 5
    endif
end</pre>
It is also slightly more efficient to use GameDaysPassed because you do not need to update a variable every frame, you only have to do the check - saving the script an operation. A minor note, but nonetheless notable.


[[Category:Functions]]
[[Category:Functions]]
[[Category:Functions (GECK 1.1)]]
[[Category:Time Functions]]
[[Category:Time Functions]]
[[Category:Time Functions (GECK 1.1)]]

Latest revision as of 12:34, 15 August 2009

< [[::Category:Functions|Category:Functions]]

A function included in the GECK version 1.1.0.36.

Description

Returns the number of real life seconds that have passed since this function was last called by the calling script.

Syntax

[help]
(seconds:float) GetSecondsPassed

Example

float timer

begin gamemode
   if timer < 5
      set timer to timer + GetSecondsPassed
   else
      ;5 seconds have passed, do something special
      set timer to 0
   endif
end

Notes

  • SetGlobalTimeMultiplier will affect the return value of this function in the same way it affects the speed of the game.
  • Each script has its own independent tracking of when GetSecondsPassed was last called.
  • Calling this function multiple times in the same script in the same frame will return the same values for each call.
  • This function is unreliable in a ScriptEffect during sleep/wait/fast travel. Use ScriptEffectElapsedSeconds instead.