JohnnyQuest101 Posted June 15, 2017 Share Posted June 15, 2017 I have used the Timed script for lighting where the lights would auto turn on and off by themselves. I tried using the timed light switch script on serving food at the table automatically. Sometimes it works and sometimes it doesn't . The script: criptName LRM_TimedLightSwitch extends ObjectReference{Controls a set of lights with a master enable parent marker with thisscript attached to turn on and off at the times of the day specifiedby the properties LightsOffTime and LightsOnTime} float Property LightsOffTime = 7.0 auto{The time at which lights should be turned off}float Property LightsOnTime = 19.0 auto{The time at which lights should be turned on} float Function GetCurrentHourOfDay() global{Returns the current time of day in hours since midnight} float Time = Utility.GetCurrentGameTime()Time -= Math.Floor(Time) ; Remove "previous in-game days passed" bitTime *= 24 ; Convert from fraction of a day to number of hoursReturn Time EndFunction Function RegisterForSingleUpdateGameTimeAt(float GameTime){Registers for a single UpdateGameTime event at the next occurrenceof the specified GameTime (in hours since midnight)} float CurrentTime = GetCurrentHourOfDay()If (GameTime < CurrentTime)GameTime += 24EndIf RegisterForSingleUpdateGameTime(GameTime - CurrentTime) EndFunction Event OnInit() If (GetCurrentHourOfDay() > LightsOffTime)GoToState("LightsOff")ElseGoToState("LightsOn")EndIf EndEvent State LightsOff Event OnBeginState()Disable()RegisterForSingleUpdateGameTimeAt(LightsOnTime)EndEvent Event OnUpdateGameTime()GoToState("LightsOn")EndEvent EndState State LightsOn Event OnBeginState()Enable()RegisterForSingleUpdateGameTimeAt(LightsOffTime)EndEvent Event OnUpdateGameTime()GoToState("LightsOff")EndEvent EndState---------------------------- I used the above script on three activator Xmarkers. Changed the time of the first activator from 7 to 11 for meal 1, xmarker two changed for meal 2 from 12 to 4, and the last marker for meal 3 from 6 to 10 pm . Sometimes it works well and I see three different meals set for 4 and two trays changing as they should. However, sometimes it fails. Each xmarker activator controls 4 food plates and two trays each. That is a total of 12 food plates and 6 trays on the table I wanted to cycle through at different times. Does anyone have a solution Link to comment Share on other sites More sharing options...
Recommended Posts