Talk:IsControlPressed
Active discussions
Revision as of 08:11, 22 September 2008 by imported>Shademe
Detecting the second control pressed ?Edit
How do I detect if a second control was pressed ( not held down ) when detecting the 1st control pressed , i.e., I'm holding down the grab key and I want to check if the activate key was pressed during that time, when I was holding the grab key ... -- shademe 08:19, 18 September 2008 (EDT)
if ( IsControlPressed 28 ) if ( OnControlDown 5 ) ;code goes here endif endif
- Dragoon Wraith TALK 08:43, 18 September 2008 (EDT)
- Thanks for the quick reply ! But that didn't work :( Tried that before - that clause didn't activate when I pressed the activate key. Think how fast the script runs has something to do with this ? I'm right now running this in a quest script, DelayTime = 0.001, almost once every frame...
- -- shademe 08:55, 18 September 2008 (EDT)
- I ran into a similar problem with GetNumKeysPressed. There are a lot of issues here
- When you activate an item GetCrosshairRef will return 0 for a few frames.
- Mice keys are detected a frame after keyboard keys with the gen-3 input functions (IKP3, On...Down, control functions) - if you're using both types there may be timing errors.
- IIUC, for mouse buttons, the gen-3 input functions use the same system as GetNumKeysPressed, which means you'll have problems detecting fast clicks no matter how you look at it.
- My suggestion - instead of checking for the player pressing grab, see if there is a grab animation (maybe Dynamic Idle or Special Idle) and check for that. Then check for activation.
- By the way, activation check should look like
set ActAltKey to (GetAltControl2 5) if (ActAltKey == 256) set ActAltKey to 1 elseif (ActAltKey == 257) set ActAltKey to 2 elseif (ActAltKey == 258) set ActAltKey to 4 endif if (IsControlPressed 5) || (IsKeyPressed ActAltKey) ;IKP2/ICP messes with GetCrosshairRef unless IKP catches the mouse key if (ActKeyDoOnce == 0) set ActKeyDoOnce to 1 if (ActAltKey > 258) ;If an extra mouse button is used, will need to keep trying to unlock until GetXRef returns a valid reference if (IsKeyPressed2 ActAltKey) set P1DkeyUnlock.KeepTrying to 1 endif endif P1DkeyUnlock.Activate cobGenActRef, 1 endif elseif P1DkeyUnlock.TappedKey set P1DkeyUnlock.TappedKey to 0 set ActKeyDoOnce to 1 ;In case the player let go of the button before GetXRef returned a valid reference, or went into a menu elseif ActKeyDoOnce set ActKeyDoOnce to 0 endif
- --Haama 11:13, 18 September 2008 (EDT)
- You might want to elaborate on the grab animation piece a little more, I don't really understand. In fact, I didn't know that grabbing had an animation
- -- shademe 03:36, 19 September 2008 (EDT)
- I don't know if there is one or not - what I mean is you may want to start looking for another way to detect either grabbing or activating. Another possibility - keep detecting grab as before (grab key) but keep using HasBeenPickedUp and/or IsFormValid to see if the reference has left the world (presumably by being activated). If those don't work, see if there is a grab animation - you can the animation debug file here to see if there is one.
- --Haama 23:08, 20 September 2008 (EDT)
- THat's what I'm doing - I have a quest script checking whether the grab key is being held down and if it is, I'm (trying to) checking whetehr the grabbed item is activated. Anyway, I was thinking of checking encumbrance of the PC as a workaround -- shademe 09:11, 22 September 2008 (EDT)