Jump to content

How to start a script with the pressing of a key


Recommended Posts

I think you would use it like this:

 

if (OnKeyDown 47)
;do stuff
endif

 

I'm not exactly sure though... In the OBSE documentation, it says that it only returns 1 for one frame. So that would mean that your script would need to be running every frame to catch it right? But on the CS Wiki it says that it works like GetGameLoaded. I've used GetGameLoaded before it quest scripts, and quest scripts only run once every 5 seconds (or whatever fquestdelaytime is set to).

Link to comment
Share on other sites

I just tested it with the example script I posted and it worked. More specifically, I had to keep the key pressed for a few seconds before it worked.

 

Then I changed the script to this:

 

scn somescript

float fquestdelaytime

Begin GameMode

if (fquestdelaytime != 0.01)
set fquestdelaytime to 0.01
endif

if (OnKeyDown 47)
Player.ModAV Strength 10
endif

End

 

This changed it so it ran 100 times per second. It detected the key press right after I pressed it. This proves that the article on CS wiki is wrong and the OBSE documentation is right. It only returns 1 for one frame, which is why it only works properly after I changed the script to run so often.

Link to comment
Share on other sites

  • 9 years later...

is there a chart somewhere to know what number i need to type in for a different key? so 47 is the v key, what would the k key be?

 

I also need some help with my script to work

 

scn OnKeyDownHelpScript

 

short key

 

Begin GameMode

 

if OnKeyDown 47 == 1
set key to 1
elseif OnKeyDown 47 == 0
set key to 0
endif
If key == 1
player.equipitemsilent Item
elseif key == 0
player.unequipitemsilent Item
endif
End
I want the item to only be equipped while holding the v key down.
Edited by CountryRoberts
Link to comment
Share on other sites

Yes there is. I do not know where I got it from as it is included in one mod (I found it as well) but it is also at CS Wiki (Took some damn time to find this one for sure :wink: ) and also maybe at UESP but now I cannot find it (I did). The common ascii-table will also work as reference but that page is also loaded with advertising... :wink:

 

I was lucky I guess, the Enhanced hotkey's documentation did point it out. :wink: Very very cool mod indeed by the way that makes life MUCH easier.

Edited by Pellape
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...