So, I've been searching around both the SC2 editor and the Internet for a while now and I've yet to find a solution for my problem. I have some abilities that depend on the in-game "Time of Day" for their functionality. For example, my hero will only cloak when it is nighttime in the game. This works really well, and now I need to be able to inform the player of the current time of day. There is a Time of Day variable type and I'm able to set it to the game's current time of day, but I cannot for the life of me figure out how to convert it to a string to be displayable on a dialog. I've attempted to simulate the time of day using timers, but they're not accurate enough. The cloaking disables before the "hour" is up and it gets more and more inaccurate as time goes on. I feel like there should be an easy way to convert the time of day into HH:MM:SS notation to be set as a label for a dialog, but I've found no such way to go about this.
Note that the return action is returning a custom script value to force the "cast". (parameters are prefixed with lp_ - if you change the name of the parameter, make sure you change the return value accordingly.)
Thank you, it works brilliantly. I didn't realize I could enter custom functions, you've opened up worlds for me!
For those who need clarification on how to use the above description:
In the Trigger editor, right click the tree panel on the left and choose New->New Function and then, using what Nevir wrote above, fill in the appropriate fields as described.
One thing you may want to change is the "Grammar Text" entry. Just leave the "User Default Grammar Text" enabled and it will allow you to use the nice hyper-link method of inserting parameters in your triggers.
One thing you may want to change is the "Grammar Text" entry. Just leave the "User Default Grammar Text" enabled and it will allow you to use the nice hyper-link method of inserting parameters in your triggers.
If you do override the grammar text like I did, you can highlight words/passages and choose a variable that they link to (dropdown at the bottom of the window) - makes it a bit easier to read for some functions/actions :)
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello all,
So, I've been searching around both the SC2 editor and the Internet for a while now and I've yet to find a solution for my problem. I have some abilities that depend on the in-game "Time of Day" for their functionality. For example, my hero will only cloak when it is nighttime in the game. This works really well, and now I need to be able to inform the player of the current time of day. There is a Time of Day variable type and I'm able to set it to the game's current time of day, but I cannot for the life of me figure out how to convert it to a string to be displayable on a dialog. I've attempted to simulate the time of day using timers, but they're not accurate enough. The cloaking disables before the "hour" is up and it gets more and more inaccurate as time goes on. I feel like there should be an easy way to convert the time of day into HH:MM:SS notation to be set as a label for a dialog, but I've found no such way to go about this.
Thanks in advance for the help
The Time Of Day type is just a string internally (with the xx:xx:xx format). You can use the following function to convert it:
Note that the return action is returning a custom script value to force the "cast". (parameters are prefixed with lp_ - if you change the name of the parameter, make sure you change the return value accordingly.)
Thank you, it works brilliantly. I didn't realize I could enter custom functions, you've opened up worlds for me!
For those who need clarification on how to use the above description:
In the Trigger editor, right click the tree panel on the left and choose New->New Function and then, using what Nevir wrote above, fill in the appropriate fields as described.
One thing you may want to change is the "Grammar Text" entry. Just leave the "User Default Grammar Text" enabled and it will allow you to use the nice hyper-link method of inserting parameters in your triggers.
If you do override the grammar text like I did, you can highlight words/passages and choose a variable that they link to (dropdown at the bottom of the window) - makes it a bit easier to read for some functions/actions :)