Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Game Time.


JohnPony
 Share

Recommended Posts

Well erm, im having some serious mental issues over this piece of code:
```
Public Sub ProcessTime()
    With GameTime
        .Minute = .Minute + 1
        If .Minute >= 60 Then
            .Hour = .Hour + 1
            .Minute = 0

            If GameTime.Hour >= 24 Then
                .Day = .Day + 1
                .Hour = 0
                ChangeDayEvents

                If GameTime.Hour < 24 & GameTime.Hour > 12 Then
                    ChangeHourNightEvents
            Else
                If GameTime.Hour < 12 & GameTime.Hour >= 1 Then
                    ChangeDayEvents
                End If
            End If

                If .Day > GetMonthMax Then
                    .Month = .Month + 1
                    .Day = 1
                    ChangeMonthEvents

                    If .Month > 12 Then
                        .Year = .Year + 1
                        .Month = 1
                        ChangeYearEvents
                    End If
                End If
            End If
        End If
    End With
End Sub

Public Sub ChangeDayEvents()
    Call PlayerMsg(index, "A New Day Is Born!", Red)
    Call SendDayChange(index)
End Sub

Public Sub ChangeHourNightEvents()
    Call PlayerMsg(index, "The Sun Sets In The Distance!", Red)
    Call SendNightChange(index)
End Sub

Public Sub ChangeHourDayEvents()
    Call PlayerMsg(index, "The Sun Finnaly Rises!", Red)
End Sub

Public Sub ChangeMonthEvents()
    Call GlobalMsg("A New Month Has Dawned!", Red)
End Sub
Public Sub ChangeYearEvents()
    Call GlobalMsg("Celebrate My Friend, For The New Year Is Upon Us!", Red)
End Sub

Public Function GetMonthMax() As Byte
    Dim M As Byte
    M = GameTime.Month
    If M = 1 Or M = 3 Or M = 5 Or M = 7 Or M = 8 Or M = 10 Or M = 12 Then
        GetMonthMax = 31
    ElseIf M = 4 Or M = 6 Or M = 9 Or M = 11 Then
        GetMonthMax = 30
    ElseIf M = 2 Then
        GetMonthMax = 28
    End If
End Function
```
It should be changing the day / night. But its not doing anything at the set times:
```
    If GameTime.Hour < 24 & GameTime.Hour > 12 Then
                    ChangeHourNightEvents
            Else
                If GameTime.Hour < 12 & GameTime.Hour >= 1 Then
                    ChangeDayEvents
                End If
```
Any idea what im doing wrong? Im really having a brain buster on this one.
Link to comment
Share on other sites

@Erwin:

> What happens if you change the & to And, or is that thesame?

I am wondering the same cause I was under.the.impression that u could only use.the word "and" because the symbols are used as suffixes like this "&" is short for "as Long", "%" is short for integer, $ is short for string ect..
Link to comment
Share on other sites

Focus on the if-then statements that compare the hours… I am tired and not thinking straight but I can not see how that would work for day/night at all. Remember, 0-12 is midnight to noon so most of that time frame it is the middle of the night... also as previously stated... the & symbols should be spelt out as and.
Link to comment
Share on other sites

thought this might help:

```
Dim AMorPM As String
Dim TempSeconds As Integer
Dim PrintSeconds As String
Dim PrintSeconds2 As String
Dim PrintMinutes As String
Dim PrintMinutes2 As String
Dim PrintHours As Integer

    Seconds = Seconds + Gamespeed

    If Seconds > 59 Then
        Minutes = Minutes + 1
        Seconds = Seconds - 60
    End If
    If Minutes > 59 Then
        Hours = Hours + 1
        Minutes = 0
    End If
    If Hours > 24 Then
        Hours = 1
    End If

    If Hours > 12 Then
        AMorPM = "PM"
        PrintHours = Hours - 12
    Else
        AMorPM = "AM"
        PrintHours = Hours
    End If

    If Hours = 24 Then
        AMorPM = "AM"
    End If

    TempSeconds = Seconds

    If Seconds > 9 Then
        PrintSeconds = TempSeconds
    Else
        PrintSeconds = "0" & Seconds
    End If

    If Seconds > 50 Then
        PrintSeconds2 = "0" & 60 - TempSeconds
    Else
        PrintSeconds2 = 60 - TempSeconds
    End If

    If Minutes > 9 Then
        PrintMinutes = Minutes
    Else
        PrintMinutes = "0" & Minutes
    End If

    If Minutes > 50 Then
        PrintMinutes2 = "0" & 60 - Minutes
    Else
        PrintMinutes2 = 60 - Minutes
    End If

    Label12.Caption = "Current Time is " & PrintHours & ":" & PrintMinutes & ":" & PrintSeconds & " " & AMorPM

    If Hours > 20 And GameTime = TIME_DAY Then
        GameTime = TIME_NIGHT
        Call SendTimeToAll
    End If
    If Hours < 21 And Hours > 6 And GameTime = TIME_NIGHT Then
        GameTime = TIME_DAY
        Call SendTimeToAll
    End If
    If Hours < 7 And GameTime = TIME_DAY Then
        GameTime = TIME_NIGHT
        Call SendTimeToAll
    End If

    If Hours < 21 And Hours > 6 Then
        Label10.Caption = "Time until night:" & 21 - Hours - 1 & ":" & PrintMinutes2 & ":" & PrintSeconds2
    Else
        If Hours < 7 Then
            Label10.Caption = "Time until day:" & 7 - Hours - 1 & ":" & PrintMinutes2 & ":" & PrintSeconds2
        Else
            Label10.Caption = "Time until day:" & 24 - Hours - 1 + 7 & ":" & PrintMinutes2 & ":" & PrintSeconds2
        End If
    End If

    If Hours > 11 Then
        GameClock = Hours - 12 & ":" & PrintMinutes & ":" & PrintSeconds & " " & AMorPM
    Else
        GameClock = Hours & ":" & PrintMinutes & ":" & PrintSeconds & " " & AMorPM
    End If

    Call SendGameClockToAll
```
Link to comment
Share on other sites

Its not to do with the and statement because i tried this:
```
Public Sub ProcessTime()
    With GameTime
        .Minute = .Minute + 1
        If .Minute >= 60 Then
            .Hour = .Hour + 1
            .Minute = 0
        End If

            If .Hour >= 24 Then
                .Day = .Day + 1
                .Hour = 0
                ChangeDayEvents
            End If

            If .Hour > 12 Then
                ChangeNightEvents
            End If

            If .Hour < 12 Then
                ChangeDayEvents
            End If

                If .Day > GetMonthMax Then
                    .Month = .Month + 1
                    .Day = 1
                    ChangeMonthEvents
                End If

                    If .Month > 12 Then
                        .Year = .Year + 1
                        .Month = 1
                        ChangeYearEvents
                    End If

    End With
End Sub
```And it still did not seem to work. Also i would think that nighttime (in my game) will range from 12 o'clock till 12 o'clock the next day. And then day time from 1 o'clock till 11:59\. Just because the time in my system is really fast, and it will just be part of the storyline (short days)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...