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...

light source script on/off at certain times...


DsoS
 Share

Recommended Posts

Any reason why the script below wouldn't work like it should?

I want the light to turn one at 7am and off at 6pm (around sunrise and sunset). The lights are light-bulb's set near the windows in houses.


begin gamemode

	if gamehour >= 7 || gamehour < 18

		enable

	else

		disable

endif


end

Link to comment
Share on other sites

sweet it works now. Thank you Lanceor :pints:

another question arose while testing the script. When I stepped outside it was raining due to a thunderstorm, so my question is...

Is there anyway for a script to look and see if there is a thunderstorm outside and work with WillieSea's haunted house lighting/thunder script? (I use a modified version of that for strobe light effect)

Link to comment
Share on other sites

You may want to check to see if this script is impacting performance by continually enabling the light or disabling the light on every pass. It's lightweight enough it *probably* isn't an issue, but if you find that it is, here's another technique:

float prevhour


begin gamemode

    if (gamehour != prevhour)

        if (gamehour <= 7 && gamehour >= 18)

            enable

        else

            disable

        endif

        set prevhour to gamehour

    endif

end

In *theory* this may be faster, but it also may turn out that the floating point compares are actually slower than just blindly doing the enable or disable. I offer this only as an alternative, not a recommendation. :)

Syscrusher

Edited by syscrusher
Link to comment
Share on other sites

I actually had that thought last night. I thought about added a Player.GetinCell command. but these lights are inside about 6 different interior cells. :unsure:

is there a easy way to set up the script to know when the player is in those cells without having to type each cell into the script?

Link to comment
Share on other sites

I actually had that thought last night. I thought about added a Player.GetinCell command. but these lights are inside about 6 different interior cells. :unsure:

is there a easy way to set up the script to know when the player is in those cells without having to type each cell into the script?

Assuming your script is attached to the base object of the lights (that is, the script is on the lights themselves) try this:

if (GetInSameCell player)

   ; Do your other logic

endif

GetInSameCell operates on its calling reference, so it should test "is the player in the same cell as the light?"

Hope this helps, and please post back if it works, as I'm about to invent a very similar wheel for my own mod. :)

Syscrusher

Link to comment
Share on other sites

You may want to check to see if this script is impacting performance by continually enabling the light or disabling the light on every pass. It's lightweight enough it *probably* isn't an issue, but if you find that it is, here's another technique:

float prevhour


begin gamemode

    if (gamehour != prevhour)

        if (gamehour <= 7 && gamehour >= 18)

            enable

        else

            disable

        endif

        set prevhour to gamehour

    endif

end

In *theory* this may be faster, but it also may turn out that the floating point compares are actually slower than just blindly doing the enable or disable. I offer this only as an alternative, not a recommendation. :)

Syscrusher

Oh, DUHHHHHH! I should have used a "short" rather than a "float" above. Sorry, I'm an IT pro and was programming in another language, and forgot Oblivion scripts have a short integer type available.

Link to comment
Share on other sites

with this script I would need at least 6 of them, one for each house/building. Is there no other way to do it using my custom exterior worldspace?

The script doesn't run on the base object, but on each reference independently. That is, if you define MyLightBaseObject and attach this script to it, then create six references of that object in your interior cells, each of those will run the script against its own refid.

I use this technique with a light control activator I built, which has only one base object defined but is used in maybe 10 different cells in my mod, and even multiply within particular cells. Each instance of the activator behaves independently of all the others.

Link to comment
Share on other sites

okay its seems to work correctly.

While We're on the subject of lights and what not I have another question....

on several meshes (anything with a fire actually, ie. MineLamp500) there is the option for "Turn Off Fire." Is there anyway using a script to turn ON at the correct times and off at the correct times (using the script above)?

Link to comment
Share on other sites

okay its seems to work correctly.

While We're on the subject of lights and what not I have another question....

on several meshes (anything with a fire actually, ie. MineLamp500) there is the option for "Turn Off Fire." Is there anyway using a script to turn ON at the correct times and off at the correct times (using the script above)?

I'll invite others to step in here, but here's my thoughts:

I haven't found that the "turn off fire" setting is at all useful, as it doesn't seem to really change the appearance of the lamp much. Here's what I do for controllable lights, instead. There are two approaches:



  1. Place a "practical" (see below) light source in the exact location of the "Off" static version of the same light source (use the grid snap in the CS). Make the practical source a persistent object, and make the "off" static version a child of the light source, but set it to "initially disabled" and to "opposite state of parent" in its Enable Parent tab. Now enable or disable your light source from your script. The "off" version will replace the lighted version whenever the lighted version is disabled.
  2. Place a "Fake" static version and an "Off" static version in the exact location. Nearby, place a "phantom" light source (the ghostly light bulb objects that are invisible in-game). Make the phantom light persistent, and make it the parent of *both* the "Off" and "Fake" static objects. The "off" object is set to initially disabled and opposite state of parent, whereas the "fake" object is initially enabled and follows the parent's enable state. Thus, only one or the other will be active at a time. Your external script controls the enable/disable on the phantom light, and the two static fixture objects follow appropriately.

In the first item, I use the word "practical" in the theatre set design sense, meaning a light source that actually emits light rather than a static object that appears to emit light but doesn't.

Important safety tip: In either case, your script is attached to an external Activator and NOT to the parent light source! If you attach it to the light source, the first time it switches off, it will disable itself!

I've done both of these successfully, and I really prefer #2. #1 is slightly quicker to set up, but #2 has the advantage that you can "cheat" the phantom light source to a more convenient location. You need to keep it near the apparent light source (the fixture) for realism, but you can offset it a bit for more pleasing visuals or to soften "nuclear" light pools on flat surfaces.

With fires, such as fireplaces, I just use the fire object from the Lights section and entirely enable/disable it. You don't need a substitute "off" object.

If you decide to try this, and you get stuck, let me know and I'll share by private message my light controller script. It sounds as if you're doing pretty well on your own, though.

Hope this helps!

Syscrusher

Link to comment
Share on other sites

i forgot that I posted that. While I was working on them, I thought about the 30 light posts and the persistent refs and what not so I decided not to do that after all. sorry that you wrote all that, but it will be helpful in the future.

Thank you for all the help :):pints:

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...