steam.Identifier
A Steam ID, the identifier of a Steam account.
Stored as the two 32-bit halves of the SteamID64, use getUniverse, getType and getInstance to read the packed fields.
Converts between the textual formats:
- SteamID64 -
76561197960287930, seeto64andfrom64. - Steam2 -
STEAM_0:0:11101, seetoSteam2andfromSteam2, only forIndividualaccounts. - Steam3 -
[U:1:22202], seetoSteam3andfromSteam3, also used bytostring. - Community URL -
https://steamcommunity.com/profiles/76561197960287930, seegetURLandparse.
Identifiers are compared by value (==), so equal Steam IDs can still be different objects, use to64 as a table key. Methods never modify the object, the with* methods return a modified copy.
Identifiers are ordered like their SteamID64 numbers (<, <=, table.sort), adding or subtracting an integer offsets the account number, wrapping around 32 bits.
Binary serialization writes the 8 little endian bytes of the SteamID64.
Constructor
steam.Identifier(universe: steam.IdentifierUniverse?, type: steam.IdentifierType?, id: integer?, instance: integer?): steam.IdentifierFields
| Name | Type | Description |
|---|---|---|
high | integer | The upper 32 bits of the SteamID64, universe << 24 | type << 20 | instance, read-only. |
id | integer | The unique account number (the lower 32 bits of the SteamID64, also known as AccountID), read-only. |
INVALID | | The all-zero Steam ID, Invalid universe and type with account number 0.
Also returned by parse for the placeholder strings of the Source engine (BOT, STEAM_ID_PENDING, ...). |
Operators
| Operator | Operand | Result |
|---|---|---|
add | integer | steam.Identifier |
sub | integer | steam.Identifier |
Static functions
from64 | Creates a new Steam ID from a SteamID64 string, like Player:SteamID64(). |
fromAccountID | Creates a new Steam ID of a Public Individual desktop account from its account number. |
fromSteam2 | Creates a new Steam ID of an Individual desktop account from a Steam2 string, like Player:SteamID(). |
fromSteam3 | Creates a new Steam ID from a Steam3 string. |
isValid64 | Checks if a string is a valid SteamID64, 1 to 20 decimal digits within the unsigned 64-bit range. |
isValidSteam2 | Checks if a string is a valid Steam2 string, STEAM_X:Y:Z with an 8-bit universe, 0 or 1 and a 31-bit number. |
isValidSteam3 | Checks if a string is a valid Steam3 string, [letter:universe:id] or [letter:universe:id:instance]. |
parse | Creates a new Steam ID from a SteamID64, Steam2, Steam3 or Steam Community URL string, like tryParse, but raises a Valu… |
to64 | Converts the Steam ID to a SteamID64 string, like Player:SteamID64(). |
toSteam3 | Converts the Steam ID to a Steam3 string, [letter:universe:id], also used by tostring. |
tryParse | Creates a new Steam ID from a SteamID64, Steam2, Steam3 or Steam Community URL string, detected by its first character. |
#steam.Identifier.from64
function steam.Identifier.from64(uint64_str: string): steam.Identifier
Creates a new Steam ID from a SteamID64 string, like Player:SteamID64().
The string is not validated, check it with isValid64 first or use parse.
| Name | Type | Description |
|---|---|---|
uint64_str | string | The decimal SteamID64, e.g. 76561197960287930. |
| Type | Name | Description |
|---|---|---|
steam.Identifier | object | The Steam ID. |
#steam.Identifier.fromAccountID
function steam.Identifier.fromAccountID(account_id: integer): steam.Identifier
Creates a new Steam ID of a Public Individual desktop account from its account number.
| Name | Type | Description |
|---|---|---|
account_id | integer | The 32-bit account number, like Player:AccountID(). |
| Type | Name | Description |
|---|---|---|
steam.Identifier | object | The Steam ID. |
#steam.Identifier.fromSteam2
function steam.Identifier.fromSteam2(steam2_str: string, allow_zero_universe?: boolean): steam.Identifier
Creates a new Steam ID of an Individual desktop account from a Steam2 string, like Player:SteamID().
Only the format is enforced, the universe wraps to 8 bits, check the string with isValidSteam2 first or use parse.
| Name | Type | Description |
|---|---|---|
steam2_str | string | The Steam2 string, e.g. STEAM_0:0:11101, the STEAM_ prefix is case-insensitive. |
allow_zero_universeoptional | boolean | If true, STEAM_0: stays Invalid, otherwise it is treated as Public like the Source engine does. |
| Type | Name | Description |
|---|---|---|
steam.Identifier | object | The Steam ID. |
#steam.Identifier.fromSteam3
function steam.Identifier.fromSteam3(steam3_str: string): steam.Identifier
Creates a new Steam ID from a Steam3 string.
Brackets are optional, the instance is taken from the optional fourth field ([A:1:123:456]), otherwise c and L chat letters set the clan chat and lobby instance flags and the rest get the default instance of their account type.
Only the format is enforced, unknown letters become Invalid and numbers wrap to their field widths, check the string with isValidSteam3 first or use parse.
| Name | Type | Description |
|---|---|---|
steam3_str | string | The Steam3 string, e.g. [U:1:22202]. |
| Type | Name | Description |
|---|---|---|
steam.Identifier | object | The Steam ID. |
#steam.Identifier.isValid64
function steam.Identifier.isValid64(uint64_str: string): boolean, nil | string
Checks if a string is a valid SteamID64, 1 to 20 decimal digits within the unsigned 64-bit range.
Only the format is checked, use Identifier:isValid to check the parsed fields.
| Name | Type | Description |
|---|---|---|
uint64_str | string | The string to check. |
| Type | Name | Description |
|---|---|---|
boolean | is_valid | true if the string is a valid SteamID64, false otherwise. |
nil | string | error_message | The reason why the string is invalid, nil if it is valid. |
#steam.Identifier.isValidSteam2
function steam.Identifier.isValidSteam2(steam2_str: string): boolean, nil | string
Checks if a string is a valid Steam2 string, STEAM_X:Y:Z with an 8-bit universe, 0 or 1 and a 31-bit number.
The STEAM_ prefix is case-insensitive.
| Name | Type | Description |
|---|---|---|
steam2_str | string | The string to check. |
| Type | Name | Description |
|---|---|---|
boolean | is_valid | true if the string is a valid Steam2 string, false otherwise. |
nil | string | error_message | The reason why the string is invalid, nil if it is valid. |
#steam.Identifier.isValidSteam3
function steam.Identifier.isValidSteam3(steam3_str: string): boolean, nil | string
Checks if a string is a valid Steam3 string, [letter:universe:id] or [letter:universe:id:instance].
Requires the brackets, a known account type letter, an 8-bit universe, a 32-bit account number and an optional 20-bit instance.
| Name | Type | Description |
|---|---|---|
steam3_str | string | The string to check. |
| Type | Name | Description |
|---|---|---|
boolean | is_valid | true if the string is a valid Steam3 string, false otherwise. |
nil | string | error_message | The reason why the string is invalid, nil if it is valid. |
#steam.Identifier.parse
function steam.Identifier.parse(str: string): steam.Identifier
Creates a new Steam ID from a SteamID64, Steam2, Steam3 or Steam Community URL string, like tryParse, but raises a ValueError if the string is invalid.
| Name | Type | Description |
|---|---|---|
str | string | The string, e.g. 76561197960287930, STEAM_0:0:11101, [U:1:22202] or https://steamcommunity.com/profiles/76561197960287930. |
| Type | Name | Description |
|---|---|---|
steam.Identifier | object | The Steam ID. |
#steam.Identifier.to64
function steam.Identifier.to64(self: steam.Identifier): string
Converts the Steam ID to a SteamID64 string, like Player:SteamID64().
A string, since Lua numbers can't hold 64-bit integers exactly. The result is cached on the object.
| Name | Type | Description |
|---|---|---|
self | steam.Identifier |
| Type | Name | Description |
|---|---|---|
string | uint64_str | The decimal SteamID64, e.g. 76561197960287930. |
#steam.Identifier.toSteam3
function steam.Identifier.toSteam3(self: steam.Identifier): string
Converts the Steam ID to a Steam3 string, [letter:universe:id], also used by tostring.
The letter is the account type, c and L for clan chats and lobbies.
The instance is appended as a fourth field for AnonGameServer accounts and Individual accounts with a non-desktop instance, e.g. [U:1:22202:2].
| Name | Type | Description |
|---|---|---|
self | steam.Identifier |
| Type | Name | Description |
|---|---|---|
string | steam3_str | The Steam3 string, e.g. [U:1:22202]. |
#steam.Identifier.tryParse
function steam.Identifier.tryParse(str: string): steam.Identifier | nil, nil | string
Creates a new Steam ID from a SteamID64, Steam2, Steam3 or Steam Community URL string, detected by its first character.
The string is fully validated, unlike with from64, fromSteam2 and fromSteam3. Steam3 strings must have brackets here, STEAM_0: is treated as Public.
Placeholders of the Source engine (BOT, NULL, UNKNOWN, STEAM_ID_LAN and STEAM_ID_PENDING) return INVALID.
| Name | Type | Description |
|---|---|---|
str | string | The string, e.g. 76561197960287930, STEAM_0:0:11101, [U:1:22202] or https://steamcommunity.com/profiles/76561197960287930. |
| Type | Name | Description |
|---|---|---|
steam.Identifier | nil | object | The Steam ID, or nil if the string is invalid. |
nil | string | error_message | The reason why the string is invalid, nil on success. |
Methods
getInstance | Returns the instance of the Steam ID. |
getType | Returns the account type of the Steam ID (e.g. |
getUniverse | Returns the universe of the Steam ID, the Steam environment the account belongs to (e.g. |
isChat | Checks if the Steam ID is a Chat account, including clan chats and lobbies. |
isClan | Checks if the Steam ID is a Clan (Steam group) account. |
isClanChat | Checks if the Steam ID is the chat of a Steam group, a Chat account with the clan flag. |
isGameServer | Checks if the Steam ID is a GameServer or AnonGameServer account. |
isIndividual | Checks if the Steam ID is an Individual user account. |
isLobby | Checks if the Steam ID is a matchmaking lobby, a Chat account with the lobby flag. |
isSameAccount | Checks if both Steam IDs belong to the same account, ignoring the instance. |
isValid | Checks if the Steam ID could belong to a real account. |
toClan | Returns the Steam group of a clan chat, [c:1:N] becomes [g:1:N]. |
toClanChat | Returns the chat of a Steam group, [g:1:N] becomes [c:1:N]. |
toSteam2 | Converts the Steam ID to a Steam2 string, STEAM_X:Y:Z, where Y is the lowest bit of the account number and Z the rest. |
toURL | Returns the Steam Community URL of the Steam ID, a profile for Individual and a group for Clan accounts. |
withAccountID | Returns a Steam ID with the given account number, the universe, account type and instance are kept. |
withInstance | Returns a Steam ID with the given instance, the universe, account type and account number are kept. |
withType | Returns a Steam ID with the given account type, the universe, instance and account number are kept. |
withUniverse | Returns a Steam ID with the given universe, the account type, instance and account number are kept. |
#Identifier:getInstance
function steam.Identifier:getInstance(): integer
Returns the instance of the Steam ID.
Differentiates between multiple instances of the same account, 1 (desktop) for individual user accounts, 0 for most others.
Chat accounts store their flags here, 0x80000 for clan chats and 0x40000 for lobbies.
| Type | Name | Description |
|---|---|---|
integer | instance | The 20-bit instance. |
#Identifier:getType
function steam.Identifier:getType(): steam.IdentifierType
Returns the account type of the Steam ID (e.g. Individual user, Clan group, GameServer).
| Type | Name | Description |
|---|---|---|
steam.IdentifierType | account_type | The account type, Invalid if the packed value is unknown. |
#Identifier:getUniverse
function steam.Identifier:getUniverse(): steam.IdentifierUniverse
Returns the universe of the Steam ID, the Steam environment the account belongs to (e.g. Public, Beta).
| Type | Name | Description |
|---|---|---|
steam.IdentifierUniverse | universe | The universe, Invalid if the packed value is unknown. |
#Identifier:isChat
function steam.Identifier:isChat(): boolean
Checks if the Steam ID is a Chat account, including clan chats and lobbies.
| Type | Name | Description |
|---|---|---|
boolean | is_chat |
#Identifier:isClan
function steam.Identifier:isClan(): boolean
Checks if the Steam ID is a Clan (Steam group) account.
| Type | Name | Description |
|---|---|---|
boolean | is_clan |
#Identifier:isClanChat
function steam.Identifier:isClanChat(): boolean
Checks if the Steam ID is the chat of a Steam group, a Chat account with the clan flag.
| Type | Name | Description |
|---|---|---|
boolean | is_clan_chat |
#Identifier:isGameServer
function steam.Identifier:isGameServer(): boolean
Checks if the Steam ID is a GameServer or AnonGameServer account.
| Type | Name | Description |
|---|---|---|
boolean | is_game_server |
#Identifier:isIndividual
function steam.Identifier:isIndividual(): boolean
Checks if the Steam ID is an Individual user account.
| Type | Name | Description |
|---|---|---|
boolean | is_individual |
#Identifier:isLobby
function steam.Identifier:isLobby(): boolean
Checks if the Steam ID is a matchmaking lobby, a Chat account with the lobby flag.
| Type | Name | Description |
|---|---|---|
boolean | is_lobby |
#Identifier:isSameAccount
function steam.Identifier:isSameAccount(other: steam.Identifier): boolean
Checks if both Steam IDs belong to the same account, ignoring the instance.
Unlike ==, a desktop Steam ID matches the web or console instance of the same user.
| Name | Type | Description |
|---|---|---|
other | steam.Identifier | The Steam ID to compare with. |
| Type | Name | Description |
|---|---|---|
boolean | is_same | true if universe, account type and account number match, false otherwise. |
#Identifier:isValid
function steam.Identifier:isValid(): boolean
Checks if the Steam ID could belong to a real account.
Universe and type must be known and not Invalid, Individual and Clan accounts must also have a non-zero account number.
The instance is not checked.
| Type | Name | Description |
|---|---|---|
boolean | is_valid | true if the Steam ID is valid, false otherwise. |
#Identifier:toClan
function steam.Identifier:toClan(): steam.Identifier | nil
Returns the Steam group of a clan chat, [c:1:N] becomes [g:1:N].
| Type | Name | Description |
|---|---|---|
steam.Identifier | nil | object | The Clan Steam ID, or nil if the Steam ID is not a clan chat. |
#Identifier:toClanChat
function steam.Identifier:toClanChat(): steam.Identifier | nil
Returns the chat of a Steam group, [g:1:N] becomes [c:1:N].
| Type | Name | Description |
|---|---|---|
steam.Identifier | nil | object | The clan chat Steam ID, or nil if the Steam ID is not a Clan. |
#Identifier:toSteam2
function steam.Identifier:toSteam2(use_universe?: boolean): string | nil
Converts the Steam ID to a Steam2 string, STEAM_X:Y:Z, where Y is the lowest bit of the account number and Z the rest.
The universe is rendered as 0 by default, like Player:SteamID() and the rest of the Source engine.
Steam2 can only describe Individual accounts, the instance is dropped.
| Name | Type | Description |
|---|---|---|
use_universeoptional | boolean | If true, the real universe is rendered instead, e.g. STEAM_1: for Public. |
| Type | Name | Description |
|---|---|---|
string | nil | steam2_str | The Steam2 string, e.g. STEAM_0:0:11101, or nil if the Steam ID is not Individual. |
#Identifier:toURL
function steam.Identifier:toURL(http?: boolean): string | nil
Returns the Steam Community URL of the Steam ID, a profile for Individual and a group for Clan accounts.
| Name | Type | Description |
|---|---|---|
httpoptional | boolean | If true, returns the HTTP URL, otherwise returns the HTTPS URL. |
| Type | Name | Description |
|---|---|---|
string | nil | url_str | The URL, e.g. https://steamcommunity.com/profiles/76561197960287930, or nil for other account types. |
#Identifier:withAccountID
function steam.Identifier:withAccountID(account_id: integer): steam.Identifier
Returns a Steam ID with the given account number, the universe, account type and instance are kept.
| Name | Type | Description |
|---|---|---|
account_id | integer | The 32-bit account number, wrapped to 32 bits. |
| Type | Name | Description |
|---|---|---|
steam.Identifier | object | The Steam ID. |
#Identifier:withInstance
function steam.Identifier:withInstance(instance: integer): steam.Identifier
Returns a Steam ID with the given instance, the universe, account type and account number are kept.
| Name | Type | Description |
|---|---|---|
instance | integer | The 20-bit instance, wrapped to 20 bits. |
| Type | Name | Description |
|---|---|---|
steam.Identifier | object | The Steam ID. |
#Identifier:withType
function steam.Identifier:withType(account_type: steam.IdentifierType): steam.Identifier
Returns a Steam ID with the given account type, the universe, instance and account number are kept.
The instance is not reset, use withInstance when switching to or from Individual or Chat.
| Name | Type | Description |
|---|---|---|
account_type | steam.IdentifierType | The account type, unknown names are stored as Invalid. |
| Type | Name | Description |
|---|---|---|
steam.Identifier | object | The Steam ID. |
#Identifier:withUniverse
function steam.Identifier:withUniverse(universe: steam.IdentifierUniverse): steam.Identifier
Returns a Steam ID with the given universe, the account type, instance and account number are kept.
| Name | Type | Description |
|---|---|---|
universe | steam.IdentifierUniverse | The universe, unknown names are stored as Invalid. |
| Type | Name | Description |
|---|---|---|
steam.Identifier | object | The Steam ID. |