Difference between revisions of "Key input"

2,765 bytes removed ,  06:21, 26 April 2009
Discussion on Article page turned into article.
imported>DragoonWraith
imported>Gregbert
(Discussion on Article page turned into article.)
 
Line 1: Line 1:
{{Deprecated Article|Key input is now best handled by [[Oblivion Script Extender]].}}
{{Deprecated Article|Key input is now best handled by [[Oblivion Script Extender]].}}
{{Discussion}}


I need to know how (and if) I can handle key input via script. I need to have both swords with ranged attacks and guns with night vision, so I need ether an alternate fire or a mode change button... but Oblivion has neither. Is there any way key input can be handled? --[[User:Bky|Bky]] 06:40, 30 May 2006 (EDT)
If you wish to detect a key input without [[OBSE]], then the best way to go about this is to detect what the effect of this key press would be. For example, if you want to detect the pressing of the Ctrl button, then your best best would be to detect Stealth (assuming that the player has Ctrl set to activate Stealth Mode). Using stealth as an example:
 
:[[User:DragoonWraith|<font face="Oblivion,Daedric" size=3>D</font>ragoon <font face="Oblivion,Daedric" size=3>W</font>raith]] [[User_talk:DragoonWraith|<font face="Oblivion,Daedric" size=2>TALK</font>]] 12:15, 30 May 2006 (EDT): Nope, there's absolutely no way to detect key presses. Luckily for you (sort of), there wasn't in Morrowind, either, and as you might imagine, this was something a lot of people wanted to do. So, your best bet is to detect something you can detect - Sneaking is easiest. Try something like this:


<pre>short sneak
<pre>short sneak
Line 35: Line 32:
End</pre>
End</pre>


:Basically, "switch" gets increased every time the player hits the Ctrl key (or whatever they have "Sneak" mapped to), and if they hit it four times (I figure no one would hit Sneak four times unless they were deliberately trying to), you activate your code to switch weapon mode or night vision or whatever you're doing.
However, it is impossible (without [[OBSE]]) to detect a key press without the key having an effect. If this is your aim, then [[OBSE]] must be used.
 
::I'm not sure how to do this, or if this is even possible, but maybe with your dual swords idea, you can have right-click set for the left-hand weapon/shield.  Does anybody know?[[User:TheImperialDragon|TheImperialDragon]] 17:20, 30 May 2006 (EDT)
 
:::[[User:DragoonWraith|<font face="Oblivion,Daedric" size=3>D</font>ragoon <font face="Oblivion,Daedric" size=3>W</font>raith]] [[User_talk:DragoonWraith|<font face="Oblivion,Daedric" size=2>TALK</font>]] 20:26, 30 May 2006 (EDT): I have my right-click set to Cast and middle-click (the mousewheel) set to block.
 
::::That should work perfectly, thank you. As for dual swords.. I needed that too, but just planned to make sword #2 a shield (yet in the story they are both used as sheilds/weapons as needed...). If you come up with anything let me know. :) --[[User:Bky|Bky]] 17:45, 30 May 2006 (EDT)
 
With the new [[:Category:Oblivion Script Extender|script extender]], you can easily detect key presses. --[[User:Cid88|Cid88]]
 
:So, As I understand it, this script will detect "switching" inside a 2 second time frame? I am trying to use a timer in a script of my own and am having little luck, just trying to amass as much information as I can and hopefully I will figure it out. I also posted on the [[GetSecondsPassed]] Page if it is more appropriate to reply there.
::--[[User:Antares|Antares]] 10:16, 4 September 2008 (EDT)


:::The script detects when the player rapidly presses the Sneak key, releases it, and presses and releases it again in quick succession, namely two seconds in this case. The timer is there to undo the counts if more than two seconds go by, because you want to make sure the player intended to double-tap the key and not actually just sneak.
==See Also==


:::As the header thing says, however, OBSE would be a much better system for getting key input.
* [[GetKeyPress]]
:::[[User:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">D</span>ragoon <span style="font-family: Oblivion, Daedric Runes; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">TALK</span>]] 17:28, 4 September 2008 (EDT)
Anonymous user