Home   Help Search Login Register  

Author Topic: Listing Lamps?  (Read 1384 times)

0 Members and 1 Guest are viewing this topic.

Merc

  • Guest
Listing Lamps?
« on: 03 Jun 2005, 20:42:28 »
Do lists only return people or can they return anything, like streetlamps?

Code: [Select]
#Loop
? IsNull _obj : exit
_Lista = list trigger1
_zoneCount = count _Lista
? _j > _zoneCount : _j = 0
_thing = _Lista select _j
?_thing == "Streetlamp" : _thing action ["lights_off"]
_j = _j + 1
~1
goto "Loop"

This would be cool in night missions if it's possible.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Listing Lamps?
« Reply #1 on: 03 Jun 2005, 21:36:39 »
A trigger does not detect lamposts.

To turn lamps off you need to use their object number, as follows:

Code: [Select]
(object 28420) switchlight "OFF"
You can find the object numbers by running a script such as this one:

Code: [Select]
_maxid = 200000

_ids = []

_i = 0
#loop
if (typeof object _i == "StreetLampPanel") then {_ids = _ids + [_i] }
_i = _i + 1
if (_i <= _maxid) then {goto "loop"}

_j = 0
#loop2
hint format ["%1",_ids]
~10
_j = _j + 1
if (_j < 3) then {goto"loop2"}
exit

Instead of StreetLampPanel, also run the code with the following to ensure you get the lot:
StreetLampMetal
StreetLampWood
StreetLampPanelAmpl
StreetLampYellow
StreetLampCut

Be patient, the script take a long time to run
« Last Edit: 03 Jun 2005, 21:37:32 by THobson »

Merc

  • Guest
Re:Listing Lamps?
« Reply #2 on: 03 Jun 2005, 23:46:00 »
Would I stick that script in a trigger and run it like so or stick it somewhere else? and would inserting the line:
Code: [Select]
[_i] switchlight "OFF" turn off the lights as the script is running?

I have another question, how would u tell if all the east units (men and vehicles that are not empty) in a trigger area were dead? Would you use a list or something else?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Listing Lamps?
« Reply #3 on: 04 Jun 2005, 08:57:33 »
The script for finding the object ids takes a long time to run (several minutes) so it is not really for use in the game.  Run it on its own and then make a note of the object ids for the lamps then in your init.sqs or somewhere else in the mission have the switchlight "OFF" instructions.  You can do that for several lights in a simple way:

Code: [Select]
{(object _x) switchlight "OFF"} forEach [1251,2003,28419,......]
where the numbers in the array are the object ids that you get from running the script.

As an exercise in scriptng only - if you did want to modify the script to find them as well as turn them off then it should look something like:

Code: [Select]
_maxid = 200000
_i = 0
#loop
if (typeof (object _i) in ["StreetLampPanel","StreetLampMetal","StreetLampWood","StreetLampPanelAmpl","StreetLampYellow","StreetLampCut"]) then {(object _i)  switchlight "OFF"}
_i = _i + 1
if (_i <= _maxid) then {goto "loop"}

exit


Note That:
Code: [Select]
if (typeof (object _i) in ["StreetLampPanel","StreetLampMetal","StreetLampWood","StreetLampPanelAmpl","StreetLampYellow","StreetLampCut"]) then {(object _i)  switchlight "OFF"}Is all one line.


On your second question:

If you create an East Present trigger and set it to repeating then it will activate whenever there are living east units in its area and it will deactivate if there are none.

So:
East Present
Repeating
Condition: this
Deactivate: Put here whatever it is you want to happen when the last one in the area gets killed (or moves out of the area).

It might work with a non-Repeating trigger - I just have not checked that.

If you want to check this from a script then give the trigger a name - say trigEastThere
In the script you can see what units are in the trigger area by checking the value of:

Code: [Select]
list trigEastThere
so for example

Code: [Select]
count list trigEastThere
would give you the number of units in the trigger area.

« Last Edit: 04 Jun 2005, 10:12:48 by THobson »

Merc

  • Guest
Re:Listing Lamps?
« Reply #4 on: 04 Jun 2005, 13:58:04 »
That solves my problem. Thanks THobson! I'm going to go try it right now.
« Last Edit: 04 Jun 2005, 14:00:34 by Merc »