Time Counter

Blitz3D Forums/Blitz3D Programming/Time Counter

doberdog(Posted 2009) [#1]
I have a problem. I need a time counter between a keypress to change a variable 3 seconds before. But


If Battle%= 1 And Stado%=3 Then 
	oldTime=MilliSecs()
While  MilliSecs() < (oldTime + 3000)

			Battle%=0
			combatvalue=0
			Text 
	Wend
EndIf


Did not work, because it pause all the game.

Can you help me?


RifRaf(Posted 2009) [#2]
if keyhit(whatever)then oltime#=millisecs()+3000


if oldtime#<millisecs() then
 ; stuff here will happen for 3 seconds
endif



stanrol(Posted 2010) [#3]
what does % do?


Gabriel(Posted 2010) [#4]
Please stop bumping ancient threads when you have nothing to add to them. You could very easily have started a new thread to ask that question.

The % symbol specifies that the variable being declared is an integer.


ClayPigeon(Posted 2010) [#5]
It's also unnecessary. The % only needs to follow the name of the variable when you first declare it. After it's been declared, it's purely redundant and can be omitted.


big10p(Posted 2010) [#6]
It's also unnecessary. The % only needs to follow the name of the variable when you first declare it. After it's been declared, it's purely redundant and can be omitted.
You don't even have to use it then as integer is the default variable type.


ClayPigeon(Posted 2010) [#7]
Really? I didn't know that. I thought that a variable without a type became the type of the first value given to it. (e.g. var = 0.25, then var becomes a float)


_PJ_(Posted 2010) [#8]
Yeah Big10p's right...
I thought the same as you, Clay but I just tried the following:

var=0.25
Print var


Returns 0

Just to make sure...
var=0.25
Print var#


Error: Variable Type Mismatch


jfk EO-11110(Posted 2010) [#9]
And while we're at it:

if keyhit(whatever)then oltime#=millisecs()+3000
if oldtime#<millisecs() then
 ; stuff here will happen for 3 seconds
endif


Better use Integers whenever you are working with Millisecs(). You probably run into NAN, rounding errors and other stuff when you feed a float with very high or low integers (eg. -1800333222).