I have this script:
Scriptname RenCrimeGuardRingScript extends ObjectReferenceimport ActorActor myActorContainerEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) myActorContainer = akNewContainer as Actor if (myActorContainer.IsGuard() == 1) RegisterForUpdate(1.0) Debug.Notification("Guard registered for update.") else akNewContainer.RemoveItem(self, 1) endifEndEventEvent OnUpdate() Debug.Notification("Test 1") Debug.Notification("Guard is updating: " + myActorContainer.HasLOS(Game.GetPlayer()) ) if myActorContainer.HasLOS(Game.GetPlayer()) == 1 Debug.Notification("Guard can see the player") endifendEventIt compiles just fine and runs up until the point where the Event OnUpdate is (supposed) to fire. I don't see any of the Debug.Notifications pop up, and I'm stumped as to why. I see the notification "Guard registered for update" pop up.
This script is running on a nonplayable piece of armor that is added to Guards through a neat little trick of using FindRandomActorFromRef. In theory it all should work fine, but my hunch is that RegisterForUpdate isn't working on objects that are inside an actor's inventory.
Any help would be greatly appreciated!
Edit: Also, is there any way to add a script directly to an actor through scripting? For some reason the idea is stuck in my head that it is possible, and that I saw it somewhere, but I can't remember how.
