Jump to content

Multiple Activators using different keys


Recommended Posts

Hi everyone,

 

I didn't manage to find the answer to this question so I'll ask here.

 

Is it possible to add multiple activators on a single object triggered by different keys ?

 

For instance, an activator is triggered when the player presses the "Use" key while facing the object ("E" by default), but would it be possible to add another action activated by a different key ("R" or "T" for example). I don't recall any mod doing anything like that and usually packaging the scripts they need in spells that can be cast on the object to bypass the need for a second activator.

 

If it's not possible to add an activator on a second key, would it be possible through Papyrus to detect key pressed at the moment the script is trigger, that would allow the use of "Shift + E" / "Ctrl + E" kind of combinations, allowing to package more than one action in the same Activator script.

 

Thanks in advance,

 

 

Link to comment
Share on other sites

You can use SKSE's OnKeyDown event to trigger various things (it needs to be coupled with RegisterForKey too). But this event will happen whenever that key is pressed. As a result you'll need to have a condition to rule out processing when you do not want it to work. And if you want it to work with a specific object, you'll need another condition to ensure that the crosshair target is the intended object. It isn't impossible but isn't exactly easy either.

 

Most people will use a perk entry point to add an option to an activation menu (the menu is created automatically). See the Ring of Namira. It adds the option to eat corpses alongside the default loot option.

Link to comment
Share on other sites

Thank you Ishara,

 

The onKeyDown solution doesn't look really optimized, from a programming standpoint it's not a good practice to add a trigger on a key that could serve other purposes, since the script will be fired every time you press the key and test for a condition, plus it might get overridden by other scripts trying to do the same thing elsewhere.

 

I checked on the ring's behavior and it could actually fit my purpose, I'll try to implement it in my mod.

 

Have a great day :happy:,

Link to comment
Share on other sites

Ok I found another way to get this done somehow so I figured I would share it here.

 

You can apply a script on the desired object, in that script you can add a MESG Object as a parameter, this Object will contain the choices that will be displayed in your menu. Then you add it to the OnActivate() Event in your script using the .Show() method of the MESG Object (ie : int buttonpressed = <MESG>.Show()), this will display a choice menu just like the one created by the perk entry point mentioned above, then you just need to test the result (buttonpressed) to dispatch the required actions from their menu item position.

 

Thanks for the help, it got me to the right place.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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