Open main menu
Home
Random
Log in
Settings
About the CreationKit Wiki
Disclaimers
the CreationKit Wiki
Search
Editing
Using Activated Object Reference
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Overview == [https://gist.github.com/Langerz82/6ff01e9c99e36270835e Activated Object Reference] is a very generic script, that enables users to implement two-state Objects in a fairly straight-forward manner without having to know much about how states work. The use of states can be pretty powerful but for the vast majority of scripts the User will only have to add basic functionality to an Object and this takes care of that generic pattern. Two-State Objects could be something thats turned ON/OFF, OPEN/CLOSED etc. The example below locks a door between specified times, this example has been derived from [http://www.creationkit.com/Complete_Example_Scripts#Enable.2FDisable_Lock_on_object_based_on_hours_of_day here] because thats where the idea emerged. == Instructions == First you should copy the [https://gist.github.com/Langerz82/6ff01e9c99e36270835e Activated Object Reference] into the Skyrim\Data\Scripts folder. Take a look at the file and read the comments. <syntaxhighlight lang="papyrus"> Float Property fCheckActiveInterval Auto ; Desired Update check time/5.0 ex. </syntaxhighlight> * This property is how often the script is going to check the users conditions measured in real-time seconds. <syntaxhighlight lang="papyrus"> ;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + OVERRIDE FUNCTIONS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; ; Override Function - Is the Object Active? Bool Function isObjectActive() return true EndFunction ; Override Function - Is the Object InActive? Bool Function isObjectInactive() return true EndFunction ; Override Function - When Object becomes Active. Function ObjectActive() EndFunction ; Override Function - When Object becomes Inactive. Function ObjectInactive() EndFunction </syntaxhighlight> * The isObjectActive and isObjectInactive are the conditional functions you should override if you want to check something before the ObjectActive and ObjectInactive functions are called respectively. Return true when you want it to trigger the Object Active/Inactive functions, and false if you dont. * Ok next you need to provide your script that extends from the ActivatedObjectReference file. For this example we have a script that locks an object at a specified time. Copy the [https://gist.github.com/Langerz82/e3f271911472bc9aeb1b Timed Lock Example] to your Skyrim/Data/Scripts/Source folder. * The following overrides the Conditionals to take into account day and time for the door Object to lock and unlock. <syntaxhighlight lang="papyrus"> ; Overrided Function. Bool Function IsObjectActive() If (fDayOfWeek && fDayOfWeek != GetDayOfWeek()) return false EndIf Float fTime = GameHour.GetValue() If (fHourClosed < fHourOpen) ; Fix to take into account times over the 24-hour period. If (fTime <= fHourClosed || fTime >= fHourOpen) return true EndIf Else If (fTime >= fHourOpen && fTime <= fHourClosed) return true EndIf EndIf return false EndFunction ; Overrided Function. Bool Function IsObjectInActive() Float fTime = GameHour.GetValue() If (fHourClosed < fHourOpen) ; Fix to take into account times over the 24-hour period. If (fTime > fHourClosed && fTime < fHourOpen) return true EndIf Else If (fTime < fHourOpen || fTime > fHourClosed) return true EndIf EndIf return false EndFunction </syntaxhighlight> * The following overides the Active/Inactive function by locking and unlocking the door respectively and showing a message to the Users when a Line-Of-Sight and the Conditions hold true. <syntaxhighlight lang="papyrus"> ; Overrided Function. Function ObjectActive() Debug.MessageBox(sDoorOpen) Self.Lock(TRUE, TRUE) EndFunction ; Overrided Function. Function ObjectInactive() Debug.MessageBox(sDoorClosed) Self.Lock(FALSE, TRUE) EndFunction </syntaxhighlight> * Find the jlTimedLock3 in the Creation Kit, under the Main menus Gameplay >> Papyrus Script Manager, look for jlTimedLock. * Attach it to a door object you wish to use as an example. [[File:PapyrusScriptManagerTimedLock.jpg|400px]] * Set the following Properties for the script. [[File:TimedLock_Properties.jpg|800px]] * Save the Mod file and run and test in-game.
Summary:
Please note that all contributions to the CreationKit Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
CreationKit:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)