Difference between revisions of "Using Object Reference Interval"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Langerz82
(Created page with "== Overview == [https://gist.github.com/Langerz82/2f6be9eb062356031b00 Object Reference Interval] is a very generic script, that enables users to implement code functionality...")
 
imported>Langerz82
 
(4 intermediate revisions by the same user not shown)
Line 9: Line 9:


<source lang="papyrus">
<source lang="papyrus">
Float Property fCheckActiveInterval Auto ; Desired Update check time/5.0 ex.
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.
</source>
</source>


* fCheckActiveInterval - This property is how often the script is going to check the users interval measured in real-time seconds.
* 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.


Line 37: Line 37:
+ at specified intervals.
+ at specified intervals.
+ The Properties for this examples should be set too:
+ The Properties for this examples should be set too:
+ fCheckActiveInterval = 3.0 ; Every one minute game time check the interval.
+ useLooking = TRUE ; We only want the interval to occur when in view.
+ fMinutesInterval = 5.0 ; Every five minutes in game time call OnTimeElapsed.
+ fMinutesInterval = 5.0 ; Every five minutes in game time call OnTimeElapsed.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/;
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/;
Line 63: Line 63:
* Attach it to an object for example a box or door you wish to use as an example.
* 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.
* Set the following Properties for the script.
[[File:jlLockInterval.jpg|800px]]
[[File:jlLockInterval.jpg|700px]]


* Save the Mod file and run and test in-game.
* Save the Mod file and run and test in-game.

Latest revision as of 21:18, 23 December 2014

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.

JlLockInterval.jpg

  • Save the Mod file and run and test in-game.