Script keep track of game time?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Script keep track of game time?

Post by HDL_CinC_Dragon »

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?
Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

think there's loads of examples here in the forum. Why not use the search button and try to find things like clock, timer...
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

wait

Post by tltrude »

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
Tom Trude,

Image
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

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...
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.




Thanks Tom, that is what im going to do.
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

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
}
}
end
Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Why 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

:)
Image
Post Reply