ACE3/addons/cargo/functions/fnc_initObject.sqf

47 lines
1.4 KiB
Plaintext
Raw Normal View History

2015-08-10 21:07:47 +00:00
/*
* Author: Glowbal
2015-08-16 20:41:35 +00:00
* Initializes variables for loadable objects. Called from init EH.
2015-08-10 21:07:47 +00:00
*
* Arguments:
2015-08-16 20:41:35 +00:00
* 0: Object <OBJECT>
2015-08-10 21:07:47 +00:00
*
* Return value:
* None
*
2015-08-16 20:41:35 +00:00
* Example:
* [object] call ace_cargo_fnc_initObject
*
2015-08-10 21:07:47 +00:00
* Public: No
*/
#include "script_component.hpp"
params ["_object"];
2016-01-19 03:53:48 +00:00
private _type = typeOf _object;
TRACE_2("params",_object,_type);
2015-08-10 21:07:47 +00:00
2016-01-19 03:53:48 +00:00
if ((_object getVariable [QGVAR(canLoad), getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(canLoad))]) != 1) exitWith {};
2015-08-10 21:07:47 +00:00
// do nothing if the class is already initialized
if (_type in GVAR(initializedItemClasses)) exitWith {};
GVAR(initializedItemClasses) pushBack _type;
2016-01-19 03:53:48 +00:00
TRACE_1("Adding load cargo action to class", _type);
private _condition = {
GVAR(enable) &&
{(_target getVariable [QGVAR(canLoad), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(canLoad))]) == 1} &&
{locked _target < 2} &&
{alive _target} &&
{[_player, _target, []] call EFUNC(common,canInteractWith)}
};
private _statement = {
params ["_target", "_player"];
[_player, _target] call FUNC(startLoadIn);
};
private _text = localize LSTRING(loadObject);
private _icon = QUOTE(PATHTOF(UI\Icon_load.paa));
private _action = [QGVAR(load), _text, _icon, _statement, _condition] call EFUNC(interact_menu,createAction);
2015-08-10 21:07:47 +00:00
[_type, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass);
2016-01-19 03:53:48 +00:00