Yeah how would I do this? I'm thinking make a function that decides if the value is within the times I need it to be in. Since you can't use any operators besides = and != (which was kind of really stupid).
But I'd prefer not to have to go through every number from 1-60 in both the minute and second spots. For some of the more obvious reasons.
I poked around and couldn't find anything. Maybe someone who knows more can help me out here?
While I'm at it, does anyone know how to blend skyboxes together as you swap them? It would be a pretty cool effect.
Rollback Post to RevisionRollBack
I am largely inactive, but I am still around. Feel free to poke me if you need some help, just be warned that I only really come back if I need help and/or if I'm posting a new map/library.
I dunno, but if you could make a library that created an artificial time of day inside the game, then you could save the value in seconds in a variable possible.
Time of day returns a string. Therefore its not possible to directly compare it to another number.
However, you might be able to create a function that converts this time of day string into a number (like seconds). This number could then be compared.
Custom script this time, too lazy for GUI >_>
intgetTimeOfDaySeconds(stringtimeOfDay){intlen=StringLength(timeOfDay);inthours;intminutes;intseconds;//This is necessary because the time strings use a kinda weird formatting. For example 00:00:01 would be "01"if(len==2){timeOfDay="00:00:"+timeOfDay;}elseif(len==5){timeOfDay="00:"+timeOfDay;}hours=StringToInt(StringSub(timeOfDay,1,2));minutes=StringToInt(StringSub(timeOfDay,4,5));seconds=StringToInt(StringSub(timeOfDay,7,8));returnhours*3600+minutes*60+seconds;}
This will convert game time into game time seconds. These can now be compared to other numbers.
PS: To implement this function into your map, just create a new custom script object and paste this in. After that create a new gui function that looks exactly like this:
get time of day seconds
Options: Function
Return Type: Integer
Parameters
time of day = 00:00:00 <Time Of Day>
Grammar Text: get time of day seconds(time of day)
Hint Text: (None)
Custom Script Code
Local Variables
Actions
General - Return getTimeOfDaySeconds(lp_timeofday)
Alternatively you can for sure also implement this function in GUI directly if you are experienced in scripting.
I wouldn't say I'm advanced in scripting, as evidenced here, but if I knew a little bit more about the logic behind the custom script I could probably make a rough approximation of how it works and begin trying to implement it.
I am largely inactive, but I am still around. Feel free to poke me if you need some help, just be warned that I only really come back if I need help and/or if I'm posting a new map/library.
I wouldn't say I'm advanced in scripting, as evidenced here, but if I knew a little bit more about the logic behind the custom script I could probably make a rough approximation of how it works and begin trying to implement it.
Thanks for trying but honestly if it comes to that I'll just forget about trying to figure out the time of day at all.
Already confusing enough. lol
It shouldn't be too difficult. First try displaying the time of day as a string using the Text Message action to see what kind of formatting the string uses (Mille25 described this.) Then try using Convert Integer to Text and Convert String to Integer to see how it prints as an integer.
I am largely inactive, but I am still around. Feel free to poke me if you need some help, just be warned that I only really come back if I need help and/or if I'm posting a new map/library.
This is a SC2 function that returns to you the current game time of day as a string. It is formatted as mentioned above. I printed it to the screen as a test and the default starting time (this map was essentially blank and had no time of day manipulation) was "06:00:00".
Using Mille's function, you can pass the current game time of day to his function, get a numeric value back and compare that against whatever you want... for example noon would be 43200 (3600 * 12).
if(getTimeOfDaySeconds(GameTimeOfDayGet())<43200){//its before noon}else{//its after noon}
Here is another example to see if the time is between 5pm and 6pm.
intnTimeOfDay;nTimeOfDay=getTimeOfDaySeconds(GameTimeOfDayGet());if(nTimeOfDay>=61200&&nTimeOfDay<=64800){//its between 5pm and 6pm}
I apoligize, i should have given you the GUI version from begin on, I was just a bit lazy because in GUI working with texts/arithmetic is a huge pain.
To get back to your problem:
General - Return getTimeOfDaySeconds(lp_timeofday)
To make this work ensure that you do the following:
- Make sure the custom script file with my function is ABOVE your GUI function (So the custom script gets initialized frist)
- When clicking on the return action, select "custom script".
- Once done, type "getTimeOfDaySeconds(lp_timeofday)" in the field
- If you already did all this, make sure the GUI parameter is exactly called "timeofday" and NOT lp_timeofday. The "lp_" automatically gets added by the "compiler" that generates the galaxy script.
- Also make sure your GUI function really returns an integer value and uses "Time of Day" as parameter-type
In GUI he doesnt even need to use seconds to compare the times. He can just enter "12:00:00" and the function will convert it to seconds aswell. This also works in galaxy using strings.
Example:
if(getTimeOfDaySeconds(GameTimeOfDayGet())<getTimeOfDaySeconds("12:00:00")){//its before noon}else{//its after noon}
@soulzek: Go
In GUI he doesnt even need to use seconds to compare the times. He can just enter "12:00:00" and the function will convert it to seconds aswell. This also works in galaxy using strings.
Example:
if(getTimeOfDaySeconds(GameTimeOfDayGet())<getTimeOfDaySeconds("12:00:00")){//its before noon}else{//its after noon}
This is true, and does make it more readable (thats what comments are for!), though it is significantly more efficient to just pre-calculate any hard-coded values as the converted number since string parsing and manipulation is slow.
Here is the Custom Script, which is called TimeOfDaySeconds:
intgetTimeOfDaySeconds(stringtimeOfDay){intlen=StringLength(timeOfDay);inthours;intminutes;intseconds;//This is necessary because the time strings use a kinda weird formatting. For example 00:00:01 would be "01"if(len==2){timeOfDay="00:00:"+timeOfDay;}elseif(len==5){timeOfDay="00:"+timeOfDay;}hours=StringToInt(StringSub(timeOfDay,1,2));minutes=StringToInt(StringSub(timeOfDay,4,5));seconds=StringToInt(StringSub(timeOfDay,7,8));returnhours*3600+minutes*60+seconds;}
The Custom Script is above the function, the return is Custom Script, and to the best of my knowledge everything was inputted correctly. Yet I still get the same error.
I am largely inactive, but I am still around. Feel free to poke me if you need some help, just be warned that I only really come back if I need help and/or if I'm posting a new map/library.
"More efficient"... Hehe i really see the C-Programmer here! :)
Even though thats absolutly correct, in this case i would prefer readability. It depends on the use of the function.
I am largely inactive, but I am still around. Feel free to poke me if you need some help, just be warned that I only really come back if I need help and/or if I'm posting a new map/library.
To post a comment, please login or register a new account.
Yeah how would I do this? I'm thinking make a function that decides if the value is within the times I need it to be in. Since you can't use any operators besides = and != (which was kind of really stupid).
But I'd prefer not to have to go through every number from 1-60 in both the minute and second spots. For some of the more obvious reasons.
I poked around and couldn't find anything. Maybe someone who knows more can help me out here?
While I'm at it, does anyone know how to blend skyboxes together as you swap them? It would be a pretty cool effect.
@Yaksmanofage: Go
I dunno, but if you could make a library that created an artificial time of day inside the game, then you could save the value in seconds in a variable possible.
Time of day returns a string. Therefore its not possible to directly compare it to another number.
However, you might be able to create a function that converts this time of day string into a number (like seconds). This number could then be compared.
Custom script this time, too lazy for GUI >_>
This will convert game time into game time seconds. These can now be compared to other numbers.
PS: To implement this function into your map, just create a new custom script object and paste this in. After that create a new gui function that looks exactly like this:
get time of day seconds
Options: Function
Return Type: Integer
Parameters
time of day = 00:00:00 <Time Of Day>
Grammar Text: get time of day seconds(time of day)
Hint Text: (None)
Custom Script Code
Local Variables
Actions
General - Return getTimeOfDaySeconds(lp_timeofday)
Alternatively you can for sure also implement this function in GUI directly if you are experienced in scripting.
@Mille25: Go
I tried it but I kept getting invalid parameter list error.
I wouldn't say I'm advanced in scripting, as evidenced here, but if I knew a little bit more about the logic behind the custom script I could probably make a rough approximation of how it works and begin trying to implement it.
@Taintedwisp: Go
Thanks for trying but honestly if it comes to that I'll just forget about trying to figure out the time of day at all.
Already confusing enough. lol
It shouldn't be too difficult. First try displaying the time of day as a string using the Text Message action to see what kind of formatting the string uses (Mille25 described this.) Then try using Convert Integer to Text and Convert String to Integer to see how it prints as an integer.
@BasharTeg: Go
EDIT: So I was able to get the game to print 00:00:09 as time when entering TimeOfDay manually into the string thingamagig. But it is always 00:00:09.
Any ideas why?
EDIT: Haven't tried Game Time. Going to try now.
+: Still nothing.
@Yaksmanofage: Go
This is a SC2 function that returns to you the current game time of day as a string. It is formatted as mentioned above. I printed it to the screen as a test and the default starting time (this map was essentially blank and had no time of day manipulation) was "06:00:00".
Using Mille's function, you can pass the current game time of day to his function, get a numeric value back and compare that against whatever you want... for example noon would be 43200 (3600 * 12).
Here is another example to see if the time is between 5pm and 6pm.
@Yaksmanofage: Go
I apoligize, i should have given you the GUI version from begin on, I was just a bit lazy because in GUI working with texts/arithmetic is a huge pain.
To get back to your problem:
General - Return getTimeOfDaySeconds(lp_timeofday)
To make this work ensure that you do the following:
- Make sure the custom script file with my function is ABOVE your GUI function (So the custom script gets initialized frist)
- When clicking on the return action, select "custom script".
- Once done, type "getTimeOfDaySeconds(lp_timeofday)" in the field
- If you already did all this, make sure the GUI parameter is exactly called "timeofday" and NOT lp_timeofday. The "lp_" automatically gets added by the "compiler" that generates the galaxy script.
- Also make sure your GUI function really returns an integer value and uses "Time of Day" as parameter-type
@soulzek: Go
In GUI he doesnt even need to use seconds to compare the times. He can just enter "12:00:00" and the function will convert it to seconds aswell. This also works in galaxy using strings.
Example:
@soulzek: Go In GUI he doesnt even need to use seconds to compare the times. He can just enter "12:00:00" and the function will convert it to seconds aswell. This also works in galaxy using strings.
Example:
This is true, and does make it more readable (thats what comments are for!), though it is significantly more efficient to just pre-calculate any hard-coded values as the converted number since string parsing and manipulation is slow.
@Mille25: Go
So here is what I have got, I hadn't implemented what Soulzek had suggested mostly because I don't know how:
Here is the timeofday Function:
Here is the Custom Script, which is called TimeOfDaySeconds:
The Custom Script is above the function, the return is Custom Script, and to the best of my knowledge everything was inputted correctly. Yet I still get the same error.
@Yaksmanofage: Go
Try writing "time of day" instead of "Time of Day", the compiler is case-sensitive. :)
@soulzek: Go
"More efficient"... Hehe i really see the C-Programmer here! :)
Even though thats absolutly correct, in this case i would prefer readability. It depends on the use of the function.
@Mille25: Go
haha, that makes me feel special. :B
So everything is working, even Soulzek's suggestion!
Now all I have to do is figure out why my flow of time is so odd. LOL!
Thanks so much, all of you!