Ace3: How to explicite deleting things (objects) while they are stored in Cargo ?

Created on 14 Aug 2017  路  9Comments  路  Source: acemod/ACE3

Hello,

I'm sorry if the solution for this problem is really very easy , but I've read the whole ACE3 Framework API documentation and couldn't find the answer . It looks like there is no such function at all , or there is, but not documented yet....

I've made the little (but nice :) ) logistic system for my team (and its training issues ) and I need to provide them with the containers which are filled up with the equipment I've chosen. Everithing works all right, but the problem is when I try to use the loop for repetively refilling this container, because the new things I've load in this loop succesively increase the amount of the cargo , and I only want to overwrite the old things with the new things on each loop pass.

My loop (added to the init of the containeer) looks like :

if (! isServer) exitWith {};

_container = _this select 0;
_refreshTime = 360;

while {alive _container} do
{

["Box_mas_ru_rifle_Wps_F", _container] call ace_cargo_fnc_loadItem;
["Box_mas_nw_rifle_Wps_F", _container] call ace_cargo_fnc_loadItem;
["Box_mas_us_rifle_Wps_F", _container] call ace_cargo_fnc_loadItem;
["Box_mas_all_rifle_Wps_F", _container] call ace_cargo_fnc_loadItem;
["TF_NATO_Radio_Crate", _container] call ace_cargo_fnc_loadItem;
["ACE_medicalSupplyCrate_advanced", _container] call ace_cargo_fnc_loadItem;
["ACE_medicalSupplyCrate", _container] call ace_cargo_fnc_loadItem;
["ACE_Box_Misc", _container] call ace_cargo_fnc_loadItem;
["ACE_Box_Ammo", _container] call ace_cargo_fnc_loadItem;
["Box_NATO_AmmoOrd_F", _container] call ace_cargo_fnc_loadItem;
["Box_NATO_Grenades_F", _container] call ace_cargo_fnc_loadItem;
["ACE_Box_Chemlights", _container] call ace_cargo_fnc_loadItem;
["Box_NATO_AmmoVeh_F", _container] call ace_cargo_fnc_loadItem;

sleep _refreshTime;
};

So I probably need to use first in my loop the function similiar to
clearItemCargoGlobal _crate;
but this function comes from bohemia and works with objects like crate (box, etc)
and touches its inwentory , not a cargo space.

In the ACE Framework docs - I've found some very usefull functions for loading , unloading, changing cargo space etc, but there's no fuction for deleting (cleaning up ) the whole cargo space , documented yet.

And his is my question - if there is such function in ACE Cargo Framework and how to use it ?

Thank you from advance for help :)

//markooff

kinquestion

All 9 comments

Thank You very much bux,

I'll try with this function and hope it'll works pretty good :)

THX

This function will delete ALL objects stored in cargo and it's not designed to be called from external.
But it should give you an idea on how to achieve your task.

ehm , but i'm not sure if I'm using it in the right way, because I'm a bit newbe in SQF scripting (the language isn't as similiar to C++ or Java or even PHP or ECMA script as I've thought before)

I've tried to put this construction in my loop and now it looks like :

while {alive _container} do
{
//[_container, -1] call ace_cargo_fnc_setSize;
//sleep 2;
//[_container, 50] call ace_cargo_fnc_setSize;


private _loaded = _container getVariable [QGVAR(loaded), []];

if (_loaded ! isEqualTo []) {
            // TODO Do we want to be able to recover destroyed equipment?
            if (_x isEqualType objNull) then {
            deleteVehicle _x;
            };
            nil
        } count _loaded;

        [_container] call FUNC(validateCargoSpace);


sleep 5;

["Box_mas_ru_rifle_Wps_F", _container] call ace_cargo_fnc_loadItem;
["Box_mas_nw_rifle_Wps_F", _container] call ace_cargo_fnc_loadItem;
["Box_mas_us_rifle_Wps_F", _container] call ace_cargo_fnc_loadItem;
["Box_mas_all_rifle_Wps_F", _container] call ace_cargo_fnc_loadItem;
["TF_NATO_Radio_Crate", _container] call ace_cargo_fnc_loadItem;
["ACE_medicalSupplyCrate_advanced", _container] call ace_cargo_fnc_loadItem;
["ACE_medicalSupplyCrate", _container] call ace_cargo_fnc_loadItem;
["ACE_Box_Misc", _container] call ace_cargo_fnc_loadItem;
["ACE_Box_Ammo", _container] call ace_cargo_fnc_loadItem;
["Box_NATO_AmmoOrd_F", _container] call ace_cargo_fnc_loadItem;
["Box_NATO_Grenades_F", _container] call ace_cargo_fnc_loadItem;
["ACE_Box_Chemlights", _container] call ace_cargo_fnc_loadItem;
["Box_NATO_AmmoVeh_F", _container] call ace_cargo_fnc_loadItem;

sleep _refreshTime;
};

Perhaps I didt it wrong way , but as far as I can understand the count sentence act as the sort of loop here
and _x is the current element of each loop pass , isn't it ?
And i'm not sure about the condition
(_x isEqualType objNull)
if it's right here - because later in the loop I construct the objects in Cargospace using
TypeOf "strings" ... so perhaps I should treat them as "strings" after they are loaded , or not ?

And my second doubt - whether the line
[_container] call FUNC(validateCargoSpace);
should be inside the inner loop or not ?

Sorry for asking, but I try to understand and learn better the sqf syntax :)

Some of the code you used like QGVAR(loaded) and FUNC(validateCargoSpace) are preprocessor macros, which work almost exactly the way they do in C++. Their usage is documented here. They are declared in ACE's header files, and unless you include the right headers too, those lines should throw script errors (You should _really_ use -showScriptErrors when testing scripts!). The correct way to use that function would be to write ace_cargo_fnc_validateCargoSpace for you, and the string for getVariable would be "ace_cargo_loaded".

Also noticed that if (_loaded ! isEqualTo []) { is wrong, it should be if !(_loaded isEqualTo []). It's not as simple as spelling "loaded not is equal to empty array" I'm afraid 馃槃.

You also have bunch of other missing brackets after that if statement.

A public API function to do this operation should probably be added 馃憤

Think #5432 might close this.

Yes, sure things,
anyway thank you esp. for commenting my post and for all advices !

@654wak654 - I always see the script errors produced by the scripts , because I use Eden Editor and as the https://community.bistudio.com/wiki/Arma_3_Startup_Parameters#Developer_Options sais : " In Eden Editor, script errors are always shown, even when this parameter is not used. "
Of course if it shows the same errors level ....

Anyway - sometimes to see some errors produced , doesn't automatically mean to uderstand them , so thank you (all of you) for some explanations :)

@markooff I strongly suggest you join the ACE3 Slack (link on front page of this repository), as it is a lot easier to explain something when you can chat in real-time. ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ItayNoyman picture ItayNoyman  路  3Comments

austinjames314 picture austinjames314  路  4Comments

thirald picture thirald  路  3Comments

Avokadomos picture Avokadomos  路  3Comments

SimichRE picture SimichRE  路  3Comments