SetTime(int, int, int, int)

Sets the game's current time.

void SetTime(
    int nHour,
    int nMinute,
    int nSecond,
    int nMillisecond
);

Parameters

nHour

The new hour value, from 0 to 23.

nMinute

The new minute value from 0 to 1 (or 0 to a higher value if the module properties for time were changed).

nSecond

The new second value, from 0 to 59.

nMillisecond

The new millisecond value, from 0 to 999.


Description

Time can only be advanced forwards; attempting to set the time backwards will result in the day advancing and then the time being set to that specified, e.g. if the current hour is 15 and then the hour is set to 3, the day will be advanced by 1 and the hour will be set to 3.

Set the game time to the time specified. Time can only be advanced forwards; attempting to set the time backwards will result in the day advancing and then the time being set to that specified, e.g. if the current hour is 15 and then the hour is set to 3, the day will be advanced by 1 and the hour will be set to 3. If values larger than the max hour, minute, second or millisecond are specified, they will be wrapped around and the overflow will be used to advance the next field, e.g. specifying 62 hours, 250 minutes, 10 seconds and 10 milliseconds will result in the calendar day being advanced by 2 and the time being set to 18 hours, 10 minutes, 10 milliseconds.



Remarks

This has no effect on in-game DelayCommand()'s, but does affect any effects applied with DURATION_TYPE_TEMPORARY, as in, they'll get removed sooner rather then later.

If used to advance a single-players time when they rest (rather then the standard minute or so) it would be wise to only do it when rest has sucessfully ended.


Version

1.30

Example

// Advance the time of the module by 2 hours and 30 minutes. 
// Maybe the party in the module had to rest for a while...
void main()
{
    // Get current hour, minute, second and millisecond.
    int nHour = GetTimeHour();
    int nMinute = GetTimeMinute();
    int nSecond = GetTimeSecond();
    int nMillisecond = GetTimeMillisecond();

    // Advance the hour and minute by 2 and 30 respectivly.
    nHour += 2;
    nMinute += 30;

    // Set the new time
    SetTime(nHour, nMinute, nSecond, nMillisecond);
}

See Also

functions: GetTimeHour | GetTimeMillisecond | GetTimeMinute | GetTimeSecond | HoursToSeconds | SetCalendar
categories: Time Functions


 author: Charles Feduke, editor: Jasperre, additional contributor(s): Jon Dewey, Lilac Soul
 Send comments on this topic.