Difference between revisions of "GetSecondsPassed"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Wkilleen
 
imported>DragoonWraith
(note about GameDaysPassed - anyone care to check if this was true in Oblivion?)
Line 1: Line 1:
Link to TES4 Construction Set Wiki: [http://cs.elderscrolls.com/constwiki/index.php/GetSecondsPassed GetSecondsPassed].
Link to TES4 Construction Set Wiki: [http://cs.elderscrolls.com/constwiki/index.php/GetSecondsPassed GetSecondsPassed].
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:
<pre>float MyTimer
begin GameMode
    if GameDaysPassed < MyTimer
        return
    else
      ; Do stuff.
      ; Reset the timer to 5 seconds (24 hours of 60 minutes of 60 seconds in a day).
        set MyTimer to GameDaysPassed + (1.0 / 24.0 / 60.0 / 60.0) * 5.0
    endif
end</pre>
This is the same as this:
<pre>float MyTimer
begin GameMode
  ; Keep track of time.
    set MyTimer to MyTimer - GetSecondsPassed
    if MyTimer > 0
        return
    else
      ; Do stuff.
      ; 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:Time Functions]]
[[Category:Time Functions]]

Revision as of 11:59, 25 December 2008

Link to TES4 Construction Set Wiki: GetSecondsPassed.

In Fallout 3, 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:

float MyTimer

begin GameMode
    if GameDaysPassed < MyTimer
        return
    else
       ; Do stuff.

       ; Reset the timer to 5 seconds (24 hours of 60 minutes of 60 seconds in a day).
        set MyTimer to GameDaysPassed + (1.0 / 24.0 / 60.0 / 60.0) * 5.0
    endif
end

This is the same as this:

float MyTimer

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

    if MyTimer > 0
        return
    else
       ; Do stuff.

       ; Reset the timer to 5 seconds.
        set MyTimer to 5
    endif
end

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.