Jump to content

Recommended Posts

Posted

I'm a noob in Papyrus and I'm trying to make so that when the player presses a key in the keyboard like X, Y or whatever, a function from my script is executed. I tried it several times using stuff like RegisterForKey, OnKeyDown, Input.IsKeyPressed, but none worked. I also searched on Google, topics on the forum and in the documentation, but I'm having no luck so far. Everything works fine but the input. I'm not sure, but i think it's because I'm trying to do it in a script that extends from Quest. Can someone give me an explanation or an example piece of code pls? thx in advance

Posted

Tested this with a quest script

 

 

Event OnInit()
 
RegisterForKey(45) ; X key
 
EndEvent
 
Event OnKeyUp(Int KeyCode, Float HoldTime)
   
    if KeyCode == 45 ; not necessary but out of habit
 
        debug.trace("KeyCode: " +KeyCode+ " Holdtime: " +HoldTime)
   
    endif
EndEvent

 

From my log:

 

[02/23/2018 - 07:47:56AM] KeyCode: 45 Holdtime: 0.134000
[02/23/2018 - 07:48:02AM]

 

You might be confusing key input with UI input... I think.

Posted (edited)
  On 2/23/2018 at 1:42 PM, candlepin said:

Sorry for asking, but you have SKSE installed and working properly, right? RegisterForKey won't work without this.

Lol, you just made me remember that I had overwritten the skse scripts with the vanilla ones from the rar file, thx dude I was never going to notice.

 

 

  On 2/23/2018 at 5:53 AM, Rasikko said:

Tested this with a quest script

Event OnInit()
 
RegisterForKey(45) ; X key
 
EndEvent
 
Event OnKeyUp(Int KeyCode, Float HoldTime)
   
    if KeyCode == 45 ; not necessary but out of habit
 
        debug.trace("KeyCode: " +KeyCode+ " Holdtime: " +HoldTime)
   
    endif
EndEvent

From my log:

[02/23/2018 - 07:47:56AM] KeyCode: 45 Holdtime: 0.134000
[02/23/2018 - 07:48:02AM]

You might be confusing key input with UI input... I think.

Just realized that I had also mistyped the OnInit section.

 

Thanks candlepin, Rasikko and NexusComa for the help and replies :smile:

Edited by KotoShamisen
Posted
  On 2/23/2018 at 8:33 PM, KotoShamisen said:

 

  On 2/23/2018 at 1:42 PM, candlepin said:

Sorry for asking, but you have SKSE installed and working properly, right? RegisterForKey won't work without this.

Lol, you just made me remember that I had overwritten the skse scripts with the vanilla ones from the rar file, thx dude I was never going to notice.

 

 

  On 2/23/2018 at 5:53 AM, Rasikko said:

Tested this with a quest script

Event OnInit()
 
RegisterForKey(45) ; X key
 
EndEvent
 
Event OnKeyUp(Int KeyCode, Float HoldTime)
   
    if KeyCode == 45 ; not necessary but out of habit
 
        debug.trace("KeyCode: " +KeyCode+ " Holdtime: " +HoldTime)
   
    endif
EndEvent

From my log:

[02/23/2018 - 07:47:56AM] KeyCode: 45 Holdtime: 0.134000
[02/23/2018 - 07:48:02AM]

You might be confusing key input with UI input... I think.

Just realized that I had also mistyped the OnInit section.

 

Thanks everyone for the help and replies! :smile:

 

 

Glad I was able to help! Lord knows I've received more than my fair share of help here!

  • Recently Browsing   0 members

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