Using Object Reference Interval: Difference between revisions
Jump to navigation
Jump to search
imported>Langerz82 |
m (Convert source tags to syntaxhighlight) |
||
| Line 8: | Line 8: | ||
Take a look at the file and read the comments. | Take a look at the file and read the comments. | ||
< | <syntaxhighlight lang="papyrus"> | ||
Bool Property useLooking Auto ; Should we take into account Line of Sight or not. | Bool Property useLooking Auto ; Should we take into account Line of Sight or not. | ||
Int Property fMinutesInterval Auto ; Desired Minutes Interval /10.0 (minutes) ex. | Int Property fMinutesInterval Auto ; Desired Minutes Interval /10.0 (minutes) ex. | ||
GlobalVariable Property GameHour Auto ; The Games Hour leave default. | GlobalVariable Property GameHour Auto ; The Games Hour leave default. | ||
</ | </syntaxhighlight> | ||
* useLooking - Set to TRUE if you want the interval to occur only when its in the players view. | * useLooking - Set to TRUE if you want the interval to occur only when its in the players view. | ||
* fMinutesInterval - How many minutes can pass before the OnTimeElapsed Overridden function will get called. | * fMinutesInterval - How many minutes can pass before the OnTimeElapsed Overridden function will get called. | ||
< | <syntaxhighlight lang="papyrus"> | ||
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
+ OVERRIDE FUNCTIONS | + OVERRIDE FUNCTIONS | ||
| Line 26: | Line 26: | ||
;Debug.Notification("ObjectReferenceInterval(Event:OnTimeElapsed)") | ;Debug.Notification("ObjectReferenceInterval(Event:OnTimeElapsed)") | ||
EndEvent | EndEvent | ||
</ | </syntaxhighlight> | ||
* OnTimeElapsed is called when the minutes interval is reached and should be overridden and include what you want to do with the Object Reference. | * OnTimeElapsed is called when the minutes interval is reached and should be overridden and include what you want to do with the Object Reference. | ||
| Line 32: | Line 32: | ||
* Ok next you need to provide your script that extends from the ObjectReferenceInterval file. For this example we have a script that locks/unlocks an object at a specified interval. Copy the [https://gist.github.com/Langerz82/79acce714b77f3b8d481 Lock/Unlock Interval Example] to your Skyrim/Data/Scripts/Source folder. | * Ok next you need to provide your script that extends from the ObjectReferenceInterval file. For this example we have a script that locks/unlocks an object at a specified interval. Copy the [https://gist.github.com/Langerz82/79acce714b77f3b8d481 Lock/Unlock Interval Example] to your Skyrim/Data/Scripts/Source folder. | ||
< | <syntaxhighlight lang="papyrus"> | ||
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
+ This script enables an ObjectReference like a door locked and unlocked | + This script enables an ObjectReference like a door locked and unlocked | ||
| Line 55: | Line 55: | ||
isLocked = !isLocked | isLocked = !isLocked | ||
EndEvent | EndEvent | ||
</ | </syntaxhighlight> | ||
* The following overides the OnTimeElapsed Event by locking and unlocking the door at the specified interval which in this case should be every 5 minutes. | * The following overides the OnTimeElapsed Event by locking and unlocking the door at the specified interval which in this case should be every 5 minutes. | ||
Latest revision as of 21:25, 5 September 2026
Overview[edit | edit source]
Object Reference Interval is a very generic script, that enables users to implement code functionality in a set time interval. This is a child project of the Activated Object Reference but is allot simpler in its code and should be used as a starting point before trying to understand the Activated Object Reference.
Instructions[edit | edit source]
First you should copy the Object Reference Interval into the Skyrim\Data\Scripts folder.
Take a look at the file and read the comments.
Bool Property useLooking Auto ; Should we take into account Line of Sight or not.
Int Property fMinutesInterval Auto ; Desired Minutes Interval /10.0 (minutes) ex.
GlobalVariable Property GameHour Auto ; The Games Hour leave default.- useLooking - Set to TRUE if you want the interval to occur only when its in the players view.
- fMinutesInterval - How many minutes can pass before the OnTimeElapsed Overridden function will get called.
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ OVERRIDE FUNCTIONS
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/;
; Override Event - When Object exceeds elapsed time.
Event OnTimeElapsed()
;Debug.Notification("ObjectReferenceInterval(Event:OnTimeElapsed)")
EndEvent- OnTimeElapsed is called when the minutes interval is reached and should be overridden and include what you want to do with the Object Reference.
- Ok next you need to provide your script that extends from the ObjectReferenceInterval file. For this example we have a script that locks/unlocks an object at a specified interval. Copy the Lock/Unlock Interval Example to your Skyrim/Data/Scripts/Source folder.
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ This script enables an ObjectReference like a door locked and unlocked
+ at specified intervals.
+ The Properties for this examples should be set too:
+ useLooking = TRUE ; We only want the interval to occur when in view.
+ fMinutesInterval = 5.0 ; Every five minutes in game time call OnTimeElapsed.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/;
ScriptName jlLockInterval extends ObjectReferenceInterval
bool isLocked = false;
; Overrided Function.
Event OnTimeElapsed()
Debug.Notification("jlLockInterval(Event:OnObjectElapsed)")
if (isLocked)
Self.Lock(FALSE, TRUE)
else
Self.Lock(TRUE, TRUE)
endif
isLocked = !isLocked
EndEvent- The following overides the OnTimeElapsed Event by locking and unlocking the door at the specified interval which in this case should be every 5 minutes.
- Find the jlLockInterval in the Creation Kit, under the Main menus Gameplay >> Papyrus Script Manager, look for jlLockInterval.
- Attach it to an object for example a box or door you wish to use as an example.
- Set the following Properties for the script.
- Save the Mod file and run and test in-game.