mannygt Posted February 28, 2012 Author Share Posted February 28, 2012 Hello again.The "FXLightRegionInvertDayNight" is the solution about this. Apply getLinkedRef() to a *base* light will affect only to the first light loaded. Link to comment Share on other sites More sharing options...
mannygt Posted February 29, 2012 Author Share Posted February 29, 2012 Hello!At last I did it. Now works perfectly. My mistake was to use getLinkedRef() of my base light. The correct way to lit/unlit all referenced light (of my custom light) is to use directly Disable() and Enable(). So here is my final code, maybe helpful for someone: Scriptname lightOnOff extends ObjectReference {Turn light On or Off depending on daytime} Event OnCellAttach() RegisterForUpdateGameTime(0.25) VerifyLight() endEvent float Function GetCurrentHourOfDay() float Time = Utility.GetCurrentGameTime() Time -= Math.Floor(Time) Time *= 24 Return Time EndFunction Event OnUpdateGameTime() VerifyLight() endEvent function VerifyLight() float currentTime = GetCurrentHourOfDay() if currentTime>=6 && currentTime<=18 Disable(true) else Enable(true) endIf EndFunction What you need: - Create your custom light- Create new script- Paste the code above To change timing as you desire, just modify the conditional line. PS: I've use the event OnCellAttach() to inizialize because OnLoad() does not works... Regards! Link to comment Share on other sites More sharing options...
gsmanners Posted February 29, 2012 Share Posted February 29, 2012 PS: I've use the event OnCellAttach() to inizialize because OnLoad() does not works... Interesting. OnLoad has this cryptic note: To be clear: For interiors, it often looks like this event fires whenever the player enters the cell. It doesn't. If you leave a cell, the cell may or may not have unloaded by the time you return, which means this event may or may not fire again. If you need a reliable event every time the player enters a cell, try the OnCellAttach Event instead. Looks to me like the devs wrote the wiki in their usual gibberish. Anyone have a gibberish-to-English dictionary handy? Link to comment Share on other sites More sharing options...
mannygt Posted February 29, 2012 Author Share Posted February 29, 2012 I don't know about handy dictionary that you are finding :) I'm Italian... Link to comment Share on other sites More sharing options...
Cipscis Posted March 1, 2012 Share Posted March 1, 2012 It means an interior cell won't necessarily be unloaded when the player leaves it, so you shouldn't rely on OnLoad firing every time the player enters the cell. If you guys are interested, I put up a light switch script (both automatic and manual versions) on the wiki the other day. The main difference between it and your script is that your script is continually polling game time, whereas my version only polls game time twice per in-game day. Cipscis Link to comment Share on other sites More sharing options...
mannygt Posted March 1, 2012 Author Share Posted March 1, 2012 (edited) Hello,tried your script: does not works... Lights are lit everytime *update* To make your script working I had change the event OnInit() to OnCellAttach() Edited March 1, 2012 by mannygt Link to comment Share on other sites More sharing options...
gsmanners Posted March 1, 2012 Share Posted March 1, 2012 (edited) Yes. OnInit is not invoked often enough to make Light Switch work. You really need to use OnCellAttach. EDIT: Additionally, OnInit "must be defined in an empty state" (which would also prevent Light Switch from working). Edited March 1, 2012 by gsmanners Link to comment Share on other sites More sharing options...
Cipscis Posted March 1, 2012 Share Posted March 1, 2012 I'm a bit confused, OnInit is defined in the empty state in that script, and because the scripted object will always be registered for updates or have code running it will remain persistent and shouldn't need to be re-initialised at any point in time, so a single run of OnInit should be enough. More importantly, I've had confirmation that it works already, so I'm not sure what the difference might be that's preventing it from working for you. Cipscis Link to comment Share on other sites More sharing options...
mannygt Posted March 1, 2012 Author Share Posted March 1, 2012 (edited) LOL Cipscis... You have linked my thread on bethesda forums :D. I've forgotten about that thread!Anyway I guarantee that I'm not trolling you. I've just copy/paste your code and not worked. Changeg to OnCellAttach() and worked. I'm a novice with papyrus scripting but I'm still learning. About OnInit() ... May not work with base object? I've place the script directly to a new light that I've created (light ID: 'LightLanternOfSkyrim') Anyway I like your idea to update status only two times a day instead of every 15 minutes. Thank you. Edited March 1, 2012 by mannygt Link to comment Share on other sites More sharing options...
Cipscis Posted March 1, 2012 Share Posted March 1, 2012 Don't worry, I don't think you're trolling me. I'm just wondering what could be different between what you've done and what TheMagician did that would stop this from working. More importantly, why OnInit isn't firing. Did you replace the content of a script that was already attached to the object in the saved game you used to test? If you weren't using a clean save and the script was already attached, then the OnInit event wouldn't be called. If you use a "clean save", then I'd expect it to work. Cipscis Link to comment Share on other sites More sharing options...
Recommended Posts