Using a script to add new game logic

Post » Sat Jun 02, 2012 8:21 am

Hi guys, this is a pretty simple question from someone just getting started but I can't seem to find a complete enough answer on the forums, so I'm posting it here.

The idea i'm stuck with is the following:

I want to have a script that runs continuously (i.e. while loop) when the game runs. The ideia is that it's listening for certain inputs (using the SKSE input functionalities) and once they are pressed, it triggers an event in the game world. A simple example would be:

while(true){
if isKeyPressed('0')
killLightsInRadius(20)
elif
...
}

The part I'm not sure how to do is making the script run as soon as the game is loaded.. I understand that you can make a script run if you attach it to a quest (or any other thing for that matter), but as you've seen this is not what I had in mind. This is probably a stupid question, but thanks for your help anyway :D
User avatar
Amy Masters
 
Posts: 3277
Joined: Thu Jun 22, 2006 10:26 am

Post » Fri Jun 01, 2012 11:05 pm

Hi guys, this is a pretty simple question from someone just getting started but I can't seem to find a complete enough answer on the forums, so I'm posting it here.

The idea i'm stuck with is the following:

I want to have a script that runs continuously (i.e. while loop) when the game runs. The ideia is that it's listening for certain inputs (using the SKSE input functionalities) and once they are pressed, it triggers an event in the game world. A simple example would be:

while(true){
if isKeyPressed('0')
killLightsInRadius(20)
elif
...
}

The part I'm not sure how to do is making the script run as soon as the game is loaded.. I understand that you can make a script run if you attach it to a quest (or any other thing for that matter), but as you've seen this is not what I had in mind. This is probably a stupid question, but thanks for your help anyway :biggrin:
I believe the SKSE team is working on an OnKeyPressed event so you could use that when it's available
User avatar
Breanna Van Dijk
 
Posts: 3384
Joined: Mon Mar 12, 2007 2:18 pm

Post » Sat Jun 02, 2012 7:10 am

You will have to create a quest and check the "start game enabled" box.

Then, put your script inside an event block. Currently there is only an OnInit event that runs only when the script is first loaded, but patch 1.6 introduces an OnGameLoad event, so the script will carry across saves.

When SKSE works out how to implement new events, you'll want to just put your logic inside an OnKeyPress event block, but until then you will have to poll IsKeyPressed.
User avatar
CORY
 
Posts: 3335
Joined: Sat Oct 13, 2007 9:54 pm


Return to V - Skyrim