another timer question
Blitz3D Forums/Blitz3D Programming/another timer question| 
 | ||
| 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
 | 
| 
 | ||
| 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... | 
| 
 | ||
| Still over my head at the moment, but thanks alot. | 
| 
 | ||
| Sorry I changed my reply. | 
| 
 | ||
| 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 | 
| 
 | ||
| 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 | 
| 
 | ||
| That's true you needed the text to appear every time.  Good job! |