Talk:Lock

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

I've noticed that, at least when used in the console, this function doesn't behave exactly as described. If an object is locked, then calling Lock 50 doesn't seem to lock it 50 pts; rather, it adds 50 to the current lock level. It seems to work the same way for objects which are unlocked via console. If an object is locked 20 pts, and i call unlock, followed by Lock 50, its lock level becomes 70. I have a suspicion this may be an issue specific to doors which are owned and therefore locked and unlocked by NPCs, and I'm hoping it's just an issue with the console. Scruggs 23:31, 26 May 2006 (EDT)

Problem[edit source]

I'm having a very odd problem. I created a new interior cell (using the interior set like in most castle dungeons) with, among other things, a PrisonCellDoor. I didn't change the base at all, just gave it a persistent reference name and tag. The problem is this; no matter what value I set the lock to in the construction set, it fails to have any effect. Further, using the script command Lock does nothing, as with the console command. I do have some observations using Lock, GetLockLevel and GetLocked.

There are essentially four states the door can be in: closed, opening, open and closing. When the door is opening or open and Lock is called (with any value), it instantly changes to a closed state. When the door is closed, GetLockLevel returns the value to which it was set with Lock, but GetLocked always returns 0. The only time GetLocked will ever return true is in fact when the door is closing while Lock is called. Then and only then will the lock icon appear on the hud when looking at the door. Any guesses? Innominate 07:38, 26 June 2008 (EDT)

Pretty sure I've got a solution. In a mod that I am currently working on for release I have a chest against which the player can train their Security Skill. It is strikingly similar to a chest found in Dunbarrow Cove, funny that huh. Anyway, the script I wrote for the chest worked perfectly early on in the development of the cell in which it is located. Then, all of a sudden the chest refused to lock itself under any circumstances, its will was sufficient to defy the almighty console!
Anyway I had a good hard think about what I possibly could have altered to have precipitated this anomaly. It would seem that "Cell Ownership" and the "Off Limits" flag are major players in our dilemna. Once I changed the Cell Ownership from Player to NONE everything worked fine. Hope this helps.
--Antares 03:43, 6 September 2008 (EDT)

Solution[edit source]

Innominate's Problem may exist for several reasons. I encountered similar issues in a mod of my own. The following precedure seemed to fix the problem entirely.
Check:

1. If the owner of the cell which contains the reference you want to lock happens to be the Player, Lock/GetLocked may not work as expected.
2. The Off Limits flag may play some part in this. In my mod I had a cell marked as off limits then changed it back simultaneously with "cell ownership".

Solution:

There are two ways in which I can see to circumvent any issues.
A. Make sure the cell is not owned by player (playerfaction might produce anomalies too).
B. When calling "Lock" on a reference inside a cell that does belong to the player, make sure the LockAsOwner flag is specified. Using the player as the owner probably wont work.

If the above does not provide a solution, read whole page again, post here if necessary, or on my user page.
Much love --Antares 03:43, 6 September 2008 (EDT)

A year later and confirmation from two independent tests show that this command absolutely will not work unless the CELL is set to owned by NONE. It cannot have ownership set by any NPC or faction or the door will simply fail to lock. I would presume the same is also true for unlocking. So if you absolutely MUST have a door locked via script, there's only one way out. Which means you also need to set ownership of any loose items in the CELL to owned by the NPC/Faction or they won't get counted for thefts. Arthmoor 23:00, 15 December 2009 (EST)

Player Ownership[edit source]

If the Player is the owner of the door ( or container ), or if the Player is a member of the faction that is the owner of the door, then the Player will always be able to open the door and will always see the door as if it was unlocked.
- If the door needs a key and the Player has the key in his inventory, then the door will be unlocked when the player activates the door.
- If the door needs a key and the Player does not have the key in his inventory, then the door will open but remain locked when the player activates the door.
If ownership is changed and the player is no longer direct or indirect owner of the door, the player will see the true status of the door again.
The GetLocked command always returns the true status of the door.
--Thorskin 12:48, 1 February 2009 (EST)