Script keep track of game time?
Moderator: Moderators
- HDL_CinC_Dragon
- Brigadier General
- Posts: 574
- Joined: Mon Dec 22, 2003 8:32 pm
Script keep track of game time?
Is it possible for the script to know how much time has gone by in the game? So can you have something like suddenly a wall falls down somewhere at like 0:3:30 minutes game time? or things like that?
wait
Use "wait" and the number of seconds.
//----------------------------------------------------
Example:
wait 210
thread global/exploder.scr::explode 1
end
//----------------------------------------------------
You can also set a random wait time.
wait (randomfloat 180 + 240) // 3 to 4 minutes
//----------------------------------------------------
Example:
wait 210
thread global/exploder.scr::explode 1
end
//----------------------------------------------------
You can also set a random wait time.
wait (randomfloat 180 + 240) // 3 to 4 minutes
- HDL_CinC_Dragon
- Brigadier General
- Posts: 574
- Joined: Mon Dec 22, 2003 8:32 pm
I did a search for time and game time but got no hits related at all to what I needed. Guess I should have searched something else.wacko wrote:think there's loads of examples here in the forum. Why not use the search button and try to find things like clock, timer...
Thanks Tom, that is what im going to do.
Not tested ingame but I think something like this would work
Code: Select all
main:
level waittill spawn
thread game_time
thread wall_fall
end
wall_fall:
while(1)
{
if (level.minutes == 3 && level.seconds == 30)
exec global/exploder.scr::explode 1
if (level.minutes == 5 && level.seconds == 30)
{
exec global/exploder.scr::explode 2
end
}
waitframe
}
end
game_time:
level.minutes = 0
level.seconds = 0
while(1)
{
wait 1
level.seconds++
if (level.seconds == 60)
{
level.minutes++
level.seconds = 0
}
}
endWhy not use level.time ??
I recommend defining a level.starttime after level waittill spawn (dm matches) or level waittill roundstart (obj), e.g.
level waittill spawn or roundstart
level.starttime = level.time
and then at any later stage finding the time after spawn or roundstart as:
level.time-level.starttime

I recommend defining a level.starttime after level waittill spawn (dm matches) or level waittill roundstart (obj), e.g.
level waittill spawn or roundstart
level.starttime = level.time
and then at any later stage finding the time after spawn or roundstart as:
level.time-level.starttime



