Pass Object to Function - Scripting Help

axeman

OpenDayZ Rockstar!
Hi, am hoping some scripting guru can help me out here or point out why I am doing this the wrong way.

I am looping through houses within a distance with
Code:
_objHouse = nearestObjects [player, ["House"], 100];
{
} forEach _objHouse;
Within that I am <doing stuff> and want to call another function and pass the current house object to that function so I can reference that object (house) directly, with:
Code:
_x execVM "scripts\animate_lights_off.sqf";

The only problem is when into the function (animate_lights_off.sqf), if I, essentially, hint this select 0; I get the word any returned and not the usual array of info. from the house..?

I have tried all sorts of permutations with no result. I have considered looking for the house again once in the new function but can not guarantee I have the exact same house.

I must be missing something obvious here as no amount of Googling is helping..
 
Code:
{_x execVM "scripts\animate_lights_off.sqf";}
forEach ((getPos player)  nearObjects ["House",100]);

http://community.bistudio.com/wiki/nearObjects
http://www.kylania.com/ex/?p=87

Similar code:
Code:
_types = ["Land_PowLines_WoodL", 
          "Land_PowLines_ConcL", 
          "Land_lampa_ind_zebr", 
          "Land_lampa_sidl_3", 
          "Land_lampa_vysoka", 
          "Land_lampa_ind", 
          "Land_lampa_ind_b", 
          "Land_lampa_sidl"];
_lamps = getmarkerpos "powercoverage" nearObjects [_types select _i, 1200];
 sleep 1;
 {_x switchLight "OFF";} forEach _lamps;
 
That is, essentially, what I am doing. When I reference the _x from the new function by assigning _house = this select 0; I get the value any instead of the array of information about the house..

For now I have got round this by putting the code into the places on the main code page, obviously want to not have to repeat code though.
 
you could try using spawn instead of execvm.

Code:
animate_lights_off compile preprocessFileLineNumbers "scripts\animate_lights_off.sqf"
 
_scriptTarget = nearestObjects [player, ["house"], 100];
{_id =[_x] spawn animate_lights_off;} forEach _scriptTarget;

Assuming that "animate_lights_off.sqf" takes "_someobject = _this select 0;"
 
Back
Top