[Mistakenly first posted in Forums]
With 2.14, the newly introduced HashMapObject functionality seems broken.
I observed that self in an object's constructor does not seem to be an actual HashMap object.
Using 2.14.150957 and the actual example code on the Biki (Example 4):
private _temporaryVehicle = [ ["#create", { params ["_vehicleType", "_vehiclePos", "_lifetimeSeconds"]; // handle constructor arguments private _newVehicle = _vehicleType createVehicle _vehiclePos; _self set ["MyVehicle", _newVehicle ]; // Store the vehicle inside the object for later // because _self is passed as parameter, it will be referenced by the spawned script until it ends. [_lifetimeSeconds, _self] spawn { params ["_lifetimeSeconds", "_self"]; sleep _lifetimeSeconds; }; }], ["#delete", { deleteVehicle (_self get "MyVehicle"); // delete the vehicle when we go away }], ["MyVehicle", objNull] // placeholder, this is not needed ]; // create a temporary RoadCone, at player position, that will delete itself after 5 seconds. createHashMapObject [_temporaryVehicle, ["RoadCone_F", getPos player, 5]];
Results in this error:
22:11:41 Error in expression <leType createVehicle _vehiclePos; _self set ["MyVehicle", _newVehicle ]; [_li> 22:11:41 Error position: <set ["MyVehicle", _newVehicle ]; [_li> 22:11:41 Error Type String, expected Number 22:11:41 File mpmissions\scripting-test.Tanoa\initPlayerLocal.sqf..., line 5
Using _self in actual methods, however, seems to work fine.
Somebody went on to comment:
That works without error, for me. I just placed the code in a radio trigger, without any comment.
Should work also in initPlayerLocal... so, not sure to understand. Sorry.
It doesn't work in initPlayerLocal.sqf, though.
I did, however, work in the debug console.
See the attached minimal Stratis map. The RPT (no mods) is included in the ZIP file.