dreamworkAPI
Ctrl K
GitHub
classDocs / steam / Identifier

steam.Identifier

classsharedmenusource
Object → 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, see to64 and from64.
  • Steam2 - STEAM_0:0:11101, see toSteam2 and fromSteam2, only for Individual accounts.
  • Steam3 - [U:1:22202], see toSteam3 and fromSteam3, also used by tostring.
  • Community URL - https://steamcommunity.com/profiles/76561197960287930, see getURL and parse.

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.Identifier

Fields

NameTypeDescription
highintegerThe upper 32 bits of the SteamID64, universe << 24 | type << 20 | instance, read-only.
idintegerThe unique account number (the lower 32 bits of the SteamID64, also known as AccountID), read-only.
INVALIDThe 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

OperatorOperandResult
add integer steam.Identifier
sub integer steam.Identifier

Static functions

from64Creates a new Steam ID from a SteamID64 string, like Player:SteamID64().
fromAccountIDCreates a new Steam ID of a Public Individual desktop account from its account number.
fromSteam2Creates a new Steam ID of an Individual desktop account from a Steam2 string, like Player:SteamID().
fromSteam3Creates a new Steam ID from a Steam3 string.
isValid64Checks if a string is a valid SteamID64, 1 to 20 decimal digits within the unsigned 64-bit range.
isValidSteam2Checks 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.
isValidSteam3Checks if a string is a valid Steam3 string, [letter:universe:id] or [letter:universe:id:instance].
parseCreates a new Steam ID from a SteamID64, Steam2, Steam3 or Steam Community URL string, like tryParse, but raises a Valu…
to64Converts the Steam ID to a SteamID64 string, like Player:SteamID64().
toSteam3Converts the Steam ID to a Steam3 string, [letter:universe:id], also used by tostring.
tryParseCreates a new Steam ID from a SteamID64, Steam2, Steam3 or Steam Community URL string, detected by its first character.

#steam.Identifier.from64

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
uint64_strstringThe decimal SteamID64, e.g. 76561197960287930.
Returns
TypeNameDescription
steam.IdentifierobjectThe Steam ID.

#steam.Identifier.fromAccountID

sharedmenunodiscardsource
function steam.Identifier.fromAccountID(account_id: integer): steam.Identifier

Creates a new Steam ID of a Public Individual desktop account from its account number.

Parameters
NameTypeDescription
account_idintegerThe 32-bit account number, like Player:AccountID().
Returns
TypeNameDescription
steam.IdentifierobjectThe Steam ID.

#steam.Identifier.fromSteam2

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
steam2_strstringThe Steam2 string, e.g. STEAM_0:0:11101, the STEAM_ prefix is case-insensitive.
allow_zero_universeoptionalbooleanIf true, STEAM_0: stays Invalid, otherwise it is treated as Public like the Source engine does.
Returns
TypeNameDescription
steam.IdentifierobjectThe Steam ID.

#steam.Identifier.fromSteam3

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
steam3_strstringThe Steam3 string, e.g. [U:1:22202].
Returns
TypeNameDescription
steam.IdentifierobjectThe Steam ID.

#steam.Identifier.isValid64

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
uint64_strstringThe string to check.
Returns
TypeNameDescription
booleanis_validtrue if the string is a valid SteamID64, false otherwise.
nil | stringerror_messageThe reason why the string is invalid, nil if it is valid.

#steam.Identifier.isValidSteam2

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
steam2_strstringThe string to check.
Returns
TypeNameDescription
booleanis_validtrue if the string is a valid Steam2 string, false otherwise.
nil | stringerror_messageThe reason why the string is invalid, nil if it is valid.

#steam.Identifier.isValidSteam3

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
steam3_strstringThe string to check.
Returns
TypeNameDescription
booleanis_validtrue if the string is a valid Steam3 string, false otherwise.
nil | stringerror_messageThe reason why the string is invalid, nil if it is valid.

#steam.Identifier.parse

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
strstringThe string, e.g. 76561197960287930, STEAM_0:0:11101, [U:1:22202] or https://steamcommunity.com/profiles/76561197960287930.
Returns
TypeNameDescription
steam.IdentifierobjectThe Steam ID.

#steam.Identifier.to64

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
selfsteam.Identifier
Returns
TypeNameDescription
stringuint64_strThe decimal SteamID64, e.g. 76561197960287930.

#steam.Identifier.toSteam3

sharedmenunodiscardsource
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].

Parameters
NameTypeDescription
selfsteam.Identifier
Returns
TypeNameDescription
stringsteam3_strThe Steam3 string, e.g. [U:1:22202].

#steam.Identifier.tryParse

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
strstringThe string, e.g. 76561197960287930, STEAM_0:0:11101, [U:1:22202] or https://steamcommunity.com/profiles/76561197960287930.
Returns
TypeNameDescription
steam.Identifier | nilobjectThe Steam ID, or nil if the string is invalid.
nil | stringerror_messageThe reason why the string is invalid, nil on success.

Methods

