ACE3/addons/cargo/functions/fnc_makeLoadable.sqf

48 lines
1.3 KiB
Plaintext
Raw Normal View History

2016-01-19 03:53:48 +00:00
/*
* Author: PabstMirror
* Makes any object loadable. Needs to be called on all machines.
*
* Arguments:
* 0: Object <OBJECT>
* 1: Set as loadable (default: true) <BOOL><SCALAR>
* 2: Size. (default: 1) <NUMBER>
*
2016-06-18 09:50:41 +00:00
* Return Value:
2016-01-19 03:53:48 +00:00
* None
*
* Example:
* [cursorTarget, true, 1] call ace_cargo_fnc_makeLoadable
*
* Public: Yes
*/
#include "script_component.hpp"
params [["_object", objNull, [objNull]], ["_canLoad", true, [false, 0]], ["_setSize", 1, [0]]];
TRACE_3("params",_object,_canLoad,_setSize);
if (isNull _object) exitWith {TRACE_1("null",_object);};
private _type = typeOf _object;
private _cfgCanLoad = getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(canLoad));
private _curSize = [_object] call FUNC(getSizeItem);
_canLoad = [0, 1] select _canLoad; //convert true/false to scalar
if ((_canLoad == 1) && {_setSize <= 0}) exitWith {
2016-08-22 19:06:52 +00:00
ERROR("ace_cargo_fnc_makeLoadable (size <= 0) when making loadable");
2016-01-19 03:53:48 +00:00
};
TRACE_2("setVar if different from config",_canLoad,_cfgCanLoad);
if (_canLoad != _cfgCanLoad) then {
_object setVariable [QGVAR(canLoad), _canLoad];
};
TRACE_2("setVar if different from config",_setSize,_curSize);
if (_setSize != _curSize) then {
_object setVariable [QGVAR(size), _setSize];
};
//Add the load actions to the object class if not already added
[_object] call FUNC(initObject);
nil