Difference between revisions of "Using Activated Object Reference"
Jump to navigation
Jump to search
imported>Langerz82 |
imported>Langerz82 |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Overview == | == Overview == | ||
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. | [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 Complete_Example_Scripts#Enable.2FDisable_Lock_on_object_based_on_hours_of_day here] because thats where the idea emerged. | 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 == | == Instructions == | ||
Line 43: | Line 43: | ||
* 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. | * 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 and | * The following overrides the Conditionals to take into account day and time for the door Object to lock and unlock. | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Line 83: | Line 83: | ||
</source> | </source> | ||
* The following overides the Active/Inactive function by locking and unlocking the door respectively showing a message to the Users. | * 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. | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Line 102: | Line 102: | ||
* Find the jlTimedLock3 in the Creation Kit, under the Main menus Gameplay >> Papyrus Script Manager, look for jlTimedLock. | * 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]] | * Attach it to a door object you wish to use as an example. [[File:PapyrusScriptManagerTimedLock.jpg|400px]] | ||
* Set the following Properties for the script. | * Set the following Properties for the script. | ||
[[File:TimedLock_Properties.jpg]] | [[File:TimedLock_Properties.jpg|800px]] | ||
* Save the Mod file and run and test in-game. | * Save the Mod file and run and test in-game. |
Latest revision as of 22:58, 7 December 2014
Overview[edit | edit source]
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 here because thats where the idea emerged.
Instructions[edit | edit source]
First you should copy the Activated Object Reference into the Skyrim\Data\Scripts folder.
Take a look at the file and read the comments.
Float Property fCheckActiveInterval Auto ; Desired Update check time/5.0 ex.
- This property is how often the script is going to check the users conditions measured in real-time seconds.
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 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
- 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 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.
; 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
- 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.
; Overrided Function.
Function ObjectActive()
Debug.MessageBox(sDoorOpen)
Self.Lock(TRUE, TRUE)
EndFunction
; Overrided Function.
Function ObjectInactive()
Debug.MessageBox(sDoorClosed)
Self.Lock(FALSE, TRUE)
EndFunction
- 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.
- Set the following Properties for the script.
- Save the Mod file and run and test in-game.