JacobJ 10 Posted April 17, 2011 Hey all I have made a script that creates a lot of lights around in the mission. I want these lights to switch on when the daytime is between 18 and 6. I can get this to work with: if (daytime > 18) or (daytime < 6) then { bla bla}; But the problem is that when it is not between this timeperiode when I run the script it doesnt turn on, when the timeperiode is reached. I suspect that a while would do the job, but I dont want to create the light over and over again after the sleep has run out. How would I do this checking, so that when its past 18 the script is run and when the clock is past 6 in the morning it runs a script that deletes all the lights created? /Jacob Share this post Link to post Share on other sites
igneous01 19 Posted April 17, 2011 your problem is your using OR, it should be AND if (daytime > 18) and (daytime < 6) then { the reason why it didnt run with or is because the script only turned on when it is exactly 1800 OR exactly 0600 Share this post Link to post Share on other sites
demonized 16 Posted April 17, 2011 if (daytime > 18) and (daytime < 6) then { maybe above is a way to run if then checks that i did not know about but i believe you have to do it this way with all conditions inside one (): if (daytime > 18 AND daytime < 6) then { if (daytime > 18 OR daytime < 6) then { Share this post Link to post Share on other sites
JacobJ 10 Posted April 17, 2011 Okay, ive got it working. I have created two triggers: trig1 condition: (daytime > 18.503) or (daytime < 6.001) onAct: nul = [] execVM "lightson.sqf"; trig2 condition: (daytime < 18.499) && (daytime > 6.003) onAct: nul = [] execVM "lightsoff.sqf"; The reason why you need to use OR in the first script is, that the time can't be more than 18:30 and under 6:00 at the same time. In the second trigger you need the AND/&&, because here your daytime is under 18:30, and 6:00 and lower is also under 18:30, thats why you need both to be true for it to work. The timedelays are there to not accidently delete the light before its been created. Share this post Link to post Share on other sites
Bon 12 Posted April 17, 2011 Hi. I think you don't even need the second trigger, as a trigger has not only an Activation field but also a Deactivation field. It is way smaller in the editor interface, so many people aren't actually aware of it. I think all you need is a trigger, condition: daytime > 18 || daytime < 6 activation: _nul = [] execVM "lightson.sqf"; deactivation: _nul = [] execVM "lightsoff.sqf"; Share this post Link to post Share on other sites
JacobJ 10 Posted April 17, 2011 Indeed, that is a good idea. But I had problems with the scripts compromising each other. Exspecially on the creating side. Share this post Link to post Share on other sites
dmarkwick 259 Posted April 17, 2011 Is any trigger even needed? My impression is that any light used is auto controlled by the game engine anyway, lights are not processed during sufficient daylight. Is the issue that you need the lights to come on at a certain time regardless of the daylight? If so then only if the lights come on after it's already dark will be noticeable ingame. Share this post Link to post Share on other sites
JacobJ 10 Posted April 17, 2011 There is no light on a illuminated tower, neither in the hangars, so thats why I need light and I need to time it. But yes, I could just make the light shine all day long. Ill give that a thought.. Share this post Link to post Share on other sites