Jump to content
Sign in to follow this  
buliwyf

ObjectGrabber.sqf don`t get object init entries

Recommended Posts

Hello..

I tried to get the ObjectGrabber.sqf to work getting the init entries of objects but i have no luck.

//Validate parameter count
if ((count _this) < 2) exitWith {diag_log "Log: [objectGrabber] Function requires at least 2 parameter!"; false};
private ["_anchorPos", "_anchorDim"];
_anchorPos = _this select 0;
_anchorDim = _this select 1;
//Validate parameters
if  ((typeName _anchorPos) != (typeName [])) exitWith {diag_log "Log:  [objectGrabber] Anchor position (0) must be an Array!"; false};
if  ((typeName _anchorDim) != (typeName 0)) exitWith {diag_log "Log:  [objectGrabber] Covered area size (1) must be an Number!"; false};
private ["_objs"];
_objs = nearestObjects [_anchorPos, ["All"], _anchorDim];
diag_log "#####################################";
diag_log "### Log: objectGrabber: StartGrabbing";
diag_log "#####################################";
for "_i" from 0 to ((count _objs) - 1) do {
private ["_obj", "_type"];
_obj = _objs select _i;
_type = typeOf _obj;
//Exclude human objects.
private ["_sim"];
_sim = getText (configFile >> "CfgVehicles" >> _type >> "simulation");
if !(_sim in ["soldier"]) then {
	private ["_objPos", "_dX", "_dY", "_z", "_azimuth", "_fuel", "_damage", "_vehicleInit"];
	_objPos = position _obj;
	_dX = (_objPos select 0) - (_anchorPos select 0);
	_dY = (_objPos select 1) - (_anchorPos select 1);
	_z = _objPos select 2;
	_azimuth = direction _obj;
	_fuel = fuel _obj;
	_damage = damage _obj;
	_vehicleInit = _obj getVariable "vehicleInit";
	if (isNil "_vehicleInit") then {{}} else {_obj getVariable "vehicleInit";};
	// _obj setvariable ["vehicleInit",_vehicleInit];
	diag_log text(format ["%1,", [_type, [_dX, _dY, _z], _azimuth, _fuel, _damage, _vehicleInit]]);
};
};
diag_log "###################################";
diag_log "### Log: objectGrabber: EndGrabbing";
diag_log "###################################";
true

This is my actual code (got it somewhere from the www and edited it a little). But in the RPT file the vehicleInit is empty...

["Land_HBarrier5",[0.951172,-3.62695,-0.00756836],305,1,0,<null>],
["Land_HBarrier5",[5.875,-4.28906,0.000518799],215,1,0,<null>],
["Land_Fire_barrel_burning",[3.23633,-6.30762,3.05176e-005],360,1,0,<null>],
["Land_HBarrier5",[10.3994,-7.37598,-0.000488281],215,1,0,<null>],
["Land_HBarrier_large",[-9.47461,5.01855,0.000305176],215,1,0,<null>]

It puts me the <null> code in the RPT file. Do anyone get it to work?

Share this post


Link to post
Share on other sites

Have you: this setVariable ["vehicleInit", "MY_INIT_STRING"] on your object? Otherwise I don't see how it should work. AFAIK there is no command to get the init line of an object. There is, however, one to clear, and set it.

Share this post


Link to post
Share on other sites
Have you: this setVariable ["vehicleInit", "MY_INIT_STRING"] on your object? Otherwise I don't see how it should work. AFAIK there is no command to get the init line of an object. There is, however, one to clear, and set it.

No i simply puted the init entries like i always do. Example from misson.sqm:

init="this setpos [(getpos this) select 0, (getpos this) select 1, 1.35];";

I thought it was possible to read the init entries with the getVariable command... =/

Wondering that it isn`t possible...

Share this post


Link to post
Share on other sites

Unless something has been setVariable'd you cannot getVariable it. None of the commands do that. From http://community.bistudio.com/wiki/Dynamic_Object_Compositions

5) If you want a custom object init you have to use this format in the initialization field of the object otherwise it wont be grabbed: this setvariable ["VehicleInit","<YOUR INITSTRING>;"]

So you have to manually do this. Which mean instead of

this setpos [(getpos this) select 0, (getpos this) select 1, 1.35];

You do:

this setVariable ["VehicleInit", "this setpos [(getpos this) select 0, (getpos this) select 1, 1.35];"];

Also remember to escape quotes if you strings or the like in your original init.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×