OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Critical_Bill on 26 May 2005, 16:24:32

Title: Listing Objects not vehicles
Post by: Critical_Bill on 26 May 2005, 16:24:32
Hello

I know you can return an list of units with a trigger set to Anybody (called 'everything' for example) and a bit of script like:
Code: [Select]
_list = list everything
But is there a way of getting a list of certain Objects? Say you wanted every ammo crate in the list or something? Can this be done?
Title: Re:Listing Objects not vehicles
Post by: bedges on 26 May 2005, 17:33:29
try playing with this (http://www.ofpec.com/editors/comref.php?letter=T#typeOf).
Title: Re:Listing Objects not vehicles
Post by: General Barron on 26 May 2005, 21:34:27
There is no way of automatically doing it. Sorry, you will have to do it by hand. :) Meaning, you have to manually construct an array with all of the ammocrates in it.

So, lets say you have 3 ammo crates, named a1, a2, and a3. Then, in your init.sqs, you would just need to place a line like this:

ammo_crates = [a1, a2, a3]

Now the global variable "ammo_crates" will contain all 3 of your crates. Simple, eh? But what if you have lots of crates, and you don't want to name them all? Well, you could make a simple script to be run from each crate's init field, which adds them to the variable. So in each crate's init field, you would put this:

this exec "addtovar.sqs"

addtovar.sqs:
Code: [Select]
~0.1 + random 0.1
ammo_crates = ammo_crates + [_this]
exit
And finally, in your init.sqs:

ammo_crates = []

Title: Re:Listing Objects not vehicles
Post by: Critical_Bill on 26 May 2005, 22:15:01
gah! thanks baron.