Laser - Public getter and setter for laser codes (#9772)

* Getter and setter for laser codes

* Documentation

* Sanitising input
This commit is contained in:
johnb432 2024-02-07 17:49:36 +01:00 committed by GitHub
parent ae532c72f7
commit 28e45c2979
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 81 additions and 0 deletions

View File

@ -3,6 +3,7 @@ PREP(addLaserTarget);
PREP(addMapHandler); PREP(addMapHandler);
PREP(dev_drawVisibleLaserTargets); PREP(dev_drawVisibleLaserTargets);
PREP(findLaserSource); PREP(findLaserSource);
PREP(getLaserCode);
PREP(handleLaserTargetCreation); PREP(handleLaserTargetCreation);
PREP(keyLaserCodeChange); PREP(keyLaserCodeChange);
PREP(laserOff); PREP(laserOff);
@ -13,6 +14,7 @@ PREP(onLaserDesignatorDraw);
PREP(rotateVectLine); PREP(rotateVectLine);
PREP(rotateVectLineGetMap); PREP(rotateVectLineGetMap);
PREP(seekerFindLaserSpot); PREP(seekerFindLaserSpot);
PREP(setLaserCode);
PREP(shootCone); PREP(shootCone);
PREP(shootRay); PREP(shootRay);
PREP(showVehicleHud); PREP(showVehicleHud);

View File

@ -0,0 +1,24 @@
#include "..\script_component.hpp"
/*
* Author: johnb43
* Gets the laser code of a laser source.
*
* Argument:
* 0: Laser source <OBJECT>
*
* Return Value:
* Laser code <NUMBER>
*
* Example:
* player call ace_laser_fnc_getLaserCode;
*
* Public: Yes
*/
params [["_laserSource", objNull, [objNull]]];
if (isNull _laserSource) exitWith {
-1
};
_laserSource getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE]

View File

@ -0,0 +1,21 @@
#include "..\script_component.hpp"
/*
* Author: johnb43
* Sets the laser code on a laser source.
*
* Argument:
* 0: Laser source <OBJECT>
* 1: Laser code <NUMBER>
*
* Return Value:
* None
*
* Example:
* [player, 1111] call ace_laser_fnc_setLaserCode;
*
* Public: Yes
*/
params [["_laserSource", objNull, [objNull]], ["_laserCode", ACE_DEFAULT_LASER_CODE, [0]]];
_laserSource setVariable [QGVAR(code), _laserCode, true];

View File

@ -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