-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function to create UUIDs (#1459)
- Loading branch information
1 parent
4576509
commit 9db07db
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_createUUID | ||
Description: | ||
Creates a version 4 UUID (universally unique identifier). | ||
Parameters: | ||
None | ||
Returns: | ||
UUID [String] | ||
Example: | ||
(begin example) | ||
private _uuid = call CBA_fnc_createUUID; | ||
(end) | ||
Author: | ||
BaerMitUmlaut | ||
--------------------------------------------------------------------------- */ | ||
SCRIPT(createUUID); | ||
|
||
private _hexDigits = [ | ||
"0", "1", "2", "3", "4", "5", "6", "7", | ||
"8", "9", "a", "b", "c", "d", "e", "f" | ||
]; | ||
private _versionByte = "4"; | ||
private _variantByte = selectRandom ["8", "9", "a", "b"]; | ||
|
||
private _uuid = []; | ||
for "_i" from 0 to 29 do { | ||
_uuid pushBack selectRandom _hexDigits; | ||
}; | ||
|
||
_uuid insert [8, ["-"]]; | ||
_uuid insert [13, ["-", _versionByte]]; | ||
_uuid insert [17, ["-", _variantByte]]; | ||
_uuid insert [22, ["-"]]; | ||
_uuid joinString "" |