Jump to content
  • 0

passing vars acrossed files


ViktorReznov

Question

So I am having an issue passing a cursorTarget from a selfAction from the first script its executed into _vehicle = (_this select 3). Later in that script, I want to retain the object in _vehicle and pass it on from that script to another script. I verify that the original container is an object Vehicle = 2b8b50c0# 1065711: suv.p3d and then in the next script my diag log reads Vehicle = <NullObject>

Ive tried exec the vehicle variable as [_vehicle] execVM "script\path\"; and then in that script, i try to reference my object as _object = _this select 0; Should be returning my object no? Its been returning as Null.....

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hello,

This is pretty much exactly how you are doing it, here's the test I just did:

I modified a script that has a vehicle object passed from fn_selfActions (hotwire.sqf) so that it has this debug line:

systemChat format ["DEBUG: hotwire_veh: _this: %1",_this];

[_vehicle] execVM "scripts\blah.sqf";

after this line: https://github.com/EpochModTeam/DayZ-Epoch/blob/master/SQF/dayz_code/actions/hotwire_veh.sqf#L2

scripts\blah.sqf is this example:

_vehicle = _this;

systemChat format ["DEBUG: _this: %1",_this];

Both debug lines show correctly in my system chat.

Discord is really good for questions like this btw: https://discord.gg/qX5JrPh

 

Link to comment
Share on other sites

  • 0

i believe it was the scope I had the variable in. that first line is always pirvate["stuff"] and ofcourse, being such a novice, i always contained all my vars there. It seemed to fix my issue but later, as I jumped through more files, it failed me again.

script one exec from addaction in self actions

_vehicle = _this select 3;

_vehicle call compile preprocessFileLineNumbers "scripts\scrapper\parts_vehicle.sqf";

script 2

_vehicle = _this;

[_vehicle,_toSpawnArray] call compile preprocessFileLineNumbers "scripts\scrapper\weapon_Parts.sqf";

script 3

_vehicle = _this select 0;

[_vehicle,_toSpawnArray,_wepsArray,_bagsArray] call compile preprocessFileLineNumbers "scripts\scrapper\spawnParts.sqf";

script 4

_vehicle = _this select 0;

trying to exec any of that as anything other than what i have posted always passes the var on as <NULL-object> even with the scope changes, without the change in scope it is still <NULL-object>

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...