getInstanceReturns the instance of the Steam ID.
getTypeReturns the account type of the Steam ID (e.g.
getUniverseReturns the universe of the Steam ID, the Steam environment the account belongs to (e.g.
isChatChecks if the Steam ID is a Chat account, including clan chats and lobbies.
isClanChecks if the Steam ID is a Clan (Steam group) account.
isClanChatChecks if the Steam ID is the chat of a Steam group, a Chat account with the clan flag.
isGameServerChecks if the Steam ID is a GameServer or AnonGameServer account.
isIndividualChecks if the Steam ID is an Individual user account.
isLobbyChecks if the Steam ID is a matchmaking lobby, a Chat account with the lobby flag.
isSameAccountChecks if both Steam IDs belong to the same account, ignoring the instance.
isValidChecks if the Steam ID could belong to a real account.
toClanReturns the Steam group of a clan chat, [c:1:N] becomes [g:1:N].
toClanChatReturns the chat of a Steam group, [g:1:N] becomes [c:1:N].
toSteam2Converts 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.
toURLReturns the Steam Community URL of the Steam ID, a profile for Individual and a group for Clan accounts.
withAccountIDReturns a Steam ID with the given account number, the universe, account type and instance are kept.
withInstanceReturns a Steam ID with the given instance, the universe, account type and account number are kept.
withTypeReturns a Steam ID with the given account type, the universe, instance and account number are kept.
withUniverseReturns a Steam ID with the given universe, the account type, instance and account number are kept.

#Identifier:getInstance

sharedmenunodiscardsource
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.

Returns
TypeNameDescription
integerinstanceThe 20-bit instance.

#Identifier:getType

sharedmenunodiscardsource
function steam.Identifier:getType(): steam.IdentifierType

Returns the account type of the Steam ID (e.g. Individual user, Clan group, GameServer).

Returns
TypeNameDescription
steam.IdentifierTypeaccount_typeThe account type, Invalid if the packed value is unknown.

#Identifier:getUniverse

sharedmenunodiscardsource
function steam.Identifier:getUniverse(): steam.IdentifierUniverse

Returns the universe of the Steam ID, the Steam environment the account belongs to (e.g. Public, Beta).

Returns
TypeNameDescription
steam.IdentifierUniverseuniverseThe universe, Invalid if the packed value is unknown.

#Identifier:isChat

sharedmenunodiscardsource
function steam.Identifier:isChat(): boolean

Checks if the Steam ID is a Chat account, including clan chats and lobbies.

Returns
TypeNameDescription
booleanis_chat

#Identifier:isClan

sharedmenunodiscardsource
function steam.Identifier:isClan(): boolean

Checks if the Steam ID is a Clan (Steam group) account.

Returns
TypeNameDescription
booleanis_clan

#Identifier:isClanChat

sharedmenunodiscardsource
function steam.Identifier:isClanChat(): boolean

Checks if the Steam ID is the chat of a Steam group, a Chat account with the clan flag.

Returns
TypeNameDescription
booleanis_clan_chat

#Identifier:isGameServer

sharedmenunodiscardsource
function steam.Identifier:isGameServer(): boolean

Checks if the Steam ID is a GameServer or AnonGameServer account.

Returns
TypeNameDescription
booleanis_game_server

#Identifier:isIndividual

sharedmenunodiscardsource
function steam.Identifier:isIndividual(): boolean

Checks if the Steam ID is an Individual user account.

Returns
TypeNameDescription
booleanis_individual

#Identifier:isLobby

sharedmenunodiscardsource
function steam.Identifier:isLobby(): boolean

Checks if the Steam ID is a matchmaking lobby, a Chat account with the lobby flag.

Returns
TypeNameDescription
booleanis_lobby

#Identifier:isSameAccount

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
othersteam.IdentifierThe Steam ID to compare with.
Returns
TypeNameDescription
booleanis_sametrue if universe, account type and account number match, false otherwise.

#Identifier:isValid

sharedmenunodiscardsource
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.

Returns
TypeNameDescription
booleanis_validtrue if the Steam ID is valid, false otherwise.

#Identifier:toClan

sharedmenunodiscardsource
function steam.Identifier:toClan(): steam.Identifier | nil

Returns the Steam group of a clan chat, [c:1:N] becomes [g:1:N].

Returns
TypeNameDescription
steam.Identifier | nilobjectThe Clan Steam ID, or nil if the Steam ID is not a clan chat.

#Identifier:toClanChat

sharedmenunodiscardsource
function steam.Identifier:toClanChat(): steam.Identifier | nil

Returns the chat of a Steam group, [g:1:N] becomes [c:1:N].

Returns
TypeNameDescription
steam.Identifier | nilobjectThe clan chat Steam ID, or nil if the Steam ID is not a Clan.

#Identifier:toSteam2

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
use_universeoptionalbooleanIf true, the real universe is rendered instead, e.g. STEAM_1: for Public.
Returns
TypeNameDescription
string | nilsteam2_strThe Steam2 string, e.g. STEAM_0:0:11101, or nil if the Steam ID is not Individual.

#Identifier:toURL

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
httpoptionalbooleanIf true, returns the HTTP URL, otherwise returns the HTTPS URL.
Returns
TypeNameDescription
string | nilurl_strThe URL, e.g. https://steamcommunity.com/profiles/76561197960287930, or nil for other account types.

#Identifier:withAccountID

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
account_idintegerThe 32-bit account number, wrapped to 32 bits.
Returns
TypeNameDescription
steam.IdentifierobjectThe Steam ID.

#Identifier:withInstance

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
instanceintegerThe 20-bit instance, wrapped to 20 bits.
Returns
TypeNameDescription
steam.IdentifierobjectThe Steam ID.

#Identifier:withType

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
account_typesteam.IdentifierTypeThe account type, unknown names are stored as Invalid.
Returns
TypeNameDescription
steam.IdentifierobjectThe Steam ID.

#Identifier:withUniverse

sharedmenunodiscardsource
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.

Parameters
NameTypeDescription
universesteam.IdentifierUniverseThe universe, unknown names are stored as Invalid.
Returns
TypeNameDescription
steam.IdentifierobjectThe Steam ID.
Generated from the dreamwork meta branch.