Jump to content

How do I use SKSE's OnKeyDown event from a quest script?


falconfetus8

Recommended Posts

Lots of googling around yielded me no answers. I've got a quest script running, but it isn't responding to any key events. Do key events even work in quest scripts? Is there something else I need to do inside the Creation Kit to make it work? I'm not getting any compiler errors, so I'm really confused about this.

 

Here is my code. The OnInit and OnUpdate events work, but the OnKeyDown event does nothing.

Scriptname FALC_CheckpointQuestScript extends Quest  

	Import Input

	float Property xPos auto hidden
	float Property yPos auto hidden
	float Property zPos auto hidden
	
	Cell Property checkpointCell auto hidden
	
	Event OnInit()
		Debug.Notification("BONFIRE LIT")
		SaveCheckpoint()
		
		RegisterForSingleUpdate(10)
	endEvent
	
	Event OnUpdate()
		Debug.Notification("YOU DIED")
		LoadCheckpoint()
	endEvent
	
	Event OnKeyDown(int keycode)
	
		;Save checkpoint when 'N' key is pressed
		if (keycode == 49)
			Debug.Notification("BONFIRE LIT")
			SaveCheckpoint()
		endIf
	
		;Load checkpoint when whatever the next key is is pressed
		if (keycode == 50)
			Debug.Notification("YOU DIED")
			LoadCheckpoint()
		endIf
	
	endEvent
	
	Function SaveCheckpoint()
		;Remember the current position and cell
		
		Actor akPlayer = Game.GetPlayer()
		
		xPos = akPlayer.GetPositionX()
		yPos = akPlayer.GetPositionY()
		zPos = akPlayer.GetPositionZ()
		
		checkpointCell = akPlayer.GetParentCell()
	
	endFunction
	
	Function LoadCheckpoint()
		;Return to the saved checkpoint
		
		Actor akPlayer = Game.GetPlayer()
		
		;TODO: Change cells
		
		;Change position
		akPlayer.SetPosition(xPos, yPos, zPos)
		
		;TODO: Resurrect all dead actors
	
	endFunction
Link to comment
Share on other sites

  • Recently Browsing   0 members

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