luvadea Posted January 13, 2021 Share Posted January 13, 2021 Hi there, I'm trying to enable a reference (some objects parented to an xmarker) between 11pm and 5 am. When the script runs I want it to check if the time is right for the reference to enable. If not, it stays disabled. Any clues? Link to comment Share on other sites More sharing options...
dylbill Posted January 13, 2021 Share Posted January 13, 2021 You can use the GameHour global variable to detect what time it is. Link to comment Share on other sites More sharing options...
luvadea Posted January 13, 2021 Author Share Posted January 13, 2021 That's what I did but ... Float CurrentTime = GameHour.GetValue() if CurrentTime > 23 && CurrentTime < 6 flyingdutchman.enable() else flyingdutchman.disable() this obviously won't work... Link to comment Share on other sites More sharing options...
dylbill Posted January 13, 2021 Share Posted January 13, 2021 You can put the script directly on the flyingdutchman and try something like this: GlobalVariable Property GameHour Auto Event OnInit() UpdateVisible() EndEvent Event OnUpdateGameTime() UpdateVisible() EndEvent Function UpdateVisible() Utility.Wait(1) Float Hour = GameHour.GetValue() If Hour > 6 && Hour <= 23 Self.Disable() Else Self.Enable() Endif Float nextUpdate If Hour > 6 && Hour <= 23 nextUpdate = (23.0 - Hour) Elseif Hour >= 23 && Hour < 24 nextUpdate = 6.0 + (24.0 - hour) Else nextUpdate = (6.0 - Hour) Endif RegisterForSingleUpdateGameTime(nextUpdate) EndFunction Link to comment Share on other sites More sharing options...
maxarturo Posted January 13, 2021 Share Posted January 13, 2021 There is also a nice script example in CK wiki for you to study, "Enable/Disable an object on a schedule". https://www.creationkit.com/index.php?title=Complete_Example_Scripts#Enable.2FDisable_an_object_on_a_schedule Have a happy modding. Link to comment Share on other sites More sharing options...
luvadea Posted January 13, 2021 Author Share Posted January 13, 2021 Float Hour = GameHour.GetValue() If Hour > 6 && Hour <= 23 Self.Disable() Else Self.Enable() Endif This was enough for what I wanted.Thank you both! Link to comment Share on other sites More sharing options...
dylbill Posted January 14, 2021 Share Posted January 14, 2021 No problem, happy modding :) Link to comment Share on other sites More sharing options...
Recommended Posts