Jump to content
pierremgi

Custom module and synced vehicles

Recommended Posts

Hi, new problem today.

 

I'm trying to pick the array of all synced vehicles to my module...

 

I don't have any problem in 3den, using:

class RespObjectsString: EDIT
              {
                property = "MGI_ModuleRespVeh_respObjectsString";
                displayName = "These objects can respawn";
                tooltip = "Link existing vehicles/crates. They will appear in this array. Do not write anything here.";
                typeName = "STRING";
                defaultValue = "'[]'";
            };

Then, in my module function, fine also:

if (is3den) then {
    _logic = _input param [0,objNull,[objNull]];
    _connects = get3DENConnections _logic apply {_x select 1};
    _vehicles = all3DENEntities select 0 select {_x in vehicles};
    _vehiclesLogic = _vehicles  select {_x in _connects};
    _logic set3DENAttribute ["MGI_ModuleRespVeh_respObjectsString",str(_vehiclesLogic)];
};

And then, when game starts, this sqf code:

_respObjectsString =  _logic getVariable ["RespObjectsString","[]"];
  _respObjects = call compile _respObjectsString;

 

So far, the edit zone is updated while in 3den and I can read something like:

[B Alpha 1-1:1,1ca82d30080# 1675089: quadbike_01_f.p3d,R Alpha 1-2:1]

where B Alpha 1-1:1 and R Alpha 1-2:1are 2 manned vehicles, and  1ca82d30080# 1675089: quadbike_01_f.p3d  , an empty one.

 

The problem is at start of the game. After call compile _respObectsString, I get an error message:

The string seems OK : "[B Alpha 1-1:1,1ca82d30080# 1675089: quadbike_01_f.p3d,R Alpha 1-2:1]"

but:

Error in expression <[B Alpha 1-1:1,1ca82d30080# 1675089: quadbi>
Error position: <Alpha 1-1:1,1ca82d30080# 1675089: quadbi>
Error Missing ]

 

I know I could refer to synchronizedObjects to the logic once in game. But I need this array for the order the vehicles were synced. And that's no so evident if I can't get this array.

I'm nor sure to understand why I'm so close to this aim, but the array of objects fails for a ] ...

A compile problem?

Share this post


Link to post
Share on other sites

Sorry, to make it short and reproducible:

Using the console, pointing at a vehicle:

 

aa = str([cursorObject]); // returns "[1ca8ac5c080# 1675079: truck_02_transport_f.p3d]"

bb = call compile aa; // error

 Error in expression <[1ca8ac5c080# 1675079: truck_02_transport_>
Error position: <ca8ac5c080# 1675079: truck_02_transport_>
Error Missing ]

 

Share this post


Link to post
Share on other sites
34 minutes ago, pierremgi said:

aa = str([cursorObject]); // returns "[1ca8ac5c080# 1675079: truck_02_transport_f.p3d]"

bb = call compile aa; // error

 

Compile cannot possibly compile this: "1ca8ac5c080# 1675079: truck_02_transport_f.p3d"

 

why are you using strings, why not just objects in array?

 

Share this post


Link to post
Share on other sites
5 minutes ago, gc8 said:

 

Compile cannot possibly compile this: "1ca8ac5c080# 1675079: truck_02_transport_f.p3d"

 

why are you using strings, why not just objects in array?

 

Because the typeName in edit class can't be an array. Must be a string, a number or a boolean.

Anyway, using an array, I obtain a [<null>,<null>,<null>] result.

 

Why is it such difficult to pass an array of objects from 3den to sqf mission??? It's ridiculous!

Share this post


Link to post
Share on other sites

If you are just after the type of object then you should just store its type, rather than an object reference. Of which an object reference cannot be stringified and converted back.

 

If you do actually want a reference to the specific synced object then you really should be getting the references at runtime in your modules init function.

 

The only other way during Eden is to call BIS_fnc_objectVar on the object and update the entities name attribute and your attribute with the returned string. This is potentially a bad way to handle this as  1. A mission designer will not be able to name their synced vehicles 2. If they do it will break your module. (unless you monitor for this and update your attribute accordingly).

 

Again if you need object references of synced objects then you should really do it at runtime (see BIS_fnc_moduleSector for instance on how it at runtime, via its module function, gets references to all the synced objects (locations, triggers, flags, etc) ).

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks  both of you.

I succeeded in the challenge to build an updated array of objects (vehicles), on which the mission maker can decide to apply a respawn position.

As you pointed, I had to apply a name on each unnamed linked vehicle. as a name is always a compilable string, that works, with custom or automatic names. You can change the name as well, or unlink/re_link the vehicle to the module, without too much impact on a mission.

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

×