Difference between revisions of "Talk:IsControlPressed"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Haama
imported>Haama
Line 12: Line 12:
::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...
::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...
::-- [[User:Shademe|shademe]] 08:55, 18 September 2008 (EDT)
::-- [[User:Shademe|shademe]] 08:55, 18 September 2008 (EDT)
:I ran into a similar problem with [[Talk:GetNumKeysPressed|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
:--[[User:Haama|Haama]] 11:13, 18 September 2008 (EDT)

Revision as of 10:13, 18 September 2008

Detecting the second control pressed ?

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
  1. When you activate an item GetCrosshairRef will return 0 for a few frames.
  2. 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.
  3. 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)