What I'm trying to do is make a book object start glowing based on certain conditions, and stop glowing once its been read.
Scriptname UnreadBooksGlowScript extends ObjectReference{Gives a visible glow to books that have not been read by the Player yet.The list of books that the player has read is stored in theFormList ReadBooksList.When an object reference to a book not in that list is loaded, ashader is picked from ReadBooksEffectShaderList and applied tothe object reference.When an unread book is read, the book is added to theReadBooksList.Each unread book checks whether it has been read every 3 seconds.If so, it turns off its effect shader.This polling approach is unfortunate, however I have not found agood way to broadcast state changes.}; PropertiesFormList Property ReadBooksList AutoFormList Property ReadBooksEffectShaderList Auto; Script variablesEffectShader ourEffectShader = Noneint shaderIdx = -1int updateTime = 3 ; Seconds; FunctionsFunction TraceMe(string msg, ObjectReference ref) Debug.Trace(msg + " " + (self as string) + " " + (self.GetCurrentLocation() as string) + " " + (self.getParentCell() as string) + " " + (self.GetWorldSpace() as string))EndFunctionFunction StartGlow() ;TraceMe("StartGlow", self) if ourEffectShader == None if shaderIdx == -1 ; Pick random shader effect shaderIdx = Utility.RandomInt(0, ReadBooksEffectShaderList.GetSize() - 1) endIf ourEffectShader = (ReadBooksEffectShaderList.GetAt(shaderIdx) as EffectShader) ourEffectShader.Play(self) RegisterForSingleUpdate(updateTime) endIfEndFunctionFunction StopGlow() ;TraceMe("StopGlow", self) if ourEffectShader != None ourEffectShader.Stop(self) ourEffectShader = None UnregisterForUpdate() endIfEndFunctionbool Function IsRead() return ReadBooksList.HasForm(GetBaseObject())endFunctionbool Function IsUnread() return !ReadBooksList.HasForm(GetBaseObject())endFunction; Event handlersEvent OnCellAttach() ;TraceMe("OnCellAttach", self) if IsUnread() StartGlow() endIfEndEventEvent OnCellDetach() ;TraceMe("OnCellDetach", self) StopGlow()EndEventEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) {Change to a different effect shader. For debugging mostly} ;TraceMe("OnHit", self) if IsUnread() StopGlow() shaderIdx = -1 StartGlow() Debug.Trace("EffectShader #" + (shaderIdx as string) + " " + (ourEffectShader as string)) ;Debug.Notification(shaderIdx as string) endIfEndEventEvent OnRead() ;TraceMe("OnRead", self) if IsUnread() ReadBooksList.AddForm(GetBaseObject()) StopGlow() endIfEndEventEvent OnUpdate() ;TraceMe("OnUpdate", self) if IsUnread() RegisterForSingleUpdate(updateTime) else StopGlow() endIfEndEvent