From 776a79940c6dd6fcbaa3cc1ef163581bd6a5c080 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 6 Feb 2024 16:35:41 +0100 Subject: [PATCH 1/3] Getter and setter for laser codes --- addons/laser/XEH_PREP.hpp | 2 ++ addons/laser/functions/fnc_getLaserCode.sqf | 20 ++++++++++++++++++++ addons/laser/functions/fnc_setLaserCode.sqf | 21 +++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 addons/laser/functions/fnc_getLaserCode.sqf create mode 100644 addons/laser/functions/fnc_setLaserCode.sqf diff --git a/addons/laser/XEH_PREP.hpp b/addons/laser/XEH_PREP.hpp index 9b9be647527..2d26ff81f25 100644 --- a/addons/laser/XEH_PREP.hpp +++ b/addons/laser/XEH_PREP.hpp @@ -3,6 +3,7 @@ PREP(addLaserTarget); PREP(addMapHandler); PREP(dev_drawVisibleLaserTargets); PREP(findLaserSource); +PREP(getLaserCode); PREP(handleLaserTargetCreation); PREP(keyLaserCodeChange); PREP(laserOff); @@ -13,6 +14,7 @@ PREP(onLaserDesignatorDraw); PREP(rotateVectLine); PREP(rotateVectLineGetMap); PREP(seekerFindLaserSpot); +PREP(setLaserCode); PREP(shootCone); PREP(shootRay); PREP(showVehicleHud); diff --git a/addons/laser/functions/fnc_getLaserCode.sqf b/addons/laser/functions/fnc_getLaserCode.sqf new file mode 100644 index 00000000000..7dd7c396a1d --- /dev/null +++ b/addons/laser/functions/fnc_getLaserCode.sqf @@ -0,0 +1,20 @@ +#include "..\script_component.hpp" +/* + * Author: johnb43 + * Gets the laser code of a laser source. + * + * Argument: + * 0: Laser source + * + * Return Value: + * None + * + * Example: + * player call ace_laser_fnc_getLaserCode; + * + * Public: Yes + */ + +params ["_laserSource"]; + +_laserSource getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE] diff --git a/addons/laser/functions/fnc_setLaserCode.sqf b/addons/laser/functions/fnc_setLaserCode.sqf new file mode 100644 index 00000000000..5f408fec931 --- /dev/null +++ b/addons/laser/functions/fnc_setLaserCode.sqf @@ -0,0 +1,21 @@ +#include "..\script_component.hpp" +/* + * Author: johnb43 + * Sets the laser code on a laser source. + * + * Argument: + * 0: Laser source + * 1: Laser code + * + * Return Value: + * None + * + * Example: + * [player, 1111] call ace_laser_fnc_setLaserCode; + * + * Public: Yes + */ + +params ["_laserSource", "_laserCode"]; + +_laserSource setVariable [QGVAR(code), _laserCode, true]; From e3d7df37875031e9e9a6c3af69e92add10bd8c15 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 6 Feb 2024 16:43:17 +0100 Subject: [PATCH 2/3] Documentation --- addons/laser/functions/fnc_getLaserCode.sqf | 2 +- docs/wiki/framework/laser-framework.md | 34 +++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 docs/wiki/framework/laser-framework.md diff --git a/addons/laser/functions/fnc_getLaserCode.sqf b/addons/laser/functions/fnc_getLaserCode.sqf index 7dd7c396a1d..05454b22618 100644 --- a/addons/laser/functions/fnc_getLaserCode.sqf +++ b/addons/laser/functions/fnc_getLaserCode.sqf @@ -7,7 +7,7 @@ * 0: Laser source * * Return Value: - * None + * Laser code * * Example: * player call ace_laser_fnc_getLaserCode; diff --git a/docs/wiki/framework/laser-framework.md b/docs/wiki/framework/laser-framework.md new file mode 100644 index 00000000000..1a7bbf7d6b4 --- /dev/null +++ b/docs/wiki/framework/laser-framework.md @@ -0,0 +1,34 @@ +--- +layout: wiki +title: Laser +description: Explains the functions available for laser designators. +group: framework +order: 5 +parent: wiki +mod: ace +version: + major: 3 + minor: 16 + patch: 4 +--- + +## 1. Scripting + +### 1.1. Get object's laser code + +`ace_laser_fnc_getLaserCode` + +| | Arguments | Type | Optional (default value) +---| --------- | ---- | ------------------------ +0 | Unit/Vehicle | Object | Required +**R** | Laser code | Number | Return value + +### 1.2. Set object's laser code + +`ace_laser_fnc_setLaserCode` + +| | Arguments | Type | Optional (default value) +---| --------- | ---- | ------------------------ +0 | Unit/Vehicle | Object | Required +1 | Laser code | Number | Required +**R** | None | None | Return value From c3aa97481e504fcbf6fd2e8cfa3116ec3bf850eb Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:26:06 +0100 Subject: [PATCH 3/3] Sanitising input --- addons/laser/functions/fnc_getLaserCode.sqf | 6 +++++- addons/laser/functions/fnc_setLaserCode.sqf | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/laser/functions/fnc_getLaserCode.sqf b/addons/laser/functions/fnc_getLaserCode.sqf index 05454b22618..0a0fce363fd 100644 --- a/addons/laser/functions/fnc_getLaserCode.sqf +++ b/addons/laser/functions/fnc_getLaserCode.sqf @@ -15,6 +15,10 @@ * Public: Yes */ -params ["_laserSource"]; +params [["_laserSource", objNull, [objNull]]]; + +if (isNull _laserSource) exitWith { + -1 +}; _laserSource getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE] diff --git a/addons/laser/functions/fnc_setLaserCode.sqf b/addons/laser/functions/fnc_setLaserCode.sqf index 5f408fec931..23f7e5c82fb 100644 --- a/addons/laser/functions/fnc_setLaserCode.sqf +++ b/addons/laser/functions/fnc_setLaserCode.sqf @@ -16,6 +16,6 @@ * Public: Yes */ -params ["_laserSource", "_laserCode"]; +params [["_laserSource", objNull, [objNull]], ["_laserCode", ACE_DEFAULT_LASER_CODE, [0]]]; _laserSource setVariable [QGVAR(code), _laserCode, true];