Snicke 0 Posted March 8, 2007 Im trying to turn of the lights to a town. But I cant get it to work. Have only found out how to turn of one light with a trigger. : nearestObject [player, "streetlamp"] switchlight "off" But I cant find out how to turn it off to the whole town. And when I tried this on a car, the car starts taking damage instead of turning on the lights.? Share this post Link to post Share on other sites
moricky 211 Posted March 8, 2007 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x switchlight "off"} foreach (position unit nearObjects ["streetlamp",300]); All streetlamps at distance less than 300m from unit will be switched off. And for vehicles - what about action? Share this post Link to post Share on other sites
Snicke 0 Posted March 8, 2007 Thanx for the heads up in the action command. But on the other side, I cant get your example to work. Share this post Link to post Share on other sites
Balschoiw 0 Posted March 8, 2007 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x switchlight "off"} foreach (position unitname nearObjects ["streetlamp",300]); Works like a charm. You just have to replace "unitname" with the name of the unit that is supposed to be the centre of the 300m radius. You can also use a GameLogic if you don´t want to use a live unit. Place a gamelogic, name it lighto1 and use this code in a trigger or in the init of the GameLogic isf you want to have the lights off right from the start: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x switchlight "off"} foreach (position lighto1 nearObjects ["streetlamp",300]); Btw. Thx for the snippet Gaia. Just made me realize I could need it Share this post Link to post Share on other sites
Snicke 0 Posted March 10, 2007 Thank you so much, works like a charm. But can you please explain to a beginner like me how this realy works? Didnt understand anything in that line. And If i wanted to make a triger at another place of the map that turns off the lights, how do I do that? You had a triger named lighto1, but how does it work. How do I make it active? Share this post Link to post Share on other sites
Balschoiw 0 Posted March 10, 2007 Sure: Quote[/b] ]{_x switchlight "off"} foreach (position unitname nearObjects ["streetlamp",300]); _x switchlight "off" is the action performed on the _x amount of objects that are collected within a radius of 300, that do match the type "streetlamp". The radius of 300 is applied to the unit or gamelogic that you place on the map . The calculation of 300 distance is done with (position unitname nearObjects. Hope that´s clear I boldened the parts that are used in the code. Quote[/b] ]You had a triger named lighto1, but how does it work. How do I make it active? First of all triggers have no name fields. They cannot have names. A trigger just works like a switch. You can choose whatever you like to activate it. Either you go for the basic setup with dropdown menus that fires if guys from side a,b,c are there or not there or a lot of other stuff. You can also Group the trigger to a specific unit by using F2 and drawing a line between the trigger and the unit you want to have to fire the trigger exclusively. Check out the pinned topics at the top of the mission editing thread. You will find a lot of infos on the basics like how triggers work and what functionality they offer. It would just consume to much time to list all the possibilities here. For easy going, insert the codeline in teh OnActivation field of trigger and choose a side that shall activate the trigger, set the detection method to "present" and test it in the editor with a unit of the corresponding side. Don´t forget to place a gamelogic or unit with the corresponding name in the codeline that is the centre of your radius of 300 in wich the lights will be turned off. Play around witht he trigger settings. Share this post Link to post Share on other sites
Big Dawg KS 6 Posted March 10, 2007 First of all triggers have no name fields. They cannot have names. Yes they do, and yes they can. Ex: {side _X == west} count list Trigger1 <- Trigger1 needs to me named somehow doesn't it... Share this post Link to post Share on other sites
Balschoiw 0 Posted March 10, 2007 Shouldn´t post when I just woke up at the couch Share this post Link to post Share on other sites