Jump to content

Making a custom light lit/unlit based on daytim


mannygt

Recommended Posts

Hello,

I'm a n00b about CK, but I know what I want.

 

I've made a mod that add lanterns near bridges. These lanterns use a custom new light with ID: "lightLanternSkyrim"

 

Now I'm trying to make lit lanterns only from 6:00 to 18:00.

I don't know how to retrieve current clock time and I don't know how to modify light on/off.

 

There is my "ideal" script here

 

Function mainLanterns()                       
 RegisterForUpdateGameTime(1)
endFunction

Event OnUpdateGameTime()
 if currentTime>=6 && currentTime<=18
TurnOFFLightByID
 else
   TurnONLightByID
 endIf
endEvent

 

Of course, currentTime, TurnOFFLightByID and TurnONLightByID are not the real script stuff.

What I've to do to get clock time and toggle lighting?

 

Thank you!

Link to comment
Share on other sites

Best way (asuming multiple lights) would be to

a) put the light objects into the cell

b) add an xmarker to the cell

c) add an activator to the cell

d) set the xmarker to be the enable parent of the light objects

e) set the xmarker to be the linked ref of the activator

f) attach a script to the activator that runs getLinkedRef().disable(true) to turn the lights off or getLinkedRef().enable(true) to turn them on.

 

This may seem more complicated at first but the script can be re-used if need be without re-coding.

Link to comment
Share on other sites

Thanks all for reply :)

 

Now I'm at office but I'm thinking about scripting my 'LightLanternOfSkyrim' custom light object and it will be:

 

Function mainLanterns()                       
RegisterForUpdateGameTime(1)
endFunction

float Function GetCurrentHourOfDay() 

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

Event OnUpdateGameTime()
float currentTime = GetCurrentHourOfDay()
if currentTime>=6 && currentTime<=18
	getLinkedRef().Disable(true)
else
	getLinkedRef().Enable(true)
endIf
endEvent

mainLanterns()

 

I want to try to place this script directly to my custom base light object, so all lanterns in the bridges I made will works...

 

What do you think about this?

Edited by mannygt
Link to comment
Share on other sites

Just as a possible alternative, have you tryed setting the external emittence on the light(s) to something like FXLightRegionInvertDayNight. See how that works for you and no scripting required.

 

Hello. No, I've no tried yet but I'll try it. BTW I want to make my first tiny script about papyrus :) Thank you.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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