Jump to content
Sign in to follow this  
zorilya

SetVariable on Demolition Charge

Recommended Posts

After having a headache from trying to figure out what was wrong with my latest project i realized it was an uninitialized variable being set using the setVariable command. my script was originally :


_item = (nearestObject [player,"TimeBombCore"]);

fnc_test = 
{
_thing = _this select 0;
hint (str(_thing));
sleep 1;

_thing setVariable ["Name","bomb"];
_variable = _thing getVariable ["Name","no name"];
hint (str(_variable));
sleep 1;
};

[_item] call fnc_test;

_var = _item getVariable ["Name","no name"];

hint (str(_var));

in this example i was testing if it was perhaps due to when it was being used i.e. called in a function.

this one returned the object reference of the model i.e. 123456: C4_charge.p3d or whatever it is

then "no name"

and finally "no name"

so i tried this instead

_item = (nearestObject [player,"TimeBombCore"]);

fnc_test = 
{
_thing = _this select 0;
hint (str(_thing));
sleep 1;

_thing setVariable ["Name","bomb"];
_variable = _thing getVariable ["Name","no name"];
hint (str(_variable));
sleep 1;
};

[_item] call fnc_test;

_var = _item setVariable ["Name","bomb"];
hint (str(_var));
sleep 1;

_var = _item getVariable ["Name","no name"];

hint (str(_var));

again just to test if it was an issue of where it was being defined.

still i could not get a return of the name being "bomb".

so to recap:

the script has the charge object stored in the main script scope and in the fnc_test when it is called.

neither times with the variable is set does it actually seem to has set a value in any variable space.

any Ideas as to why this might be. I can only conclude that you cannot setVariable using this particular object but it seems odd that every other object reference seems to be perfectly fine with setVariable e.g. units, houses, vehicles

Share this post


Link to post
Share on other sites

I ran into something like this with ArmA2 the other night. Trying to add an action to a pipe on the map. I was able to get it as an object, move you to it's location but I couldn't addAction to it and trying to attach things to it would crash the game. So it was like it was there but wasn't "real". Might be the same thing for this demo charge where it's a p3d object but not a class of object you can fully interact with?

You can get the "projectile object" from a fired eventHandler. But like my pipe wheel some commands just don't affect it, like setVariable and addAction.

this addEventHandler ["Fired", {demoCharge = (_this select 6)}];
"demoMarker" setMarkerPos getPos demoCharge; // works
demoCharge setVariable ["name", "My First Demo Charge"]; // doesn't work

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  

×