Jump to content

Creating a basic lock door script?


Azurahawk

Recommended Posts

So I just hoped back into modding again with some programming experience between java, c#, and c++. It's time for me to start scripting.

So I glanced at the logic that the Bethesda wiki provided for the Skyrim language. I understand, and possibly know exactly what to use; however, I am unsure how to execute it. The objective is simple: When the Player opens this door that I named as a reference: lustTrickDoor, when the player insides the house the door locks, forcing the player to kill one or all the bandits in the house to escape. Doing this requires a script triggering this event.

 

Here's what I have planned:

 

Scriptname LustTrap extends Objectreference

 

function ActorOpenDoor(Actor PlayerRef)

if Player == (Need to figure out the code for door)

          lustTrickDoor.locked();

else

          lustTrickDoor.unlocked();

endif

endfunction

 

Pretty self explanatory. Catch is, how can I implement this? Under the quest database? Or should I create a triggerbox and change the format of the script to where the player must be present? That's my issue is where to put the script, and putting it to where it can be used.

Link to comment

You would attach the script to the instance of the door in the creation kit (not the base object) and use an OnActivate(ObjectReference akActionRef) event to start your script as soon as someone activates the door. You then have to check for the player via

akActionRef == Game.GetPlayer()

Note that akActionRef is the actor that is returned by the OnActivate event. 

 

If you have some programming experience I recommend looking at the complete example scripts section in the wiki. If you know C and java well Papyrus is pretty self-explanatory.

 

Btw. you can not simply name an Object in the creation Kit and then use the name in the script.

LustTrickDoor.look() does not work. You would need to make the door a property first:

ObjectReference Property LustTrickDoor Auto

and fill the property within the creation kit with the right door. In your case you should be able to use self.look() as well. 

A triggerbox behind the door works the same way, except you would use the Event OnTriggerEnter(ObjectReference akActionRef).

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use