Forum

> > CS2D > Scripts > Handle SteamIDs Easily in Lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English Handle SteamIDs Easily in Lua

3 replies
To the start Previous 1 Next To the start

old Handle SteamIDs Easily in Lua

Hajt
User Off Offline

Quote
Lua doesn't support 64-bit integers, so SteamID64 strings are really annoying to work with.

I just convert them to SteamID32 - it fits in a native Lua integer (4 bytes) and is way easier to handle, example:

1
2
3
4
5
function SteamID64To32(s) 
    return tonumber(s) - 76561197960265728 
end

print(SteamID64To32("76561197960287930") )

Devs probably won't switch SteamID64 strings to 32-bit integers, so converting in Lua is usually the easiest way.

https://developer.valvesoftware.com/wiki/SteamID
edited 2×, last 16.09.25 10:38:29 pm

old Re: Handle SteamIDs Easily in Lua

Hajt
User Off Offline

Quote
Well, using numbers is usually better for speed and memory. An integer takes about 4b, while a 17-char string uses at least 17b, plus a bit more if you add \r\n. Sorting numbers is simpler and faster because it just compares numeric values directly.

However, for small datasets, this difference doesn't really matter. Modern PCs are quite good at comparing strings, so the performance gap is often very small.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview