Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

[SKY] Request: Light Script


Tamira
 Share

Recommended Posts

I'm also a scripting noob; however, I found an example script on the wiki which seems to do exactly what you need. It appears that in Skyrim the way to check the current time of day requires getting the total game time passed since Helgen and then subtracting the total game days.



ScriptName 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 = 18.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


Edited by BootySweat
  • Upvote 1
Link to comment
Share on other sites

Thank you very much Booty! :flower:

I never thought it could be that complicated to get the game hour in Skyrim. :huh: Again we see that modding for Oblivion had been so much easier.

I added the script now to a parent light and it works fine.

My intention is to replace the "on" lights as well as the flickering, glowing candles and torches with "off" objects during daytime as it makes more sense. Now I only have to make off-versions of the lantern and glazed candles, which will be easy in NifSkope.

Edit: Done. All works fine!

Thanks again!

Edited by Tamira
Link to comment
Share on other sites

Thank you very much Booty! :flower:

I never thought it could be that complicated to get the game hour in Skyrim. :huh: Again we see that modding for Oblivion had been so much easier.

I added the script now to a parent light and it works fine.

My intention is to replace the "on" lights as well as the flickering, glowing candles and torches with "off" objects during daytime as it makes more sense. Now I only have to make off-versions of the lantern and glazed candles, which will be easy in NifSkope.

Edit: Done. All works fine!

Thanks again!

Yes, it did seem a bit overly complicated. I wonder if there is a more simple way to do this, perhaps with GetSunPositionX?

In any case, glad to hear it's working OK.

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...