Advertisement
Guest User

Untitled

a guest
Apr 24th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. scriptName AutomaticLightSwitchScript extends ObjectReference
  2. {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}
  3.  
  4. ;-- Properties --------------------------------------
  5. float property LightsOffTime = 7.00000 auto
  6. {The time at which lights should be turned off}
  7. float property LightsOnTime = 18.0000 auto
  8. {The time at which lights should be turned on}
  9.  
  10. ;-- Variables ---------------------------------------
  11. ObjectReference MyMaster = None
  12. ;-- Functions ---------------------------------------
  13.  
  14. float function GetCurrentHourOfDay() global
  15. {Returns the current time of day in hours since midnight}
  16.  
  17. float Time = utility.GetCurrentGameTime()
  18. Time -= math.Floor(Time) as float
  19. Time *= 24 as float
  20. return Time
  21. endFunction
  22.  
  23. ; Skipped compiler generated GotoState
  24.  
  25. ; Skipped compiler generated GetState
  26.  
  27. function OnInit()
  28.  
  29. if AutomaticLightSwitchScript.GetCurrentHourOfDay() > LightsOffTime
  30. self.GotoState("LightsOff")
  31. else
  32. self.GotoState("LightsOn")
  33. endIf
  34. endFunction
  35.  
  36. function RegisterForSingleUpdateGameTimeAt(float GameTime)
  37. {Registers for a single UpdateGameTime event at the next occurrence of the specified GameTime (in hours since midnight)}
  38.  
  39. float CurrentTime = AutomaticLightSwitchScript.GetCurrentHourOfDay()
  40. if GameTime < CurrentTime
  41. GameTime += 24 as float
  42. endIf
  43. self.RegisterForSingleUpdateGameTime(GameTime - CurrentTime)
  44. endFunction
  45.  
  46. ;-- State -------------------------------------------
  47. state lightson
  48.  
  49. function OnBeginState()
  50.  
  51. self.Enable(false)
  52. if (MyMaster == None) && (SKSE.GetScriptVersionRelease() >= 48) && (PapyrusUtil.GetVersion() >= 30)
  53. MyMaster = Game.GetFormFromFile(JsonUtil.IntListGet("DynDOLOD_" + JsonUtil.GetStringValue("DynDOLOD_Worlds", StringUtil.Substring(Game.GetPlayer().GetWorldspace() as string, 13, StringUtil.Find(Game.GetPlayer().GetWorldspace() as string, "(") - 14), "None") as string, "master", 0), "DynDOLOD.esp") As ObjectReference
  54. endIf
  55. if (MyMaster != None) && (StorageUtil.GetIntValue(None, "DynDOLOD_Active", 0) == 1)
  56. Utility.Wait(1)
  57. (MyMaster as SHESON_DynDOLOD_Master).IBowToTheev2(StorageUtil.GetFormValue(MyMaster, "DynDOLOD_MyActiveFirstborn", None) As ObjectReference, (MyMaster as SHESON_DynDOLOD_Master).MyCurrentFirstbornList, (MyMaster as SHESON_DynDOLOD_Master).MyCurrentMinionList, TRUE, TRUE)
  58. endIf
  59. self.RegisterForSingleUpdateGameTimeAt(LightsOffTime)
  60. endFunction
  61.  
  62. function OnUpdateGameTime()
  63.  
  64. self.GotoState("LightsOff")
  65. endFunction
  66. endState
  67.  
  68. ;-- State -------------------------------------------
  69. state lightsoff
  70.  
  71. function OnBeginState()
  72.  
  73. self.Disable(false)
  74. if (MyMaster == None) && (SKSE.GetScriptVersionRelease() >= 48) && (PapyrusUtil.GetVersion() >= 30)
  75. MyMaster = Game.GetFormFromFile(JsonUtil.IntListGet("DynDOLOD_" + JsonUtil.GetStringValue("DynDOLOD_Worlds", StringUtil.Substring(Game.GetPlayer().GetWorldspace() as string, 13, StringUtil.Find(Game.GetPlayer().GetWorldspace() as string, "(") - 14), "None") as string, "master", 0), "DynDOLOD.esp") As ObjectReference
  76. endIf
  77. if (MyMaster != None) && (StorageUtil.GetIntValue(None, "DynDOLOD_Active", 0) == 1)
  78. Utility.Wait(1)
  79. (MyMaster as SHESON_DynDOLOD_Master).IBowToTheev2(StorageUtil.GetFormValue(MyMaster, "DynDOLOD_MyActiveFirstborn", None) As ObjectReference, (MyMaster as SHESON_DynDOLOD_Master).MyCurrentFirstbornList, (MyMaster as SHESON_DynDOLOD_Master).MyCurrentMinionList, TRUE, TRUE)
  80. endIf
  81. self.RegisterForSingleUpdateGameTimeAt(LightsOnTime)
  82. endFunction
  83.  
  84. function OnUpdateGameTime()
  85.  
  86. self.GotoState("LightsOn")
  87. endFunction
  88. endState
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement