Skip to content

Commit

Permalink
Laser - Public getter and setter for laser codes (#9772)
Browse files Browse the repository at this point in the history
* Getter and setter for laser codes

* Documentation

* Sanitising input
  • Loading branch information
johnb432 authored Feb 7, 2024
1 parent ae532c7 commit 28e45c2
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
2 changes: 2 additions & 0 deletions addons/laser/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PREP(addLaserTarget);
PREP(addMapHandler);
PREP(dev_drawVisibleLaserTargets);
PREP(findLaserSource);
PREP(getLaserCode);
PREP(handleLaserTargetCreation);
PREP(keyLaserCodeChange);
PREP(laserOff);
Expand All @@ -13,6 +14,7 @@ PREP(onLaserDesignatorDraw);
PREP(rotateVectLine);
PREP(rotateVectLineGetMap);
PREP(seekerFindLaserSpot);
PREP(setLaserCode);
PREP(shootCone);
PREP(shootRay);
PREP(showVehicleHud);
Expand Down
24 changes: 24 additions & 0 deletions addons/laser/functions/fnc_getLaserCode.sqf
Original file line number Diff line number Diff line change
@@ -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]
21 changes: 21 additions & 0 deletions addons/laser/functions/fnc_setLaserCode.sqf
Original file line number Diff line number Diff line change
@@ -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];
34 changes: 34 additions & 0 deletions docs/wiki/framework/laser-framework.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 28e45c2

Please sign in to comment.