Difference between revisions of "GetLockLevel - ObjectReference"
Jump to navigation
Jump to search
imported>RJHelms84 m (Added lock level values for convenience.) |
imported>PlausibleSarge m (Missed a line in example, meaning it wouldn't compile) |
||
(One intermediate revision by the same user not shown) | |||
Line 4: | Line 4: | ||
==Description== | ==Description== | ||
Returns the level of the lock attached to this object. If there is no lock, it will return 0 - very easy. | Returns the level of the lock attached to this object. This number can be anything from 0-255, with different values representing lock difficulties (Novice-Expert). If there is no lock, it will return 0 - very easy. | ||
Lock level values are: | Lock level values are: | ||
** 1 = Novice | ** 0-1 = Novice | ||
** 25 = Apprentice | ** 2-25 = Apprentice | ||
** 50 = Adept | ** 26-50 = Adept | ||
** 75 = Expert | ** 51-75 = Expert | ||
** | ** 76-254 = Master | ||
** 255 = Requires Key | ** 255 = Requires Key | ||
Line 30: | Line 30: | ||
Debug.Trace("Lock is very easy") | Debug.Trace("Lock is very easy") | ||
endIf | endIf | ||
</source> | |||
This function fetches the lock level for a given lock in a much more robust way, | |||
making scripting locked objects significantly easier. | |||
<source lang="papyrus"> | |||
;sanitizes lock level | |||
;0 = unlocked, 1 = novice, 2 = apprentice, 3 = adept, 4 = expert, 5 = master, 6 = key | |||
int function SanitizeLockLevel(ObjectReference lock) | |||
int level = lock.GetLockLevel() | |||
if !lock.IsLocked() | |||
return 0 | |||
endif | |||
if level == 0 || level == 1 ;novice | |||
return 1 | |||
elseif level >= 2 && level <= 25 ;Apprentice | |||
return 2 | |||
elseif level >= 26 && level <= 50 ;Adept | |||
return 3 | |||
elseif level >= 51 && level <= 75 ;Expert | |||
return 4 | |||
elseif level >= 76 && level <= 254 ;Master | |||
return 5 | |||
else | |||
return 6 | |||
endif | |||
endfunction | |||
</source> | </source> | ||
Latest revision as of 01:55, 18 August 2013
Member of: ObjectReference Script
Description[edit | edit source]
Returns the level of the lock attached to this object. This number can be anything from 0-255, with different values representing lock difficulties (Novice-Expert). If there is no lock, it will return 0 - very easy. Lock level values are:
- 0-1 = Novice
- 2-25 = Apprentice
- 26-50 = Adept
- 51-75 = Expert
- 76-254 = Master
- 255 = Requires Key
Syntax[edit | edit source]
int Function GetLockLevel() native
Parameters[edit | edit source]
None.
Return Value[edit | edit source]
The level of the lock attached to this object.
Examples[edit | edit source]
; Is the lock very easy?
if (WeakChestProperty.GetLockLevel() == 0)
Debug.Trace("Lock is very easy")
endIf
This function fetches the lock level for a given lock in a much more robust way,
making scripting locked objects significantly easier.
;sanitizes lock level
;0 = unlocked, 1 = novice, 2 = apprentice, 3 = adept, 4 = expert, 5 = master, 6 = key
int function SanitizeLockLevel(ObjectReference lock)
int level = lock.GetLockLevel()
if !lock.IsLocked()
return 0
endif
if level == 0 || level == 1 ;novice
return 1
elseif level >= 2 && level <= 25 ;Apprentice
return 2
elseif level >= 26 && level <= 50 ;Adept
return 3
elseif level >= 51 && level <= 75 ;Expert
return 4
elseif level >= 76 && level <= 254 ;Master
return 5
else
return 6
endif
endfunction
See Also[edit | edit source]
- Locking and Unlocking Doors tutorial.
- IsLocked - ObjectReference
- Lock - ObjectReference
- LockDoors (Procedure)
- SetLockLevel - ObjectReference
- UnlockDoors (Procedure)
- UnlockOwnedDoorsInCell - Actor
- GetLocked console command.
- GetLockLevel console command.
- Lock console command.
- Unlock console command.