Here's what I have so far, it works, but would probably give someone an epileptic fit. Set it as ANY DYNAMIC entity's main script:
;Artificial Intelligence Script
;Header
desc = Flashlight
;Triggers
:State=0:State=1,DimLocalVar=Flashlight,SetVar=FlashLight 0
:KeyPressed=20 1,State=1:SetVar=Flashlight 1,state=2
:KeyPressed=20 0,State=2:State=3
:KeyPressed=20 1,State=3:SetVar=Flashlight 0,state=4
:KeyPressed=20 0,State=4:State=1
:VarEqual=Flashlight 1:EmitFlash,EmitFlash,EmitFlash,EmitFlash
:Always:Hide,LinkToPlr
;End of Script
Press "T" to activate
-TZK