Jump to content

[LE] script for changing food on table


Recommended Posts

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 this
script attached to turn on and off at the times of the day specified
by 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" bit
Time *= 24 ; Convert from fraction of a day to number of hours
Return Time
EndFunction
Function RegisterForSingleUpdateGameTimeAt(float GameTime)
{Registers for a single UpdateGameTime event at the next occurrence
of the specified GameTime (in hours since midnight)}
float CurrentTime = GetCurrentHourOfDay()
If (GameTime < CurrentTime)
GameTime += 24
EndIf
RegisterForSingleUpdateGameTime(GameTime - CurrentTime)
EndFunction
Event OnInit()
If (GetCurrentHourOfDay() > LightsOffTime)
GoToState("LightsOff")
Else
GoToState("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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...