Block Activation on a bed.

Post » Mon Nov 19, 2012 6:26 am

I have a Bed in which I placed a Script

On the OnLoad statement I have the Block Activation.


In my script OnActivate I have stuff to do...


When I firs load up the cell and the player clicks on the bed all works as planned... But the second time the player clicks on the bed I get the normal sleep menu and if I cancel it
The script on the bed runs... and thus the third repeats the second and so on... But only the first time seems to work ???


Any thoughts one this?
User avatar
Jack Moves
 
Posts: 3367
Joined: Wed Jun 27, 2007 7:51 am

Post » Sun Nov 18, 2012 10:41 pm

Could you post the source of the script you're using? There may be a problem with it that's causing this behaviour.

Cipscis
User avatar
Miragel Ginza
 
Posts: 3502
Joined: Thu Dec 21, 2006 6:19 am

Post » Sun Nov 18, 2012 2:58 pm

Ok here is the code but it actually triggers a quest. as I said this all works except the Block activate only works on the first shot and then fails on the next activate.
I am considering adding a loop to this which exits when the player wakes... for timing purposes.

Scriptname TheSleepingBed extends ObjectReference  ObjectReference Property SpecialSleepingBed AutoQuest Property SleepingBedQuest AutoInt SleepStatebool SleptReferenceAlias Property SleepingPlayer Auto ;Player in QuestReferenceAlias Property SleepingPartner Auto ; CompanionEvent OnInit()SpecialSleepingBed.BlockActivation() : added because on load did not seem to work 100% ???EndeventEvent OnLoad()SpecialSleepingBed.BlockActivation()endEventEvent OnActivate(ObjectReference akActionRef)Actor Sleeper = akActionRef as Actor		  if Sleeper == Game.Getplayer()SleepingBedQuest.Start() ;Start quest that causes player to sleep, Quest has code in script to send player to be AI DrivenSleepingBedQuest.SetStage(10);Debug.notification("Player Sleep Starts")utility.wait(5.0)Else;Debug.notification("Actor Sleep Starts")utility.wait(15.0)endif; Debug.Trace("Activated by " + akActionRef);The following values are returned:;0 - Not sleeping;2 - Not sleeping, wants to sleep;3 - Sleeping;4 - Sleeping, wants to wake; Is the actor sleeping?SleepState = Sleeper.GetSleepState();Debug.notification("Sleeper State = " + SleepState)if SleepState == 3 && Sleeper == Game.Getplayer()Slept = True;Debug.Trace("Yes sleeping!")registerForSleep()Endifif SleepState == 3 && Sleeper != Game.Getplayer()Slept = True;Debug.Trace("Yes sleeping!")Endifif (Sleeper == Game.Getplayer() && SleepState == 3) ||  (Sleeper == Game.Getplayer() && SleepState == 4)Game.EnablePlayerControls()Game.SetPlayerAIDriven(False)SleepingPlayer.clear()SleepingPartner.clear()SleepingBedQuest.Stop()Utility.wait(5.0)endifif (SleepState == 4 || SleepState == 0) && (Sleeper != Game.Getplayer() && Slept == True)Slept = FalseEndifif (SleepState == 4 || SleepState == 0) && (Sleeper == Game.Getplayer() && Slept == True)Slept = FalseUnregisterForSleep()Game.ForceFirstPerson()EndifEndEvent
User avatar
Vicky Keeler
 
Posts: 3427
Joined: Wed Aug 23, 2006 3:03 am


Return to V - Skyrim