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
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|500px]]


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

Revision as of 23:28, 22 December 2014

Overview

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

First you should copy the Object Reference Interval 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.
Int Property fMinutesInterval Auto ; Desired Minutes Interval /10.0 (minutes) ex.
GlobalVariable Property GameHour Auto ; The Games Hour leave default.
  • fCheckActiveInterval - This property is how often the script is going to check the users interval measured in real-time seconds.
  • 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:
+ fCheckActiveInterval = 3.0 ; Every one minute game time check the interval.
+ 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.