SKSE Script Function Question

Post » Tue Jan 29, 2013 5:16 am

Hi there

I have been trying to create a script that initiates after the play presses a key. To do this I was forced to script like a child having a RegisterForUpdate loop to detect this (see code below).
Spoiler
Event OnInit()
Debug.Notification("Initialised")
RegisterForKey(13)
RegisterForUpdate(2)
EndEvent
Event OnUpdate()
if Input.IsKeyPressed(13)
Possession()
else
debug.notification("sorry")
endif
EndEvent
I did research and came across the SKSE functions called RegisterForKey and OnKeyDown. Reading the wiki's on them I tried out a demo code as shown below
Spoiler

Event OnInit()
RegisterForKey(12)
Debug.MessageBox("Step1")
EndEvent

Event OnKeyDown(int Keycode)
if Keycode == 12
Debug.MessageBox("Working")
endif
EndEvent
Unfortunately there is no evidence of it working and I have tried numerous alterations to the code which has left me wondering whether the OnKeyDown function can be used as an Event. Have I missed something? :confused: Any help would be greatly appreciated
User avatar
Chloe Lou
 
Posts: 3476
Joined: Sat Nov 04, 2006 2:08 am

Post » Tue Jan 29, 2013 6:48 pm

The events won't work in a ReferenceAlias script. They have to run on something that can be reduced to a Form type. I put mine in a quest script and it worked fine.
User avatar
m Gardner
 
Posts: 3510
Joined: Sun Jun 03, 2007 8:08 pm

Post » Tue Jan 29, 2013 12:32 pm

Oh wow I will try that now if that is true then you have rescued me from hours of confusion. I have never quite understood how/why the scipt type restricts the function use. One concern I have is that the mod I am making is to allow you to take control of a NPC and uses some of the ReferenceAlias functions how can I work around this? is there a way to reference or call on other scripts?
User avatar
Queen of Spades
 
Posts: 3383
Joined: Fri Dec 08, 2006 12:06 pm


Return to V - Skyrim