• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Elapsed Game Time

Level 19
Joined
Feb 25, 2009
Messages
2,004
Elapsed Time v1.0

In this tutorial I will teach you how make an proper trigger that will trackdown the elapsed time in real-time.

What I need?
  • Warcraft 3 Frozen Throne - World Editor
  • Basics knowledge of working with triggers
  1. Open your map and procced to the Trigger Editor (you can press F4)
  2. Open the specified "Category" where you want to put the trigger
  3. Create a new trigger and name it how ever you want

attachment.php


4. Look at the trigger below and assign it to your newly created trigger (you can read the trigger comments for better understanding):

  • Game Time
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • -------- ---------------------------------------------------------------- --------
      • -------- Setting the seconds to +1 every 1 second --------
      • -------- ---------------------------------------------------------------- --------
      • Set Time_Seconds = (Time_Seconds + 1)
      • -------- ---------------------------------------------------------------- --------
      • -------- Checking if the seconds are hit 10 --------
      • -------- ---------------------------------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Time_Seconds Equal to 10
        • Then - Actions
          • -------- ---------------------------------------------------------------- --------
          • -------- If so, settings seconds back to 0 --------
          • -------- ---------------------------------------------------------------- --------
          • Set Time_Seconds = 0
          • -------- ---------------------------------------------------------------- --------
          • -------- Setting the "Ten_Seconds" to +1 --------
          • -------- This occur everytime the veriable "Time_Seconds" hits the value 10 --------
          • -------- ---------------------------------------------------------------- --------
          • Set Ten_Seconds = (Ten_Seconds + 1)
          • -------- ---------------------------------------------------------------- --------
          • -------- Checking if the veriable "Ten_Seconds" is 6 --------
          • -------- ---------------------------------------------------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Ten_Seconds Equal to 6
            • Then - Actions
              • -------- ---------------------------------------------------------------- --------
              • -------- If so, then 1 minute is expired and the veriable "Time_Minutes" will be 1 --------
              • -------- Also setting the "Ten_Seconds" back to 0 --------
              • -------- ---------------------------------------------------------------- --------
              • Set Ten_Seconds = 0
              • Set Minutes = (Minutes + 1)
            • Else - Actions
        • Else - Actions
      • -------- ---------------------------------------------------------------- --------
      • -------- At the end, we make a string veriable that will display the current elapsed time --------
      • -------- The string will be in this order: Elapsed time is: #color(Time_Minutes) + and + #color(Time_Ten_Seconds)+(Time_Seconds) + seconds. --------
      • -------- ---------------------------------------------------------------- --------
      • Set Time_String = ((Elapsed time is: |cffffcc00 + (String(Minutes))) + (|r minutes and |cffffcc00 + ((String(Ten_Seconds)) + ((String(Time_Seconds)) + |rseconds.))))
Now let me explain to you what actually happens in my trigger:
  • I've added an action that will run once every 1 second.
  • So, every one second the variable "Time_Seconds" will be increased by 1 - this variable will track the elapsed SECONDS
  • Once the variable "Time_Seconds" hits a value of 10 my other variable called "Time_Ten_Seconds" will be increased by 1 - this variable will track every 10 elapsed seconds (10-20-30-40-50) and will make it look like (1(10), 2(20), 3(30), 4(40), 5(50)).
  • After that, when my variable "Time_Ten_Seconds" hits the value of 6(60) it will make the variable "Time_Minutes" to increase by 1 - this variable will track the elapsed MINUTES. Please notice that the variable "Time_Ten_Seconds" will never show a value of 6 in a string, because it will become 0 again after it hits the both variables hits the maximum supported value.
  • After all, we need to store the elapsed time in a string using our variable "Time_String"

What I need for this trigger?
- You need to create 4 variables via the "Variables Editor" - to open it, click onto the "X" mark into the Trigger Editor or simply press CTRL+B. Here is an screenshot where it is located:

attachment.php


- Variables that you need are:
  • Time_Seconds [Type: Integer]
  • Time_Ten_Seconds [Type: Integer]
  • Time_Minutes [Type: Integer]
  • Time_String [Type: String]

Now you can make a second trigger to test your tracking trigger like this:

  • Check the time
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Time_String
Let me explain again to you what happens here:
  • Each time you hit the ESC key you will display a text showing the variable "Time_String" thus, the Time_String will show the elapsed game time (check the screenshot below):

attachment.php


Test map
View attachment Elapsed Time v1.0.w3x

Editor Notes
This is my first try to make an tutorial, thus it might be not explained very well. If you think its not, please show me where is the mistakes and probably how to fix them. In time I will try to improve this tutorial using JASS/vJass to track down the elapsed time.

Credits
Feel free to edit and use as long as you give credits to me.
 

Attachments

  • tutorial_trigger.JPG
    tutorial_trigger.JPG
    6.5 KB · Views: 1,737
  • tutorial_veriable.JPG
    tutorial_veriable.JPG
    3.9 KB · Views: 1,616
  • tutorial_showtime.JPG
    tutorial_showtime.JPG
    87.6 KB · Views: 1,640
Last edited:
Level 19
Joined
Feb 25, 2009
Messages
2,004
It would actually be better to measure game time in seconds and then get data from that as needed using modulo.

Isn't there already an elapsed game time function? I forgot.

Game-time and real-time are two different things. The trigger will actually trackdown the real-time (in real world :D) you have spended into the game, not the game-time which does not represend the real-time.
 
Last edited:
Level 4
Joined
Jul 18, 2008
Messages
76
helpful and good! I will use this on my map as a simple timecheck :)

credits awarded
 
Game-time and real-time are two different things. The trigger will actually trackdown the real-time (in real world :D) you have spended into the game, not the game-time which does not represend the real-time.

Yeah but it's still doing these minute and hour calculations every second. That's what I'm getting at.
 
Yes, but using game-time to calculate the real-time will be a mess isn't it?
What im offering in this tutorial is a clear stated trigger that will cause no lag at all, nor it will bug, and it will calculate the time until your turn it off.

Yeah, forget what I said about using game-time. I haven't touched WE in ages >___>
 
Level 24
Joined
May 9, 2007
Messages
3,563
There are various issues with this.

First, in-trigger comments are not as readable as ones in the body of the tutorial, and compromise the readability of the actual coding portions of the trigger. Ideally, you want to split the trigger up and analyze it line by line outside of the trigger tags.

Second, it's loaded full of grammatical errors and doesn't actually explain very much, very well. This is a concept basic enough that you should be explaining how it works in-detail, seeing as people who need your tutorial won't be experts. The images are also really quite un-necessary and clunky.

Third, there are obvious flaws with the system itself. Why you use ten second increments in the trigger is unclear, instead of going directly from seconds to minutes.

Your use of "real-time" as a term is misleading, as most would think that that refers to the amount of time that is passing in the "real" world as they're playing the game. This isn't what it is, seeing as that if the game is paused, the trigger will cease to run.
 
This is a little basic. Yeah, people might question how to do something like this but I don't think this fits as a tutorial. (It is essentially a +1 per second, and then a conversion to minutes)

Sorry, it was made decently, and the trigger is fine, but I just don't think it is something complex enough to need a tutorial. =) I am going to graveyard it for now (since it hasn't been updated in over a month), but if you want it back out, just send me a notification.

~Graveyarded.
 
Top