In-Game Timer
Quote from UsCobra11 on August 26, 2012, 1:31 pmHi, I want to create an on-screen timer (Like challenge mode maps) in my map that starts with a trigger, and ends with a trigger. Once the ending trigger is hit, the time stays on the screen for a while, and then fades. What would be an easy, clean way to create this?
Hi, I want to create an on-screen timer (Like challenge mode maps) in my map that starts with a trigger, and ends with a trigger. Once the ending trigger is hit, the time stays on the screen for a while, and then fades. What would be an easy, clean way to create this?
[Released] Power Interference
[Released] Rust and Dust (Spotlight Map!)
[Released] Multiportal
Quote from FelixGriffin on August 26, 2012, 2:07 pmUse 2 game_texts (minute, second) with 2 math_counters and a logic_timer subtracting one from the seconds. OutValue -> game_text -> SetText, OnHitMin -> minutes -> Subtract -> 1, OnHitMin -> !self -> SetValue -> 59 (after 1 second).
Use 2 game_texts (minute, second) with 2 math_counters and a logic_timer subtracting one from the seconds. OutValue -> game_text -> SetText, OnHitMin -> minutes -> Subtract -> 1, OnHitMin -> !self -> SetValue -> 59 (after 1 second).
Quote from UsCobra11 on August 26, 2012, 2:23 pmFelixGriffin wrote:Use 2 game_texts (minute, second) with 2 math_counters and a logic_timer subtracting one from the seconds. OutValue -> game_text -> SetText, OnHitMin -> minutes -> Subtract -> 1, OnHitMin -> !self -> SetValue -> 59 (after 1 second).Is that a timer ticking down? I need a timer ticking up.
Is there a more detailed tutorial somewhere? I'm not that familiar with logic_timers.
Is that a timer ticking down? I need a timer ticking up.
Is there a more detailed tutorial somewhere? I'm not that familiar with logic_timers.
[Released] Power Interference
[Released] Rust and Dust (Spotlight Map!)
[Released] Multiportal
Quote from HMW on August 26, 2012, 2:36 pmhttps://developer.valvesoftware.com/wiki/Logic_timer
https://developer.valvesoftware.com/wiki/Math_counter
https://developer.valvesoftware.com/wiki/Game_textPresto!
(You can easily convert Felix's example to a stopwatch-style timer by reversing the various min/max and add/subtract things.)
https://developer.valvesoftware.com/wiki/Logic_timer
https://developer.valvesoftware.com/wiki/Math_counter
https://developer.valvesoftware.com/wiki/Game_text
Presto!
(You can easily convert Felix's example to a stopwatch-style timer by reversing the various min/max and add/subtract things.)
Other Portal 2 maps: Medusa Glare
Portal 1 maps: Try Anything Twice | Manic Mechanic
Quote from wstrika on August 26, 2012, 3:46 pmWould be nice if you could somehow figure out how to overlay an in-game timer on any map you play...would make recording speedruns of custom maps a lot easier with a more universal timer.
Would be nice if you could somehow figure out how to overlay an in-game timer on any map you play...would make recording speedruns of custom maps a lot easier with a more universal timer.
Quote from FelixGriffin on August 26, 2012, 5:19 pmI could try writing a script to do that, it should be possible using AddOutput and SetX/SetY. Just make something RunScriptCode it, preferably something unmoving. The worldspawn, maybe?
I could try writing a script to do that, it should be possible using AddOutput and SetX/SetY. Just make something RunScriptCode it, preferably something unmoving. The worldspawn, maybe?
Quote from UsCobra11 on August 26, 2012, 5:33 pmFelixGriffin wrote:I could try writing a script to do that, it should be possible using AddOutput and SetX/SetY. Just make something RunScriptCode it, preferably something unmoving. The worldspawn, maybe?Why aren't you community contributor? You are awesome dude, you make great stuff, and you helped me with the most important part in my map. Always volunteering to create amazing things for others.
I'll discuss it with the other mods.
Also... that'd be cool!
Why aren't you community contributor? You are awesome dude, you make great stuff, and you helped me with the most important part in my map. Always volunteering to create amazing things for others.
I'll discuss it with the other mods.
Also... that'd be cool!
[Released] Power Interference
[Released] Rust and Dust (Spotlight Map!)
[Released] Multiportal
Quote from wstrika on August 26, 2012, 6:10 pmFelixGriffin wrote:I could try writing a script to do that, it should be possible using AddOutput and SetX/SetY. Just make something RunScriptCode it, preferably something unmoving. The worldspawn, maybe?Yes, please. That would help a huge amount.
Yes, please. That would help a huge amount.

Quote from ChickenMobile on August 26, 2012, 9:51 pmThe only problem with changing a game_text is that you constantly need to display the game_text in order for it not to 'fade'. I would have the hold time at a second and the fade times at 0 so then you can use the 'Display' input to update every second without the game_text overlaying itself and becoming very bright.
Here's some code I made up if you want to continue working on it. There might be a couple of errors because I haven't actually tested it yet.
- Code: Select all
//Global counter
counter <- 0//Display time
function DisplayText()
{
EntFire( "@DisplayText", "setText", ConvertToFormat(), 0 )
EntFire( "@DisplayText", "Display", "", 0.01 )//Trigger the relay for each second
counter++
//The relay here should just call the DisplayText() function
EntFire( "@DisplayText_Relay", "Trigger", "", 1.0 )
}function ConvertToFormat()
{
//using modulus logic we can figure out hours mins and left over seconds from counter
local modMinuteSeconds = counter % 3600
local hours = (counter - modMinuteSeconds) / 3600
local modSecs = modMinuteSeconds % 60
local mins = (modMinuteSeconds - modSecs) / 60
local secs = modSecslocal Smins = ""
local Ssecs = ""if(mins < 10)
{
Smins = "0" + mins.tostring()
}
else {
Smins = mins.tostring()
}
if(secs < 10)
{
Ssecs = "0" + secs.tostring()
}
else {
Ssecs = secs.tostring()
}//Insert time conversion here from seconds from counter to relevant format 00:00:00
local displayTime = hours + ":" + Smins + ":" + Ssecs
return displayTime
}// Setup Game_Text - called on mapspawn
function SetPos()
{
printl("starting timer")EntFire( "@DisplayText", "SetTextColor", "210 210 210 128", 0.0 )
EntFire( "@DisplayText", "SetTextColor2", "50 90 116 128", 0.0 )
EntFire( "@DisplayText", "SetPosY", "0.85", 0.0 )
EntFire( "@DisplayText", "SetPosX", "0.1", 0.0 )
EntFire( "@DisplayText", "SetText", "00:00:00", 0.0 )DisplayText()
}Ok So it works and I tested it. Here's the script file and all the entities in a .vmf you will need in order to get this to work:
counter.7zI beat you Felix G!
Hope this is what you want UsCobra. You can change the position of the text inside the .nut file.
The only problem with changing a game_text is that you constantly need to display the game_text in order for it not to 'fade'. I would have the hold time at a second and the fade times at 0 so then you can use the 'Display' input to update every second without the game_text overlaying itself and becoming very bright.
Here's some code I made up if you want to continue working on it. There might be a couple of errors because I haven't actually tested it yet.
- Code: Select all
//Global counter
counter <- 0//Display time
function DisplayText()
{
EntFire( "@DisplayText", "setText", ConvertToFormat(), 0 )
EntFire( "@DisplayText", "Display", "", 0.01 )//Trigger the relay for each second
counter++
//The relay here should just call the DisplayText() function
EntFire( "@DisplayText_Relay", "Trigger", "", 1.0 )
}function ConvertToFormat()
{
//using modulus logic we can figure out hours mins and left over seconds from counter
local modMinuteSeconds = counter % 3600
local hours = (counter - modMinuteSeconds) / 3600
local modSecs = modMinuteSeconds % 60
local mins = (modMinuteSeconds - modSecs) / 60
local secs = modSecslocal Smins = ""
local Ssecs = ""if(mins < 10)
{
Smins = "0" + mins.tostring()
}
else {
Smins = mins.tostring()
}
if(secs < 10)
{
Ssecs = "0" + secs.tostring()
}
else {
Ssecs = secs.tostring()
}//Insert time conversion here from seconds from counter to relevant format 00:00:00
local displayTime = hours + ":" + Smins + ":" + Ssecs
return displayTime
}// Setup Game_Text - called on mapspawn
function SetPos()
{
printl("starting timer")EntFire( "@DisplayText", "SetTextColor", "210 210 210 128", 0.0 )
EntFire( "@DisplayText", "SetTextColor2", "50 90 116 128", 0.0 )
EntFire( "@DisplayText", "SetPosY", "0.85", 0.0 )
EntFire( "@DisplayText", "SetPosX", "0.1", 0.0 )
EntFire( "@DisplayText", "SetText", "00:00:00", 0.0 )DisplayText()
}
Ok So it works and I tested it. Here's the script file and all the entities in a .vmf you will need in order to get this to work:
I beat you Felix G!
Hope this is what you want UsCobra. You can change the position of the text inside the .nut file.
Quote from FelixGriffin on August 27, 2012, 8:41 amNice! So far the only thing I have working is creating the entities from the NUT
- Code: Select all
function init(){
timer <- Entities.CreateByClassname("logic_timer"); //The timer
EntFireByHandle(timer,"refiretime","1",0,null,null); //Set the timer to 1 second
EntFireByHandle(timer,"addoutput","targetname felix_script_timer",0,null,null);
text1 <- Entities.CreateByClassname("game_text");
text2 <- Entities.CreateByClassname("game_text");
EntFireByHandle(text1,"addoutput","targetname felix_script_text1",0,null,null);
EntFireByHandle(text2,"addoutput","targetname felix_script_text2",0,null,null);
...etc...I'll change the names to work with your part, then you can run it without anything special in the BSP file. Just bind something to ent_fire worldspawn runscriptfile timerscript.nut and hit it to start the clock.
Nice! So far the only thing I have working is creating the entities from the NUT
- Code: Select all
function init(){
timer <- Entities.CreateByClassname("logic_timer"); //The timer
EntFireByHandle(timer,"refiretime","1",0,null,null); //Set the timer to 1 second
EntFireByHandle(timer,"addoutput","targetname felix_script_timer",0,null,null);
text1 <- Entities.CreateByClassname("game_text");
text2 <- Entities.CreateByClassname("game_text");
EntFireByHandle(text1,"addoutput","targetname felix_script_text1",0,null,null);
EntFireByHandle(text2,"addoutput","targetname felix_script_text2",0,null,null);
...etc...
I'll change the names to work with your part, then you can run it without anything special in the BSP file. Just bind something to ent_fire worldspawn runscriptfile timerscript.nut and hit it to start the clock.