Last active
January 2, 2016 11:09
-
-
Save rickysaltzer/8294927 to your computer and use it in GitHub Desktop.
Convert SteamID to CommunityID. Shamelessly cobbled together from various pieces on the internet.
This file contains hidden or 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
local STEAMID = arg[1] | |
-- Generic split function found on the internet | |
-- http://coronalabs.com/blog/2013/04/16/lua-string-magic/ | |
function string:split( inSplitPattern, outResults ) | |
if not outResults then | |
outResults = { } | |
end | |
local theStart = 1 | |
local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart ) | |
while theSplitStart do | |
table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) ) | |
theStart = theSplitEnd + 1 | |
theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart ) | |
end | |
table.insert( outResults, string.sub( self, theStart ) ) | |
return outResults | |
end | |
-- Convert SteamID to Community ID (64) | |
function SteamIdToCommunityId( sid ) | |
local id = sid:split( ":" ) id = ( ( ( id[3] * 2 ) + id[2] ) + 1197960265728 ) id = "7656" .. id | |
return id | |
end | |
print( SteamIdToCommunityId( STEAMID ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment