In the current map I am working on I have some Dialog timers that are supposed to represent how much time an actual timer has left so I don't have to use the ugly timer windows. Whenever I test the map offline the timers match up perfectly, but as soon as I test the map online the timers fall out of synch (I am using real time for all of the timers and wait commands). Is this just bound to happen or is there some way to prevent this?
I don't have a lot of experience with the map editor so I wouldn't be surprised if my newbishness is showing somewhere.
-----Incoming Crappy Code-----
-----The Timer Window is a tad faster then the dialog window. It beats the dialog timer from 30 to 0 by about 1.5 secs.-----
Settings Timer
Events
Timer - Elapsed time is 1.0 Real Time seconds
Local Variables
i = 30 <Integer>
Conditions
Actions
Timer - Start Settings Timer as a One Shot timer that will expire in 30.0 Real Time seconds
Variable - Set Settings Timer = (Last started timer)
Timer - Create a timer window for Settings Timer, with the title "Game Starts in:", using Remaining time (initially Visible)
Variable - Set Settings Timer Window = (Last created timer window)
Advanced Create Dialog(300, 60, 150, 0, Top Right, Show, (All players), File, HorizontalBorder, False)
Variable - Set Settings Timer Dialog = (Last created dialog)
General - For each integer i from 30 to 0 with increment -1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
i != 0
Then
Dialog - Create a label for dialog Settings Timer Dialog with the dimensions (200, 50) anchored to Center with an offset of (0, 20) with the text (Combine ("Game starts in ", (Text(i)))) color set to White text writeout set to False with a writeout duration of 2.0
Variable - Set Settings Timer Dialog Window = (Last created dialog item)
General - Wait 1.0 Real Time seconds
Dialog - Destroy Settings Timer Dialog Window
Else
Dialog - Destroy Settings Timer Dialog Window
-----Advanced Create Dialog is this-----
Advanced Create Dialog
Options: Action
Return Type: (None)
Parameters
Size X = 0 <Integer>
Size Y = 0 <Integer>
Offset X = 0 <Integer>
Offset Y = 0 <Integer>
Anchor = Bottom Left <Anchor>
Show/Hide = Show <Show/Hide Option>
Show/Hide Player Group = (All players) <Player Group>
Background Image = No File <File - Image>
Background Image Type <Image Type>
Background Tiled <Boolean>
Grammar Text: Advanced Create Dialog(Size X, Size Y, Offset X, Offset Y, Anchor, Show/Hide, Show/Hide Player Group, Background Image, Background Image Type, Background Tiled)
Hint Text: (None)
Custom Script Code
Local Variables
Actions
Dialog - Create a Modal dialog of size (Size X, Size Y) at (Offset X, Offset Y) relative to Anchor of screen
Dialog - Hide the background image of (Last created dialog)
Dialog - Create an image for dialog (Last created dialog) with the dimensions (Size X, Size Y) anchored to Top Left with an offset of (0, 0) setting the tooltip to "" using the image Background Image as a Background Image Type type with tiled set to Background Tiled tint color White and blend mode Normal
Dialog - Show/Hide (Last created dialog) for Show/Hide Player Group
Im not quite sure why this is happening, especially since your are stating it just happens in mutliplayer, whats really weird. Seems like timers and waits are not exactly synched or smth.
However i have to ask, do you really need the timer for your map? If yes, you can also try to set the label periodically to the remaining time of the timer.
If not i would just use a loop to simulate the timer, like you did.
start timer
Events
Timer - Elapsed time is 1.0 Real Time seconds
Local Variables
Conditions
Actions
Timer - Start my timer as a One Shot timer that will expire in 30.0 Real Time seconds
Trigger - Turn update label On
update label (initially off)
Events
Timer - Every 1.0 seconds of Real Time
Local Variables
Conditions
Actions
Dialog - Set my label text to (Text((Remaining time of my timer)) with 0 decimal places) for (Active Players)
You can also write a custom action to create your own little timers:
custom timer
Options: Action, Create Thread
Return Type: (None)
Parameters
duration (sec) = 0 <Integer>
time type = Real Time <Time Type>
executed trigger = No Trigger <Trigger>
Grammar Text: custom timer(duration (sec), time type, executed trigger)
Hint Text: (None)
Custom Script Code
Local Variables
time remaining = 0 <Integer>
tmp d = No Dialog <Dialog>
tmp di = No Dialog Item <Dialog Item>
Actions
Dialog - Create a Modal dialog of size (500, 400) at (0, 0) relative to Center of screen
Dialog - Show (Last created dialog) for (All players)
Variable - Set tmp d = (Last created dialog)
Dialog - Create a label for dialog (Last created dialog) with the dimensions (200, 50) anchored to Center with an offset of (0, 0) with the text "" color set to White text writeout set to False with a writeout duration of 2.0
Variable - Set tmp di = (Last created dialog item)
General - For each integer time remaining from duration (sec) to 0 with increment -1, do (Actions)
Actions
Dialog - Set tmp di text to (Text(time remaining)) for (Active Players)
General - Wait 1.0 time type seconds
Dialog - Destroy tmp d
Trigger - Run executed trigger (Check Conditions, Don't Wait until it finishes)
For sure you can add much more options to your custom timer function, like dialog size and position etc.
Trying it your way the timer window still is a bit faster then the dialog timer until it hits a certain point and the dialog timer skips ahead the timer window by a full second.
The timers are still synched when testing it offline though.
I mean it's not the end of the world if there's no way to really fix this. If needed I can just use the ugly timer window.
The ugly hideous timer window.
-----
Your second method might work. I'll experiment with it more in the morning. The dialog timer is still running faster then the timer window which according to my stopwatch kept the real time while the dialog timer sped ahead just a bit (about 1.5 secs per 30 secs).
If that's the case it looks like the option is between accurate time keeping with an ugly window or a slightly faster then real time game clock with style.
In the current map I am working on I have some Dialog timers that are supposed to represent how much time an actual timer has left so I don't have to use the ugly timer windows. Whenever I test the map offline the timers match up perfectly, but as soon as I test the map online the timers fall out of synch (I am using real time for all of the timers and wait commands). Is this just bound to happen or is there some way to prevent this?
I don't have a lot of experience with the map editor so I wouldn't be surprised if my newbishness is showing somewhere.
Could you post the related source-code right here?
Just select all lines of your trigger, right-click and chose "copy as text".
-----Incoming Crappy Code-----
-----The Timer Window is a tad faster then the dialog window. It beats the dialog timer from 30 to 0 by about 1.5 secs.-----
Settings Timer
Events
Timer - Elapsed time is 1.0 Real Time seconds
Local Variables
i = 30 <Integer>
Conditions
Actions
Timer - Start Settings Timer as a One Shot timer that will expire in 30.0 Real Time seconds
Variable - Set Settings Timer = (Last started timer)
Timer - Create a timer window for Settings Timer, with the title "Game Starts in:", using Remaining time (initially Visible)
Variable - Set Settings Timer Window = (Last created timer window)
Advanced Create Dialog(300, 60, 150, 0, Top Right, Show, (All players), File, HorizontalBorder, False)
Variable - Set Settings Timer Dialog = (Last created dialog)
General - For each integer i from 30 to 0 with increment -1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
i != 0
Then
Dialog - Create a label for dialog Settings Timer Dialog with the dimensions (200, 50) anchored to Center with an offset of (0, 20) with the text (Combine ("Game starts in ", (Text(i)))) color set to White text writeout set to False with a writeout duration of 2.0
Variable - Set Settings Timer Dialog Window = (Last created dialog item)
General - Wait 1.0 Real Time seconds
Dialog - Destroy Settings Timer Dialog Window
Else
Dialog - Destroy Settings Timer Dialog Window
-----Advanced Create Dialog is this-----
Advanced Create Dialog
Options: Action
Return Type: (None)
Parameters
Size X = 0 <Integer>
Size Y = 0 <Integer>
Offset X = 0 <Integer>
Offset Y = 0 <Integer>
Anchor = Bottom Left <Anchor>
Show/Hide = Show <Show/Hide Option>
Show/Hide Player Group = (All players) <Player Group>
Background Image = No File <File - Image>
Background Image Type <Image Type>
Background Tiled <Boolean>
Grammar Text: Advanced Create Dialog(Size X, Size Y, Offset X, Offset Y, Anchor, Show/Hide, Show/Hide Player Group, Background Image, Background Image Type, Background Tiled)
Hint Text: (None)
Custom Script Code
Local Variables
Actions
Dialog - Create a Modal dialog of size (Size X, Size Y) at (Offset X, Offset Y) relative to Anchor of screen
Dialog - Hide the background image of (Last created dialog)
Dialog - Create an image for dialog (Last created dialog) with the dimensions (Size X, Size Y) anchored to Top Left with an offset of (0, 0) setting the tooltip to "" using the image Background Image as a Background Image Type type with tiled set to Background Tiled tint color White and blend mode Normal
Dialog - Show/Hide (Last created dialog) for Show/Hide Player Group
------(source: http://www.sc2mapster.com/forums/resources/tutorials/33449-dialog-custom-dialog-technique/ )-----
-----I have a few other timers, but they essentially follow the same code and don't run at the same time (or at least aren't supposed to)-----
Im not quite sure why this is happening, especially since your are stating it just happens in mutliplayer, whats really weird. Seems like timers and waits are not exactly synched or smth.
However i have to ask, do you really need the timer for your map? If yes, you can also try to set the label periodically to the remaining time of the timer.
If not i would just use a loop to simulate the timer, like you did.
start timer
Events
Timer - Elapsed time is 1.0 Real Time seconds
Local Variables
Conditions
Actions
Timer - Start my timer as a One Shot timer that will expire in 30.0 Real Time seconds
Trigger - Turn update label On
update label (initially off)
Events
Timer - Every 1.0 seconds of Real Time
Local Variables
Conditions
Actions
Dialog - Set my label text to (Text((Remaining time of my timer)) with 0 decimal places) for (Active Players)
You can also write a custom action to create your own little timers:
custom timer
Options: Action, Create Thread
Return Type: (None)
Parameters
duration (sec) = 0 <Integer>
time type = Real Time <Time Type>
executed trigger = No Trigger <Trigger>
Grammar Text: custom timer(duration (sec), time type, executed trigger)
Hint Text: (None)
Custom Script Code
Local Variables
time remaining = 0 <Integer>
tmp d = No Dialog <Dialog>
tmp di = No Dialog Item <Dialog Item>
Actions
Dialog - Create a Modal dialog of size (500, 400) at (0, 0) relative to Center of screen
Dialog - Show (Last created dialog) for (All players)
Variable - Set tmp d = (Last created dialog)
Dialog - Create a label for dialog (Last created dialog) with the dimensions (200, 50) anchored to Center with an offset of (0, 0) with the text "" color set to White text writeout set to False with a writeout duration of 2.0
Variable - Set tmp di = (Last created dialog item)
General - For each integer time remaining from duration (sec) to 0 with increment -1, do (Actions)
Actions
Dialog - Set tmp di text to (Text(time remaining)) for (Active Players)
General - Wait 1.0 time type seconds
Dialog - Destroy tmp d
Trigger - Run executed trigger (Check Conditions, Don't Wait until it finishes)
For sure you can add much more options to your custom timer function, like dialog size and position etc.
Trying it your way the timer window still is a bit faster then the dialog timer until it hits a certain point and the dialog timer skips ahead the timer window by a full second.
The timers are still synched when testing it offline though.
I mean it's not the end of the world if there's no way to really fix this. If needed I can just use the ugly timer window.
The ugly hideous timer window.
-----
Your second method might work. I'll experiment with it more in the morning. The dialog timer is still running faster then the timer window which according to my stopwatch kept the real time while the dialog timer sped ahead just a bit (about 1.5 secs per 30 secs).
If that's the case it looks like the option is between accurate time keeping with an ugly window or a slightly faster then real time game clock with style.