mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Dragging - Add parameters for FUNC(setDraggable)
& FUNC(setCarryable)
to apply globally (#10266)
This commit is contained in:
parent
96700e8dfd
commit
d56a3a6a95
@ -70,6 +70,9 @@ if (isNil QGVAR(maxWeightCarryRun)) then {
|
|||||||
[QGVAR(startCarry), LINKFUNC(startCarryLocal)] call CBA_fnc_addEventHandler;
|
[QGVAR(startCarry), LINKFUNC(startCarryLocal)] call CBA_fnc_addEventHandler;
|
||||||
[QGVAR(startDrag), LINKFUNC(startDragLocal)] call CBA_fnc_addEventHandler;
|
[QGVAR(startDrag), LINKFUNC(startDragLocal)] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
|
[QGVAR(setCarryable), LINKFUNC(setCarryable)] call CBA_fnc_addEventHandler;
|
||||||
|
[QGVAR(setDraggable), LINKFUNC(setDraggable)] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
[QGVAR(carryingContainerClosed), {
|
[QGVAR(carryingContainerClosed), {
|
||||||
params ["_container", "_owner"];
|
params ["_container", "_owner"];
|
||||||
TRACE_2("carryingContainerClosed EH",_container,_owner);
|
TRACE_2("carryingContainerClosed EH",_container,_owner);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
* 2: Position offset for attachTo command <ARRAY> (default: [0, 1, 1])
|
* 2: Position offset for attachTo command <ARRAY> (default: [0, 1, 1])
|
||||||
* 3: Direction in degrees to rotate the object after attachTo <NUMBER> (default: 0)
|
* 3: Direction in degrees to rotate the object after attachTo <NUMBER> (default: 0)
|
||||||
* 4: Override weight limit <BOOL> (default: false)
|
* 4: Override weight limit <BOOL> (default: false)
|
||||||
|
* 5: Apply globally <BOOL> (default: false)
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
@ -24,7 +25,8 @@ params [
|
|||||||
["_enableCarry", false, [false]],
|
["_enableCarry", false, [false]],
|
||||||
"_position",
|
"_position",
|
||||||
"_direction",
|
"_direction",
|
||||||
["_ignoreWeightCarry", false, [false]]
|
["_ignoreWeightCarry", false, [false]],
|
||||||
|
["_global", false, [false]]
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isNull _object) exitWith {};
|
if (isNull _object) exitWith {};
|
||||||
@ -37,6 +39,19 @@ if (!isNil "_direction" && {!(_direction isEqualType 0)}) exitWith {
|
|||||||
ERROR_2("setCarryable: Bad direction parameter [%1] for [%2], should be a number or nil",_direction,_object);
|
ERROR_2("setCarryable: Bad direction parameter [%1] for [%2], should be a number or nil",_direction,_object);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle global here
|
||||||
|
if (_global) exitWith {
|
||||||
|
private _jipID = format [QGVAR(carrying_%1), hashValue _object];
|
||||||
|
[QGVAR(setCarryable), [_object, _enableCarry, _position, _direction, _ignoreWeightCarry], _jipID] call CBA_fnc_globalEventJIP;
|
||||||
|
|
||||||
|
// Remove from JIP queue if object is deleted
|
||||||
|
if !(_object getVariable [QGVAR(setCarryableRemoveJip), false]) then {
|
||||||
|
[_jipID, _object] call CBA_fnc_removeGlobalEventJIP;
|
||||||
|
|
||||||
|
_object setVariable [QGVAR(setCarryableRemoveJip), true, true];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
if (isNil "_position") then {
|
if (isNil "_position") then {
|
||||||
_position = _object getVariable [QGVAR(carryPosition), [0, 1, 1]];
|
_position = _object getVariable [QGVAR(carryPosition), [0, 1, 1]];
|
||||||
};
|
};
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
* 2: Position offset for attachTo command <ARRAY> (default: [0, 1.5, 0])
|
* 2: Position offset for attachTo command <ARRAY> (default: [0, 1.5, 0])
|
||||||
* 3: Direction in degrees to rotate the object after attachTo <NUMBER> (default: 0)
|
* 3: Direction in degrees to rotate the object after attachTo <NUMBER> (default: 0)
|
||||||
* 4: Override weight limit <BOOL> (default: false)
|
* 4: Override weight limit <BOOL> (default: false)
|
||||||
|
* 5: Apply globally <BOOL> (default: false)
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
@ -24,7 +25,8 @@ params [
|
|||||||
["_enableDrag", false, [false]],
|
["_enableDrag", false, [false]],
|
||||||
"_position",
|
"_position",
|
||||||
"_direction",
|
"_direction",
|
||||||
["_ignoreWeightDrag", false, [false]]
|
["_ignoreWeightDrag", false, [false]],
|
||||||
|
["_global", false, [false]]
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isNull _object) exitWith {};
|
if (isNull _object) exitWith {};
|
||||||
@ -37,6 +39,19 @@ if (!isNil "_direction" && {!(_direction isEqualType 0)}) exitWith {
|
|||||||
ERROR_2("setDraggable: Bad direction parameter [%1] for [%2], should be a number or nil",_direction,_object);
|
ERROR_2("setDraggable: Bad direction parameter [%1] for [%2], should be a number or nil",_direction,_object);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle global here
|
||||||
|
if (_global) exitWith {
|
||||||
|
private _jipID = format [QGVAR(dragging_%1), hashValue _object];
|
||||||
|
[QGVAR(setDraggable), [_object, _enableDrag, _position, _direction, _ignoreWeightDrag], _jipID] call CBA_fnc_globalEventJIP;
|
||||||
|
|
||||||
|
// Remove from JIP queue if object is deleted
|
||||||
|
if !(_object getVariable [QGVAR(setDraggableRemoveJip), false]) then {
|
||||||
|
[_jipID, _object] call CBA_fnc_removeGlobalEventJIP;
|
||||||
|
|
||||||
|
_object setVariable [QGVAR(setDraggableRemoveJip), true, true];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
if (isNil "_position") then {
|
if (isNil "_position") then {
|
||||||
_position = _object getVariable [QGVAR(dragPosition), [0, 1.5, 0]];
|
_position = _object getVariable [QGVAR(dragPosition), [0, 1.5, 0]];
|
||||||
};
|
};
|
||||||
|
@ -47,12 +47,12 @@ DFUNC(replaceTerrainModelsAdd) = {
|
|||||||
) then {
|
) then {
|
||||||
// wait while server replaces object, then init dragging on all clients
|
// wait while server replaces object, then init dragging on all clients
|
||||||
[{
|
[{
|
||||||
if (typeOf cursorObject == "") exitwith {};
|
private _object = cursorObject;
|
||||||
[cursorObject, {
|
|
||||||
if !hasInterface exitWith {};
|
if (isNull _object) exitwith {};
|
||||||
[_this, true] call EFUNC(dragging,setDraggable);
|
|
||||||
[_this, true] call EFUNC(dragging,setCarryable);
|
[_object, true, nil, nil, nil, true] call EFUNC(dragging,setCarryable);
|
||||||
}] remoteExec ["call", 0];
|
[_object, true, nil, nil, nil, true] call EFUNC(dragging,setDraggable);
|
||||||
}, [], 1] call CBA_fnc_waitAndExecute;
|
}, [], 1] call CBA_fnc_waitAndExecute;
|
||||||
};
|
};
|
||||||
true
|
true
|
||||||
|
@ -53,6 +53,7 @@ You will **not** be able to carry / drag objects that are too heavy, the mass is
|
|||||||
| 2 | Position to offset the object from player | Array | Optional (default: `[0, 1.5, 0]`) |
|
| 2 | Position to offset the object from player | Array | Optional (default: `[0, 1.5, 0]`) |
|
||||||
| 3 | Direction in degree to rotate the object | Number | Optional (default: `0`) |
|
| 3 | Direction in degree to rotate the object | Number | Optional (default: `0`) |
|
||||||
| 4 | Ignore weight limitation for dragging | Boolean | Optional (default: `false`) |
|
| 4 | Ignore weight limitation for dragging | Boolean | Optional (default: `false`) |
|
||||||
|
| 5 | Apply changes globally | Boolean | Optional (default: `false`) |
|
||||||
| **R** | None | None | Return value |
|
| **R** | None | None | Return value |
|
||||||
|
|
||||||
#### 2.1.1 Example 1
|
#### 2.1.1 Example 1
|
||||||
@ -63,7 +64,7 @@ You will **not** be able to carry / drag objects that are too heavy, the mass is
|
|||||||
|----| --------- | ----------- |
|
|----| --------- | ----------- |
|
||||||
| 0 | `foo` | My object |
|
| 0 | `foo` | My object |
|
||||||
| 1 | `true` | Dragging is enabled |
|
| 1 | `true` | Dragging is enabled |
|
||||||
| 2 | `[0,2,0]` | 0 meters sideways, 2 meters forward, 0 |meters upwards
|
| 2 | `[0,2,0]` | 0 meters sideways, 2 meters forward, 0 meters upwards |
|
||||||
| 3 | `45` | Rotated by 45° |
|
| 3 | `45` | Rotated by 45° |
|
||||||
|
|
||||||
#### 2.1.2 Example 2
|
#### 2.1.2 Example 2
|
||||||
@ -89,6 +90,7 @@ You will **not** be able to carry / drag objects that are too heavy, the mass is
|
|||||||
| 2 | Position to offset the object from player | Array | Optional (default: `[0, 1, 1]`) |
|
| 2 | Position to offset the object from player | Array | Optional (default: `[0, 1, 1]`) |
|
||||||
| 3 | Direction in degree to rotate the object | Number | Optional (default: `0`) |
|
| 3 | Direction in degree to rotate the object | Number | Optional (default: `0`) |
|
||||||
| 4 | Ignore weight limitation for carrying | Boolean | Optional (default: `false`) |
|
| 4 | Ignore weight limitation for carrying | Boolean | Optional (default: `false`) |
|
||||||
|
| 5 | Apply changes globally | Boolean | Optional (default: `false`) |
|
||||||
| **R** | None | None | Return value |
|
| **R** | None | None | Return value |
|
||||||
|
|
||||||
#### 2.2.1 Example
|
#### 2.2.1 Example
|
||||||
|
Loading…
Reference in New Issue
Block a user