another timer question

Blitz3D Forums/Blitz3D Programming/another timer question

stayne(Posted 2007) [#1]
After 3 seconds of holding the mouse over an entity I want that entity to be targeted as long as the mouse is held over it. My brain is fried... anyone have an idea? I'm working with types. Here's my non-working pathetic code (I realize targettimer is always set to millisecs... this is where I'm stuck)...

CameraPick(x\camera,MouseX(),MouseY())

For b.bot = Each bot
  If PickedEntity() = b\entity And MilliSecs()=>targettimer+3000
    b\targeted=True
    Text GraphicsWidth()/2,GraphicsHeight()/2,"targeted"
  Else
    b\targeted=False
    targettimer=MilliSecs()
  EndIf
Next



_33(Posted 2007) [#2]
targeted must be initiated on the following case:
if then entity is picked and targeted = false

then initiate and put your timer value to timer() + 3000 there. Do not test timer() + 3000 every time...


stayne(Posted 2007) [#3]
Still over my head at the moment, but thanks alot.


_33(Posted 2007) [#4]
Sorry I changed my reply.


stayne(Posted 2007) [#5]
Still very confused...

CameraPick(x\camera,MouseX(),MouseY())

For b.bot = Each bot
	If PickedEntity() = b\entity And b\targeted = False
		targettimer=MilliSecs()+3000
			If MilliSecs()=>targettimer
				b\targeted=True
				Text GraphicsWidth()/2,GraphicsHeight()/2-40,"targeted"
			EndIf
	Else
		b\targeted=False
		targettimer=MilliSecs()
	EndIf

Next



stayne(Posted 2007) [#6]
Finally! Man I must be getting old.

CameraPick(x\camera,MouseX(),MouseY())

For b.bot = Each bot
	If PickedEntity() = b\entity
		If MilliSecs()=>targettimer
			b\targeted=True
			Text GraphicsWidth()/2,GraphicsHeight()/2-40,"targeted"
		EndIf
	Else
		b\targeted=False
		targettimer=MilliSecs()+3000
	EndIf
Next



_33(Posted 2007) [#7]
That's true you needed the text to appear every time. Good job!