[REQ] Lockable Door Script

Post » Wed Jun 20, 2012 12:09 pm

When I modded Oblivion I had a lockable door script that enabled the player to relock a door with the key. I am not particularily good at scripting, so wondered if someone who is, could please write such a script for me?

Not sure if it helps, but this is the lockable door script I used in Oblivion...

Spoiler
ScriptName ComplexSecretDoorScript

ref mySelf
short button

begin OnActivate
set mySelf to GetSelf
if IsActionRef Player == 1 && mySelf.GetOpenState == 3
if mySelf.GetLocked ==1 && player.GetItemCount SecretDoorKey > 0
mySelf.UnLock
Message " You unlock the door with a key."
mySelf.Activate Player
elseif mySelf.GetLocked == 0 && Player.GetItemCount SecretDoorKey > 0
MessageBox "Would you like to open or lock the door?", "Open", "Lock", "Cancel"
elseif mySelf.GetLocked == 1 && Player.GetItemCount SecretDoorKey == 0
Message " You need a key to unlock this door."
else
mySelf.Activate Player
endif
else
mySelf.Activate
endif
end

begin GameMode
set button to GetButtonPressed
if button > -1
if button == 0
mySelf.Activate Player
elseif button == 1
mySelf.Lock 100
Message " You lock the door with a key."
endif
endif
end
User avatar
victoria johnstone
 
Posts: 3424
Joined: Sat Oct 14, 2006 9:56 am

Post » Wed Jun 20, 2012 7:48 am

Hi Meek :)

Check out this tutorial I made, it sort of does what you want, with a little tweaking would work.
Its a tutorial on making your first script that 'does' something in the game, unlike the 'hello world' tutorials that really don't put the pieces of the puzzle together.

This tut will show you how to make your message objects, and how to make your script object. You then attach the script object to the door, and then set the message properties on the script object, that is on the door. Sounds complicated but this tut should help. And once you get that down, setting the lock levels on the door should be a snap.

TESAlliance Papyrus 101 forum:
http://tesalliance.org/forums/index.php?/topic/4697-class-1-start-here-for-basics/
User avatar
Heather Kush
 
Posts: 3456
Joined: Tue Jun 05, 2007 10:05 pm

Post » Wed Jun 20, 2012 11:22 pm

That looks like an excellent tutorial. The sort of step by step guide that I and others who need things spelling out step by step, can actually work through. Thanks! I shall get started. :)
User avatar
Kit Marsden
 
Posts: 3467
Joined: Thu Jul 19, 2007 2:19 pm


Return to V - Skyrim