// This script locks OBJECT_SELF at night and unlocks it during the day.
//
// ============================================================================
// Part of the "Aspire" module foundation package.
// Author: Kaylor
// ============================================================================
void main()
{
    if (GetLocalInt(OBJECT_SELF, "Aspire_LockerTimeStamp") != GetTimeHour()){

        // Lock the object at night
        if (GetIsNight() == TRUE){
            if (GetLocked(OBJECT_SELF) == FALSE){
                SetLocked(OBJECT_SELF, TRUE);
                SetLocalInt(OBJECT_SELF, "Aspire_LockerTimeStamp", GetTimeHour());
            }
        }

        // Unlock it during the day.
        else {
            if (GetLocked(OBJECT_SELF) == TRUE){
                SetLocked(OBJECT_SELF, FALSE);
                SetLocalInt(OBJECT_SELF, "Aspire_LockerTimeStamp", GetTimeHour());
            }
        }
    }
}